Sign in to follow this  
Prune

Updating TNB so N is oriented with different than gl_Normal?

Recommended Posts

Prune    224
Hi, I need a bit of help with a geometric calculation. I'm using shells to render fur, and since I allow wavy hairs, the normals for each shell are stored in normal maps generated from the fur generation process (norm(dx, dy, OFFSET) where dx, dy are offsets from lower shell for the hair particle and OFFSET the shell spacing). To handle the dynamics, the shell vertices are offset as follows in the vertex shader: hairNormal = normalize(hairNormal + (externalForce * gl_NormalMatrix) * pow(10.0 * offset, 1.5)); // externalForce is taken to object space by gl_NormalMatrix^T; normalization to preserve hair length gl_Vertex.xyz += offset * hairNormal; gl_Position = ftransform(); where hairNormal is initially either gl_Normal or normal read from a combing-direction vertex texture map transformed by a TNB (but tangent-to-object, not -world, space). Note that this hairNormal is referring to the overall per-vertex direction of hair, not the normal of individual hairs. Now, my question is: in the pixel shader, how do I transform the individual hair normals read from the normal map to reflect the additional shift? Do I need to rotate the TNB used for the tangent-to-world space transform somehow so the N there corresponds to the hairNormal from the vertex shader, not gl_Normal? If so, can I simply recompute the TNB by using hairNormal and the unmodified tangent vector, or do I need to modify the tangent? The other possible idea I had is to have dxdy offset maps instead of normal maps and add the offset from the vertex shift, then calculate the normal. Since the normalization in the vertex shader seen above changes the spacing between shells, I use offset * hairNormal.z for the 3rd offset... Or is it actually valid to simply add hairNormal to the value from the normal map and normalize? Thanks in advance.

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