2

I am studying/implementing a version of the Perlin Noise and Improved Perlin Noise. Perlin says in his paper that he replaced the smoothstep function

3t^2 - 2t^3

that he used to interpolate the 8 linear functions at the grid cell's corners with the function:

6t^5 - 15t^4 + 10t^3

Because the 2nd order derivative of the smoothstep function is discontinuous. He says (and that's clearly visible in the image he shows), that this causes some visual artefacts due to the way normals look like as the result of this function being used. Now I understand what a discontinuous function is. I also understand how normals are computed in the Perlin noise function using the partial derivatives of the Perlin Noise function, but I don't understand why the fact that 2nd order derivative being not continuous causes an issue with the normals. The normals are computed using the 1st order derivative of the Noise function, not the 2nd order derivative. So how can the fact that the 2nd order derivative is not continuous has such an effect on the normals?

enter image description here

For more details on the improved Noise Function.

user18490
  • 3,546
  • 4
  • 33
  • 52

1 Answers1

1

So how can the fact that the 2nd order derivative is not continuous has such an effect on the normals?

Firstly, remember that the 2nd order derivative is the normal's 1st order derivative. The problem is not about calculating normals, but rather how smoothly the normals progress in space. This will directly affect lighting and put in evidence the smoothness of the underlying function, and, generally speaking, the more continuosly derivable a function is, the smoother it will feel.

Although Perlin's former method results in continuos normals and continuos shading, you can still tell where the border is because the shading does not have a continuos derivative, and our perception is designed to perceive that as what it is: a continuos surface that is not that smooth in that border

Take a look at this four functions (from top to bottom):

  • Blatantly discontinuos mapping
  • Continous mapping, discontinuos derivative
  • Continuos derivative
  • Infinitely continuos derivative

            half TriangleWave (half x) {
    
                x = 2 * frac(x/2);
                return min(x, 2 - x);
            }
    
            half SShape (half x) {
    
                x = saturate(x);
                return x * x * (3 - 2 * x);
            }
    
            fixed4 frag (v2f f) : SV_Target {
    
                // Bottom to top coordinate system
                half x = 3 * f.tex.x;
                half y = f.tex.y;
    
                if (y > 0.75)
                    return frac(x);
                if (y > 0.5)
                    return TriangleWave(x);
                if (y > 0.25)
                    return SShape(TriangleWave(x));
                return 0.5 - 0.5 * cos(x*3.141592);
            }
    

    Functions smoothness comparison

The last one is the smoothest, but you almost can't tell it from the third one. But the second one, although a continous mapping, still lets you feel a border there.

Due to the normals' direct effect on lighting (the previous shader can easily be though as a lighting calculation), you are basically choosing between the second and third option. That's why you usually want the normals themselves to be continuously differentiable, and not settle for just continuity

Emilio Martinez
  • 1,052
  • 6
  • 22