Jump to content
  • Advertisement
Sign in to follow this  

Clamping ray to projection space

This topic is 3035 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'm trying to trace a ray through a light frustum, and at this point I'm trying to clamp the cam to pixel ray to the projection space of the light. I can enhance this to the actual frustum soon. This is what I've got in case the camera is behind the light. I'm wondering if this is correct and if I can then modify this to clamp on all the planes. Also, would it be beneficial to do this on the CPU? I didn't want to do it because I'm already finding the pixel position in light projection space on the gpu already. I am however getting the camera in light space on the cpu.

if (camPosInLPS.z < 0)
float3 camToPixelLPS = (iPixelLPS - camPosInLPS);
camPosInLPS += camToPixelLPS * abs(camPosInLPS.z) / camToPixelLPS.z;

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!