   Shadow Map-How to calculate Position in Light Sapce?
  I have read Shadow Map's source code in DX9 example.I find that in vertex shader, they calculate that vertex position(in light space) like this:vPosLight = mul( vPos, g_mViewToLightProj );vPos : vertex position in camera spaceg_mViewToLightProj : inverse(matView_Camera)*matView_Light*matProj_LightBut i use a simple directly way to calculate vertex position in light space:vPosLight = mul(iPos, g_matWorldViewProj_Light);iPos : vertex position in object space(local space)g_matWorldViewProj_Light : matWorld * matView_Light * matProj_LightI want to ask that the way i use is correct? If my way is correct, why DX9 example use that matrix(a little complex).Thanks all!   
Quote:Original post by Game_XinBingI have read Shadow Map's source code in DX9 example.I find that in vertex shader, they calculate that vertex position(in light space) like this:vPosLight = mul( vPos, g_mViewToLightProj );vPos : vertex position in camera spaceg_mViewToLightProj : inverse(matView_Camera)*matView_Light*matProj_LightOkay, so they take the camera space position and transform it into light space using a matrix that represents this transformation (camera->world->light camera->light clip).Quote:But i use a simple directly way to calculate vertex position in light space:vPosLight = mul(iPos, g_matWorldViewProj_Light);iPos : vertex position in object space(local space)g_matWorldViewProj_Light : matWorld * matView_Light * matProj_LightYou take the object space position and transform it into light space using a matrix that represents this transformation (object->world->light camera->light clip).Quote:I want to ask that the way i use is correct?Yes, both ways look correct to me.Quote:If my way is correct, why DX9 example use that matrix(a little complex).Both methods will perform the same since they perform the same matrix multiplication, provided you already have the inputs to the multiplication. In their example, they require the camera space vertex position, which you are almost always going to calculate anyway. In your method you need the worldspace position, and there are cases where one wouldn't bother to calculate this (for example if you're going to do camera space lighting, you'd multiply your input vertex by a matrix to transform directly to camera space).   ;  Thank your help.But i can't give you return :)   