Sign in to follow this  
Adaline

Perspective shadow map question

Recommended Posts

Adaline    710
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 :
[code]
VP=viewMatrix*projectionMatrix;
D3DXVec4Transform(&tmpV4,&D3DXVECTOR4(LIGHT_DIR,0),&VP);
D3DXVec3Normalize(&lightVector,&D3DXVECTOR3(tmpV4));
[/code]

..... and then lightVector.y=0 !

I must miss something .....

Share this post


Link to post
Share on other sites
Adaline    710
Thanks :)

I tried :
[code]
D3DXVec4Transform(&tmpV4,&D3DXVECTOR4(LIGHT_DIR,1),&VP);
D3DXVec3Normalize(&lightVector,&(D3DXVECTOR3(tmpV4)/tmpV4.w));
[/code]

.... I get another point of view, but it's still along camera direction, not along light direction :blink:

Share this post


Link to post
Share on other sites
ekba89    788
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.

Share this post


Link to post
Share on other sites
Adaline    710
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

Share this post


Link to post
Share on other sites
ekba89    788
Hmm i see there are a lot of things i should learn :D. I searched for psm now and i found [url="http://http.developer.nvidia.com/GPUGems/gpugems_ch14.html"]this[/url]. 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 :D and if something comes to my mind i tell you.

Share this post


Link to post
Share on other sites
JohnnyCode    1046
[quote name='Adaline' timestamp='1310975297' post='4836696']

VP=viewMatrix*projectionMatrix;
D3DXVec4Transform(&tmpV4,&D3DXVECTOR4(LIGHT_DIR,0),&VP);
D3DXVec3Normalize(&lightVector,&D3DXVECTOR3(tmpV4));

[/quote]

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.

Share this post


Link to post
Share on other sites
Adaline    710
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

thx

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this