Calculating TBN vectors in GLSL when using VTF?

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

Recommended Posts

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!

Share on other sites

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.

Share on other sites

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

Share on other sites

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?

Share on other sites

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.

• Game Developer Survey

We are looking for qualified game developers to participate in a 10-minute online survey. Qualified participants will be offered a \$15 incentive for your time and insights. Click here to start!

• 18
• 12
• 9
• 9
• 25