Jump to content
  • Advertisement
Sign in to follow this  
mancubit

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

This topic is 3034 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
Advertisement
..oh man - i shouldnt multiply with the world-matrix if the light position is already in world-space - stupid little mistake that cost me about 6 hours

now it works perfectly

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!