Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

3D snoise has artifacts and periodic tendencies

未关闭
#62 0 条评论 2 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
csharp

调研方向

首先运行提供的 PerlinNoiseGenJob,并检查在所示维度和频率下由 noise.snoise(float3(pnx, pny, z)) 生成的纹理。跟踪 3D snoise 的实现及其测试或示例,然后验证生成的输出不再显示报告中的对角线周期性或不连续的 -1/1 像素。

由索引模型根据 Issue 内容生成。

描述

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();
        }
    }
主要语言
C#
星标
1.4k
派生
159
PR 合并指标
30 天内没有已合并 PR

贡献指南

这个仓库没有索引到贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

Unity-Technologies/Unity.Mathematics 的其他 Issue

查看 Unity-Technologies/Unity.Mathematics 的全部 Issue

相似的 Issue

更多 C# Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。