# Clamping ray to projection space

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

## 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;  }

• 47
• 12
• 10
• 10
• 9
• ### Forum Statistics

• Total Topics
631374
• Total Posts
2999647
×