Tangents/Bitangents for spherical cube
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!
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.
Quote:Original post by Eric LengyelUnderstood, 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.
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.
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.
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]
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]
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.
Quote:Original post by LorenzoGattiAh, that makes sense - unfortunately :)
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.
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement