0
\$\begingroup\$

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

Thanks a lot !

\$\endgroup\$

1 Answer 1

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\$
2
  • \$\begingroup\$ Like this ? o.WorldNormal = normalize( mul(float4(v.normal, 0.0), _Object2World).xyz); \$\endgroup\$
    – MaT
    Jul 10, 2013 at 13:37
  • \$\begingroup\$ Yes, that looks correct. \$\endgroup\$
    – Tordin
    Jul 10, 2013 at 13:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .