0
\$\begingroup\$

How to access/calculate worldNormal in a Vertex and Fragment shader ?

Thanks a lot !

\$\endgroup\$
2
\$\begingroup\$

Multiply the normal with the worldmatrix, not the world_view_projection.

do this in the vertex shader, and then pass the value down as a linear interpolation value. then you dont need to do it in the pixelshader.

\$\endgroup\$
  • \$\begingroup\$ Like this ? o.WorldNormal = normalize( mul(float4(v.normal, 0.0), _Object2World).xyz); \$\endgroup\$ – MaT Jul 10 '13 at 13:37
  • \$\begingroup\$ Yes, that looks correct. \$\endgroup\$ – Tordin Jul 10 '13 at 13:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.