Jump to content

  • Log In with Google      Sign In   
  • Create Account


Calculating TBN vectors in GLSL when using VTF?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 MARS_999   Members   -  Reputation: 1266

Like
0Likes
Like

Posted 06 March 2014 - 02:08 AM

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!



Sponsor:

#2 Ashaman73   Crossbones+   -  Reputation: 7122

Like
2Likes
Like

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.



#3 Hodgman   Moderators   -  Reputation: 29473

Like
3Likes
Like

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.



#4 dpadam450   Members   -  Reputation: 886

Like
0Likes
Like

Posted 06 March 2014 - 03:27 PM

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



#5 MARS_999   Members   -  Reputation: 1266

Like
0Likes
Like

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?



#6 dpadam450   Members   -  Reputation: 886

Like
0Likes
Like

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.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS