Smooth Tangent Space

Hi,
I’ve got a problem with Tangent Space.
I want to have a smooth sphere with bump mapping, and here’s what happens on the top of the sphere:

It happens because tangent and binormal vectors are different on each triangle. I can only smooth normal vector, because I can’t take average of tangent and binormal vectors because they will result in 0-vector, because that happens on the top of the sphere.

I tried to rotate tangent and binormal vectors to be ortho-normal to the normal vector, but it still results in artifacts in specular lighting.

Any ideas?

You should orthogonalize the tangent to normal and calculate bitangent with a cross product.

It looks like that the picture is the sphere pol. The tangent and bitangent are linear interpolated. So it’s not possible to get a smooth curved tangent. To visualate that problem you should display th tangent with “gl_FragColor.xyz = Tangent * 0.5 +0.5;”

Only a mesh with a higher resolution or per pixel tangent could help.

Originally posted by oc2k1:
[b] You should orthogonalize the tangent to normal and calculate bitangent with a cross product.

It looks like that the picture is the sphere pol. The tangent and bitangent are linear interpolated. So it’s not possible to get a smooth curved tangent. To visualate that problem you should display th tangent with “gl_FragColor.xyz = Tangent * 0.5 +0.5;”

Only a mesh with a higher resolution or per pixel tangent could help. [/b]
You actually don’t want to calculate a bitangent that way. If you do so, you’re assuming that texels are always square, which is definitely not the case, especially here. That said, any normal map on the top of the sphere would be distorted. If it’s possible to special case this situation (IE: you’re not generating tangents/bitangents from polygon soup), then you can try to generate tangents so that you can control where lines show up.

Really, there is just no (practical) solution that will deal with this case perfectly. However, one good way is to only smooth with tangents that are “similar” in facing. For instance, if the dot product between two face tangents is within some acceptable threshold.

Anyways, using an orthogonal tangent space will get you incorrect results for almost all curved geometry. It’s a common recommendation that I’ve seen, but it’s definitely not what should be done.

Kevin B.

Thank’s for answers :slight_smile:
I’ve found a solution in per-pixel matrix multiplication. Now I don’t use per-vertex Eye2Tangent Space matrix, but I use Tangent2Eye per-pixel matrix. And it works without artifacts :slight_smile:

Can you tell more about that solution ?