Jump to content
  • Advertisement
Sign in to follow this  

Updating TNB so N is oriented with different than gl_Normal?

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!