Calculating TBN vectors in GLSL when using VTF?

Started by
4 comments, last by dpadam450 10 years, 1 month ago

How can one calculate the TBN vectors for a vertex texture fetch displacement of a vertex using GLSL 1.2... Is it even possible? I don't need 100% accurate results but decent enough to look okay.

Thanks!

Advertisement

The TBN is normally calculated from the geometry (normal vector) of an model, including its texture coords (to determine the surface direction). To get good results, you even need to merge the tri/quad dependent TBN at shared vertices. To access all these information in a shader, even a geometry shader, will be really hard. If you have a fix topology, calculate the TBN upfront per vertex and send it to the vertex shader.

Here's an article about TBN and an approximation for normal mapping without pre-caluclated TBNs.

If you don't have tangents/bitangents available, one option is Mikkelsen's Bump Mapping of Unparametrized Surfaces.

You should be calculating the normal map of your model offline. With the normal you can calculate the TBN.

NBA2K, Madden, Maneater, Killing Floor, Sims http://www.pawlowskipinball.com/pinballeternal

You should be calculating the normal map of your model offline. With the normal you can calculate the TBN.

I am using a normal map but the tbn vectors will they not be different after I displace them in the vertex shader...

All I have to use is tex coordinate and the normal before and I assume the normal after it's displaced?

In a standard pipeline. You have a high poly model baked onto a low poly, right. So I assume you have a height map (or vector map) generated from a high poly onto a low poly model?

If so, if its stricly a height map from a high poly model onto a low poly model
Then you are fine, because you have baked the high poly models normals into a texture, and you are displacing the low poly vertices to basically generate the high poly model.

If it is a vector displacement map or a height map, with no actual high poly model. IE you just have a sphere and you can swap textures to generate new models. Then I suggest that on CPU side, you take your single sphere model, displace it by your vectors, and by hand look at the edges from that given vertex and manually compute a normal/tangent. You have to look at the other vertices to generate a normal. You don't want to do that at run time.

NBA2K, Madden, Maneater, Killing Floor, Sims http://www.pawlowskipinball.com/pinballeternal

This topic is closed to new replies.

Advertisement