Sign in to follow this  
mancubit

normal mapping on "exposed cube" planets

Recommended Posts

I am currently struggling to implement normal mapping on my planet renderer.

My planet is basically a cube consisting of 6 planes (one for each side). In the vertex shader the vertices get normalized (which creates a unit sphere) and scaled with the radius of the planet and the result of a perlin noise function to create some mountains. Everything works fine, but i cant figure out how to apply normal mapping onto the surface.

Fortunately i was able to get the surface normals by getting the top/bottom/left/right neighbor of the current vertex in object space. Then i am transforming these neighbors to world space and apply the noise function. The tangents were then calculated by the differences of top/bottom and right/left neighbors and I calculate the surface normal by using the cross product between these. The bad thing is, although the surface normal is correct on the whole planet, the tangents and bitangents aren't consitent. In the screenshot i am drawing the tangents. As you can see, the left and right faces of the planet have uncontinuous tangents.
I guess thats because the top neighbor on the top plane isnt the top neighbor of the right plane, but every fix i am trying to adjust the sampled neighbors doesnt work.

So basically the question is: how do i calculate the tangents that they are continuous over the whole sphere? (so that i am able to create a correct tangent space for normal mapping)
any help is appreciated, as i am completly stuck on this problem

[attachment=1872:tangents.jpg]

Share this post


Link to post
Share on other sites
I feel privileged to be the one that gets to tell you about the "Hairy Ball Theorem". Yes you heard me correctly. Now stop your snickering! :)

The theorem tells us that it's impossible to create an all over continuous field of tangents over the surface of a sphere in an odd dimensional vector space.
So the good news is someone took the time to prove that you're out of luck :)

That being said you could alternatively try a different approach --> [url="http://www.gamedev.net/topic/572450-procedural-bump-mapping-on-the-gpu/"]http://www.gamedev.n...ing-on-the-gpu/[/url]
Implicitly the split in derivatives occurs at the silhouette as seen from the camera. This is where the gpu samples the lowest resolution mip maps anyway.
It's essentially the most ideal location for the mandatory splits.

I'd recommend the 3 tap method (or even more taps should you wish it). As the paper says these are both independent and cache coherent.

As I mention in this thread --> [url="http://www.gamedev.net/topic/599363-bump-mapping/"]http://www.gamedev.n...3-bump-mapping/[/url] you can even do a variant that works in post process
which allows you to do a nice sobel for the derivative calculation.

Your other option is of course to simply use normal mapping anyway but accept that you will have tangent space splits.

Share this post


Link to post
Share on other sites
sorry for the late response..

thanks for clarification, your links seem quite interesting too

btw: i managed to get normal mapping working, i just forgot to shift the normal of the texture to the [-1,1] range - embarrassing that this cost me three days...

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