Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

3D snoise has artifacts and periodic tendencies

Đang mở
#62 0 bình luận 2 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
csharp

Hướng nghiên cứu

Bắt đầu bằng cách chạy PerlinNoiseGenJob được cung cấp và kiểm tra texture được tạo từ noise.snoise(float3(pnx, pny, z)) với các kích thước và tần số được hiển thị. Theo dõi triển khai 3D snoise cùng các bài kiểm thử hoặc ví dụ của nó, sau đó xác minh rằng output được tạo không còn xuất hiện tính tuần hoàn theo đường chéo đã được báo cáo hoặc các pixel -1/1 không liên tục.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

The provided 3D snoise function produces very low quality perlin noise and appears to be unusable for any practical application.

Here is a sample output of the algorithm, converted to PNG format:
Perlin

As you can see, there is a diagonal periodic nature to it at higher scales. And, if you look very closely, you can see a pattern of discontinuous individual pixels (stuck at values -1 or 1).

Here is the code I used to generate this texture. Perhaps I made a mistake somewhere?

    [BurstCompile]
    public struct PerlinNoiseGenJob : IJob, IDisposable
    {
        public PerlinNoiseGenJob(int2 seed, float frequency, int2 origin, int2 dimensions, float valueMultiplier=1)
        {
            this.seed = seed;
            this.frequency = frequency;
            this.origin = origin;
            this.dimensions = dimensions;
            this.valueMultiplier = valueMultiplier;
            perlinNoise = new NativeArray<float>(dimensions.x * dimensions.y, Allocator.TempJob, NativeArrayOptions.UninitializedMemory);
        }
        
        public int2 seed;

        public float frequency;

        public int2 origin;

        public int2 dimensions;

        public float valueMultiplier;

        public NativeArray<float> perlinNoise;
        
        public void Execute()
        {
//            float z = (float) hash(seed) / uint.MaxValue;
            float z = 0;
            for (int i = 0; i < perlinNoise.Length; i++)
            {
                int ox = i % dimensions.x;
                int oy = i / dimensions.x;
                float pnx = (origin.x + ox) * frequency;
                float pny = (origin.y + oy) * frequency;
                perlinNoise[i] = noise.snoise(float3(pnx, pny, z)) * valueMultiplier;
            }
        }

        public void Dispose()
        {
            perlinNoise.Dispose();
        }
    }
    public class PerlinNoiseTextureGenerator : MonoBehaviour
    {
        public Texture2D texture;
        
        private void Start()
        {
            var dimensions = int2(1000,1000);
            var job = new PerlinNoiseGenJob(int2(5,12), 1f/10, int2(0,0), dimensions);
            var startTime = Time.realtimeSinceStartup;
            var handle = job.Schedule();
            handle.Complete();
            Debug.Log("Run time: "+(Time.realtimeSinceStartup - startTime));
            
            Color[] colors = new Color[dimensions.y * dimensions.x];
            for (int i=0; i<job.perlinNoise.Length; i++)
            {
                colors[i] = new Color((job.perlinNoise[i]+1)/2, 0,0);
            }
            
            texture = new Texture2D(dimensions.x,dimensions.y);
            texture.SetPixels(colors);
            
            //AssetDatabase.CreateAsset(texture, "Assets/Generated/Perlin.asset");
            File.WriteAllBytes("D:\\Perlin2.png", texture.EncodeToPNG());
            
            job.Dispose();
        }
    }
Ngôn ngữ chính
C#
Star
1.4k
Fork
159
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của Unity-Technologies/Unity.Mathematics

Tất cả issue của Unity-Technologies/Unity.Mathematics

Issue tương tự

Thêm issue về C#

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.