Sign in to follow this  
Waaayoff

Passing Tangents and Binormals to shader (for normal mapping)?

Recommended Posts

Waaayoff    952
I was wondering, are these passed the same way as normals? For every vertex i need to have for example: { position, textureUV, normal, binormal, tangent }?

Also should i only pass two of these and calculate the third in the vertex shader?

Share this post


Link to post
Share on other sites
Yes that's correct. Personally I calculate the bitangent (it's 'Bitangent' when working with 3D surfaces - a surface has a normal and two orthogonal tangents. 'Binormal' is when you're working with 3D lines such as splines, which have a tangent and two orthogonal normals) in the shader rather than passing an extra vertex attribute, but I imagine only profiling would establish if this is actually faster. You'd be trading off the cost of the extra data to upload to the GPU against the cost of perfoming the calculation in the shader.

Unless you're striving for every tiny bit of performance I'd just do whichever method would make for the tidiest code.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this