Jump to content
  • Advertisement
Sign in to follow this  
Alex_hbg

How to calculate normals for deferred rendering + skinned mesh?

This topic is 672 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

I am using this at the moment:

    float4x3 SkinTransform = 0;
    [unroll]
    for (int i = 0; i < 4; i++)
    {
        SkinTransform += BoneTransforms[PointBoneIndices[i]] * PointBoneWeights[i];
    }
    float3 normal = input.Normal;
    normal = mul(normal, (float3x3)SkinTransform);
    normal = normalize(normal);
 
Though that doesn't seem to work when the model's world changes like it is rotated, and the normals don't rotate as well. I switched to this:
 
    normal = mul(normal, (float3x3)InverseTransposeWorld);
    normal = normalize(normal);
 
But it doesn't seem to take into account when the model animates.
 
How should this work? Tbh I don't even remotely understand the math so I can't even hazard a guess as to where I am going wrong.
Edited by AlexLynch

Share this post


Link to post
Share on other sites
Advertisement

You need to apply both transforms:

 

float3 normal = input.Normal;
normal = mul(normal, (float3x3)SkinTransform);
normal = mul(normal, (float3x3)InverseTransposeWorld);
normal = normalize(normal);

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!