Unity-Technologies / Unity-Technologies/Unity.Mathematics

3D snoise artifact on x=y=z

Open
#71 1 comment 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
1.4k
Forks
159
PR merge metrics
No merged PRs in 30d

Description

The "snoise(float3 v)" function has artefacts in a line exactly at x=y=z.
This artefact seems to repeat in multiple places (always along the line x=y=z relative to a noise cell maybe?).

This produces obvious artefacts when used in my voxel engine in Unity3D,
which currently uses marching cubes to display the isosurface at value 0 of the 3d noise.

bug_img01

The relevant code is this:
valueForMarchingCubes = Unity.Mathematics.noise.snoise(pos3d / 100f) + 0.42f;

A reproduceable Unity3D script:

using UnityEngine;
using Unity.Mathematics;
using static Unity.Mathematics.math;

public class NoiseBugRepro : MonoBehaviour {
    // Start is called before the first frame update
    void Start () {
        string output = "";
        for (int i = 0; i<20; ++i) {
            float x = lerp(1.8f, 2.2f, i / 20f);
            float3 pos = float3(x, 2f, 2f);

            float val = noise.snoise(pos / 20f);

            output += string.Format("noise.snoise({0:F2}, {1:F2}, {2:F2}) -> {3:F6}\n", pos.x, pos.y, pos.z, val);
        }

        Debug.Log(output);
    }
}

Output that shows the artefact when exactly on the x=y=z line:

noise.snoise(1.80, 2.00, 2.00) -> -0.373848
noise.snoise(1.82, 2.00, 2.00) -> -0.372971
noise.snoise(1.84, 2.00, 2.00) -> -0.372090
noise.snoise(1.86, 2.00, 2.00) -> -0.371204
noise.snoise(1.88, 2.00, 2.00) -> -0.370314
noise.snoise(1.90, 2.00, 2.00) -> -0.369420
noise.snoise(1.92, 2.00, 2.00) -> -0.368521
noise.snoise(1.94, 2.00, 2.00) -> -0.367619
noise.snoise(1.96, 2.00, 2.00) -> -0.366712
noise.snoise(1.98, 2.00, 2.00) -> -0.365801
noise.snoise(2.00, 2.00, 2.00) -> -0.571772
noise.snoise(2.02, 2.00, 2.00) -> -0.363966
noise.snoise(2.04, 2.00, 2.00) -> -0.363043
noise.snoise(2.06, 2.00, 2.00) -> -0.362115
noise.snoise(2.08, 2.00, 2.00) -> -0.361184
noise.snoise(2.10, 2.00, 2.00) -> -0.360248
noise.snoise(2.12, 2.00, 2.00) -> -0.359309
noise.snoise(2.14, 2.00, 2.00) -> -0.358365
noise.snoise(2.16, 2.00, 2.00) -> -0.357418
noise.snoise(2.18, 2.00, 2.00) -> -0.356467

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Unity.Mathematics.noise.snoise(float3) implementation and run the supplied Unity3D NoiseBugRepro script. Compare the value at (2.00, 2.00, 2.00) with neighboring inputs, then verify that the artifact is removed and the output varies smoothly along the sampled line.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, unity
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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.