- Home /
Shader Raycasting From Camera
Hi, I need to raycast from a secondary camera taking into account its properties (focal length, aspect ratio,etc) and then get the pixel hit in a shader for the main camera so that you can visualize what the secondary camera is exactly seeing. I hope the attached image is enough to explain the desired effect. Thanks in advance!
Answer by lgarczyn · Jan 10, 2020 at 08:21 PM
Why not just add a hard dynamic spotlight placed at the same position and rotation as the camera?
You can generate a cookie that is the correct aspect ratio, then calculate the angle to match the fov.
You can then disable it when rendering on the projected camera https://answers.unity.com/questions/581569/dissable-lights-per-camera.html
I had already tried it several times and there was a lot of light bugs but I changed the camera rendering path to deferred and now I think things are starting to work. $$anonymous$$aybe this will be enough with some adjustments. Thanks
Once you're done, please post your code if you can. It's a very interesting problem.
Your answer

Follow this Question
Related Questions
Get 2D Collider with 3D Ray 2 Answers
Start raycast from object 1 Answer
How to get Camera Collision Detection on Terrain 1 Answer
hello's i needs help on camera movement 1 Answer
How to prevent camera from clipping through walls with raycasts? 0 Answers