Tell me more ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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

Thanks a lot !

share|improve this question
up vote 2 down vote accepted

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.

share|improve this answer
Like this ? o.WorldNormal = normalize( mul(float4(v.normal, 0.0), _Object2World).xyz); – MaT Jul 10 at 13:37
Yes, that looks correct. – Tordin Jul 10 at 13:50
Thank you a lot ! – MaT Jul 10 at 13:51

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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