- Home /
Answer by CHPedersen · Jul 10, 2013 at 01:44 PM
Since the normal is in object coordinates when received from the vertices in the mesh, you need to transform it to world space. This is done by multiplying it with the object's model matrix. This matrix is called "_Object2World" in shaders, e.g.:
worldNormal = mul(_Object2World, objectNormal);
Thanks you ! FOr the moment I do: o.WorldNormal = normalize( mul(float4(v.normal, 0.0), _Object2World).xyz);
Oh, right, I forgot that _Object2World is a 4x4 matrix, so you gotta pad your vectors with a fourth coordinate w = 0, exactly like you're doing. Great!
Your answer
![](https://koobas.hobune.stream/wayback/20220613105831im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Fog shader 2 Answers
Why doesn't this vertex+fragment shader work? 0 Answers
Access to svPosition in fragment shader 1 Answer
Can a CG shader fail to work on hardware? 1 Answer
Grabpass refraction masking 0 Answers