Sign in to follow this  
Varrak

Terrain normals from simplex noise derivatives

Recommended Posts

Varrak    100
I have a procedural planetary renderer up and running, using GPU Simplex Noise (Hybrid Multi-fractal and fBm terrain). I recently implemented derivatives in my code, which seem to work on simple textured noise, but not so well on terrain - the normals are skewed significantly. I'm just wondering if anyone else out there has used derivatives to generate normals, and how they did it? I was just using the heightmap to calculate normals using finite differencing, but this gave ugly seams at terrain patch boundaries which were difficult to fix.

Here's the code I have right now to calculate the normals:

[font=courier new,courier,monospace]float3 realNormal = normalize( normal - tangent * dot( tangent, noise.xyz ) - binormal * dot( binormal, noise.xyz ) );[/font]

Where normal, tangent and binormal are the interpolated per-vertex values, and noise.xyz is the noise derivatives in x, y and z. I'm guessing the errors I'm seeing are related to the scale of the noise and the scale applied to noise values in elevating the terrain, but for the life of me I can't figure out how to get it right. Any help would be much appreciated [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]

Share this post


Link to post
Share on other sites
Varrak    100
*sigh*. Turns out, the above code is right... but only if you normalize the derivative first. After hours of going around in circles, it of course turns out to be something trivial... [img]http://public.gamedev.net//public/style_emoticons/default/sad.png[/img]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this