0

So I am writing a shader and I was setting up the light direction and normal direction to make a lambert shader.

VOUT.normalDirection = normalize( mul(float4(i.normal,0.0),_World2Object).xyz);

float3 lightDirection = normalize(_WorldSpaceLightPos0.xyz);

And the I wonderd, why do I need the normals in object space and the light in world space?

How do I know when I need to put somthing in world space or in object space?

Thanks in advance!

anonymous-dev
  • 2,897
  • 9
  • 48
  • 112

1 Answers1

0

This is a sneaky one but it may well be correct, because the proper way to transform normals is to multiply them by the transpose of the inverse of the matrix that you would use for transforming points.

bjorke
  • 3,295
  • 1
  • 16
  • 20