Sign in to follow this  

[solved] world to screen/uv-space conversion problems

This topic is 2820 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

i want to implement a lightshaft shader (details: gpu-gems3-lightshafts) but have problems in transforming my light-worldposition to screenspace uv-coordinates. basically i do the following: vertex shader:
vOut.posLight =  mul(float4(gLight.pos, 1.0f), gWVP);

where gLight.pos is my light position in world-space and gWVP is my world * view * proj matrix then i convert this position in my pixel-shader to uv-coordinates in screenspace:
float2 posL = float2(pIn.posLight.x / pIn.posLight.w,pIn.posLight.y / pIn.posLight.w);
	
posL.x = posL.x * 0.5f + 0.5f;
posL.y = -posL.y * 0.5f + 0.5f;


after this, i thought posL should have the uv-coordinates of my light in screenspace (for example (0.5f, 0.5f) when in middle of screen) but unfortunately this doesnt work - and i dont know why - anybody knows whats wrong with my calculations? thanks in advance! [Edited by - mancubit on March 28, 2010 7:26:18 PM]

Share this post


Link to post
Share on other sites

This topic is 2820 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