1

I'm implementing a 3D perlin noise-based spherical planet generator but I'm getting line artifacts when trying to leverage the analytical derivative in the noise calculations. I'm calculating the analytical derivative using Milo Yip's approach: 3D Perlin noise analytical derivative

For instance, when trying to use IQ noise:

float IQturbulence(float3 p, int octaves, float freq, float amp, float gain, float lacunarity)
{
    float sum = 0.5;
    float3 dsum = float3(0,0,0);
    for(int i = 0; i < octaves; i++) 
    {
        float4 n = noiseDeriv((p*freq), (i)/256.0);
        dsum += n.yzw;
        sum += amp * n.x / (1 + dot(dsum,dsum));
        freq *= lacunarity;
        amp *= gain;
    }
    return sum;
}

I get these grid line artifacts that look like this:

https://i.stack.imgur.com/pyynF.jpg

However, these lines only occur when I leverage the dot product (scalar) of the derivative in the noise calculation,

i.e.

(1 + dot(deriv,deriv))

whether that is used to modulate the amplification, frequency, etc. it always seems to produce artifacts.

When using the derivative to domain warp, I get no line artifacts.

ex.

float4 n = noiseDeriv((p + 0.15 * dsum) * freq, (i)/256.0);

Is this simply a limitation with classic Perlin noise? I'm a bit hesitant to change noise algorithms entirely at this stage of my project. :/

  • Note: I am using quintic functions when calculating the derivative.
onehand
  • 11
  • 5
  • Interestingly, on [this](http://www.decarpentier.nl/scape-procedural-extensions) page, de Carpentier is taking another derivative _d(w*f)/df_ and incorporating that in his final derivative calculation (see his `perlinNoiseDeriv` method). `// Get the derivative d(w*f)/df` `float2 dwp = f * f * f * (f * (f * 36 - 75) + 40); // 36f^5 - 75f^4 + 40f^3` This isn't the second derivative, so I'm not sure what this curve is for. Are there any math wizzes that might know how to incorporate this into Milo Yip's equation? :) de Carpentier's is only for 2D. – onehand Oct 07 '17 at 21:58

1 Answers1

0

So I'm not sure if I messed up somewhere or what, but I was able to get the artifacts successfully removed by replacing this one section for the x derivative from Milo's solution:

float nx = gx000
    + uP * (dot100 - dot000)
    + u  * (gx100 - gx000)
    + v  * (gx010 - gx000)
    + w  * (gx001 - gx000)
    + uP * v * (dot110 - dot010 - dot100 + dot000)
    + u * v *  (gx110 - gx010 - gx100 + gx000)
    + uP * w * (dot101 - dot001 - dot100 + dot000)
    + u * w *  (gx101 - gx001 - gx100 - gx000)
    + v * w *  (gx011 - gx001 - gx010 + gx000)
    + uP * v * w * (dot111 - dot011 - dot101 + dot001 - dot110 + dot010 + dot100 - dot000)
    + u * v * w *  (gx111 - gx011 - gx101 + gx001 - gx110 + gx010 + gx100 - gx000);

with

float a = dot000;
float b = dot100;
float c = dot010;
float d = dot110;
float e = dot001;
float f = dot101;
float g = dot011;
float h = dot111;

float nx = uP*(b - a) 
    + uP*v*(a + d - b - c) 
    + uP*w*(a + f - b - e)
    + uP*v*w*(b + c + e + h - a - d - f - g);

3D IQ noise looks great now!

I got the derivation here.

I didn't have to change ny and nz for the artifacts to go away, but I went ahead and updated those as well.

float ny = vP*(c - a) 
    + u*vP*(a + d - b - c)
    + vP*w*(a + g - c - e)
    + u*vP*w*(b + c + e + h - a - d - f - g);

float nz = wP*(e - a)
    + u*wP*(a + f - b - e)
    + v*wP*(a + g - c - e)
    + u*v*wP*(b + c + e + h - a - d - f - g);
onehand
  • 11
  • 5