Unity-Technologies / Unity-Technologies/Unity.Mathematics
3D snoise has artifacts and periodic tendencies
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 1.4k
- Forks
- 159
- PR merge metrics
- No merged PRs in 30d
Description
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:

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();
}
}
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the provided PerlinNoiseGenJob and inspecting the texture generated from noise.snoise(float3(pnx, pny, z)) with the shown dimensions and frequency. Trace the 3D snoise implementation and its tests or examples, then verify that the generated output no longer shows the reported diagonal periodicity or discontinuous -1/1 pixels.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- computer-graphics, game-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100