Hi there,
I’m trying to generate accurate normals for 3d noise displacement on arbitrary meshes. For 2d noise applied to a plane, this is easy: simply find the neighboring noise values with a small offset, and normalize the vectors.
However, for 3d noise, this approach doesn’t seem to work. I tried using the following approach but the results are really weird:
float3 GetNormal (float3 pos)
{
float small = 0.001;
float3 normal = float3(0.0, 0.0, 0.0);
normal.x = Noise( float3(pos.x+small, pos.y, pos.z)) - Noise( float3(pos.x-small, pos.y, pos.z));
normal.y = Noise( float3(pos.x, pos.y+small, pos.z)) - Noise( float3(pos.x, pos.y-small, pos.z));
normal.z = Noise( float3(pos.x, pos.y, pos.z+small)) - Noise( float3(pos.x, pos.y, pos.z-small));
return normalize(normal);
}
I’ve also read this article on normal perturbation but I have not been able to implement it correctly. Am I on the right track here?
Any suggestion would be greatly appreciated!