Using M=Mview*Mprojection , I transform the scene into post-projective space.
The problem I have is with light vector (parallel light) : it's always along camera direction in post-projective space.
My camera is perfectly horizontal, the 'post projective' light direction I have has always a zero y-component, the light vector in world space is (0.57,-0.57,0.57).
Here's how I transform the light vector :
VP=viewMatrix*projectionMatrix;
D3DXVec4Transform(&tmpV4,&D3DXVECTOR4(LIGHT_DIR,0),&VP);
D3DXVec3Normalize(&lightVector,&D3DXVECTOR3(tmpV4));
Also why do you need light's direction in screen space. To create shadow map you should have another view projection matrix for your light and render depth with it's pov.
This is not standard shadow mapping, this is perspective shadow mapping (PSM) in which the scene is first transformed into screen space, then into light space
Hmm i see there are a lot of things i should learn . I searched for psm now and i found this. I'm working right now so i couldn't read all of it but maybe it can help you because it mentions some problems with psm. Also sorry for not helping much but i'm newbie too and if something comes to my mind i tell you.
So you are saying that you have a light vector defined in screen space and that it is a constant. But why in your code you move this constant from world space to projection space?
When actualy you want to move it from projection space into view or world space right? You use
projectionvector*(ProjInverseMatrix*ViewInverseMatrix)., will move a projection vector to world space.
No, LIGHT_DIR is in world space, lightVector in screen space
My problem can't be there (I hope I'm able to transform a vector correctly^^)
I think this is a problem in light view/projection matrices
Working in post-projective space seems to be so difficult (for example objects behind the camera are inverted etc...) that I'm getting information about TSM (trapezoidal shadow map) : the results are better, and it seems to be easier to implement