View Full Version : Smooth Tangent Space

Bobo.Bobo

04-15-2007, 05:01 AM

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:

http://tweety3d.no-ip.org/rozne/scr000055.jpg

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.

http://tweety3d.no-ip.org/rozne/scr000056.jpg

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?

oc2k1

04-15-2007, 06:09 AM

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.

ebray99

04-15-2007, 08:38 AM

Originally posted by oc2k1:

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

Bobo.Bobo

04-15-2007, 09:54 AM

Thank's for answers :)

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 :)

Nikolai Timofeev

04-15-2007, 10:01 PM

Can you tell more about that solution ?

Powered by vBulletin® Version 4.2.3 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.