I am generating a camera frustum mesh through code and it is working fine.
Now I am searching for a solution (shader based or else) to restrict the camera frustum mesh if it intersects with any object. As you can see in the image, my frustum is passing through the plane which is not correct.
How can I control it? I searched and tried to apply different kinds of shaders but nothing seems to work.
Get the frustum planes of the camera.
For each GameObject in the scene, get its
Renderer
component'sbounds
if any.Test if the renderers bounds intersect with any of the frustum planes.
This should be a pretty good approximation of whether your camera can "see" the mesh (i.e if the frustum intersects with any object)