Sign in to follow this  

Perspective shadow map question

This topic is 2338 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
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
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
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
[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
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

This topic is 2338 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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