Search Unity

Converting Normals From Objectspace to Worldspace in C#

Discussion in 'Editor & General Support' started by LoveToLoose, Mar 28, 2019.

  1. LoveToLoose

    LoveToLoose

    Joined:
    Mar 25, 2019
    Posts:
    8
    Hey, I'm looking for a way to convert the normals of a mesh from object space to world space.

    Transform.TransformVector() does not work in this case because the game objects are scaled. (Normals should have a 90 gegree angle to surfaces. When scaling an object a lot of the angles between vertecies can change, so if you just scale normals like everything else you often times don't end up with 90 degrees.)

    There seem to be easy solutions for shaders: https://forum.unity.com/threads/world-space-normal.58810/

    How would one do that in C#?

    Thanks for having a look. :)