# normal mapping on "exposed cube" planets

This topic is 2637 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## 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 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 --> http://www.gamedev.n...ing-on-the-gpu/
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 --> http://www.gamedev.n...3-bump-mapping/ 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 on other sites
sorry for the late response..

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...

1. 1
2. 2
Rutin
19
3. 3
JoeJ
16
4. 4
5. 5

• 35
• 23
• 13
• 13
• 17
• ### Forum Statistics

• Total Topics
631701
• Total Posts
3001810
×