Sign in to follow this  

Tangents/Bitangents for spherical cube

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am playing around with planet rendering (again), and have hit a weird bug to do with normal mapping. My normals are continuous across the sphere: But my tangents are not: And nor are my bitangents: Which leads to a normal-mapped result like this: The sphere is really an exploded cube, which explains why only a certain face has trouble, but I can't for the life of me find the error. I have made sure that the tangents and bitangents lie along the texture U,V coordinates (which are tested to be correct), and have tried all combinations of rotating/flipping the tangents and bitangents on the affected faces. If anyone has any ideas, they would be most welcome!

Share this post


Link to post
Share on other sites
It is a known topological fact that you can't have a non-vanishing continuous tangent field on a sphere. There's going to be a problem somewhere, so you have to decide how to divide the surface up into different regions where the tangent field is locally continuous, but you will always have seams between the regions.

Share this post


Link to post
Share on other sites
Quote:
Original post by Eric Lengyel
It is a known topological fact that you can't have a non-vanishing continuous tangent field on a sphere. There's going to be a problem somewhere, so you have to decide how to divide the surface up into different regions where the tangent field is locally continuous, but you will always have seams between the regions.
Understood, and seams I can deal with. However, it looks like I have entire faces that have flipped tangents/bitangents, and I think this should be correctable.

The texture coordinates of the sphere match the OpenGL cubemap layout, and they seem to be correct. The tangents/bitangents definitely match the s/t texture coordinates, so each face should be correctly lit, even if there are seams.

Share this post


Link to post
Share on other sites
All right, the problems seem to run deeper than I realised. A quick question:

If my tangent space basis is correct, should the light direction - once it has been transformed into tangent space - be continuous?

My intuition says yes, but this series of images says no (light vector transformed into tangent space, as rgb: front-left, front-right, rear-right, rear-left):




Now, obviously we can't have continuous tangents/bitangents over a sphere, as Eric pointed out. But if we ignore for a moment that this looks spherical, it is in fact a cube (which has been expanded). And it is certainly possible to normal map a cube - I have it mostly working here, except for the problem in the tangent space transform.

Do you think this is just a case that my s,t texture coordinates are screwy, or is there something deeper wrong here?

[Edited by - swiftcoder on May 25, 2008 2:09:42 PM]

Share this post


Link to post
Share on other sites
Quote:
Original post by swiftcoder

Now, obviously we can't have continuous tangents/bitangents over a sphere, as Eric pointed out. But if we ignore for a moment that this looks spherical, it is in fact a cube (which has been expanded). And it is certainly possible to normal map a cube - I have it mostly working here, except for the problem in the tangent space transform.

No, it isn't possible to normal map a cube, not in the way that you need here.
The curvature of an actual cube is "swept under the carpet" at its edges and vertices, individual faces pose no problem and discontinuous tangents between adjacent faces are actually desired; but here the fact that your sphere model is based on a cube doesn't help, you still need continuous tangents and you cannot take advantage of cube edges.

Maybe you don't need a whole smooth sphere: if only an hemisphere is visible, you can put the seam at its invisible circumference and deform the tangents, frame by frame, to match camera position.

Share this post


Link to post
Share on other sites
Quote:
Original post by LorenzoGatti
No, it isn't possible to normal map a cube, not in the way that you need here. The curvature of an actual cube is "swept under the carpet" at its edges and vertices, individual faces pose no problem and discontinuous tangents between adjacent faces are actually desired; but here the fact that your sphere model is based on a cube doesn't help, you still need continuous tangents and you cannot take advantage of cube edges.
Ah, that makes sense - unfortunately :)

So it looks like my best choice is going to be model-space normal maps. Generating those is going to be a little expensive compared to the image-based approach I was using, but if it has to be, it has to be.

Share this post


Link to post
Share on other sites

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

If you intended to correct an error in the post then please contact us.

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