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!

Started by MARS_999, Mar 06 2014 02:08 AM

5 replies to this topic

Sponsor:

Posted 06 March 2014 - 02:34 AM

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.

Posted 06 March 2014 - 02:54 AM

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

Posted 06 March 2014 - 05:26 PM

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?

Posted 06 March 2014 - 06:24 PM

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.

**Edited by dpadam450, 06 March 2014 - 06:25 PM.**