Portion of quad visible to camera,

I intend to use a quad as a tv screen inside a 3d world.



How can I know the portion of the tv screen visible to the camera when an obstacle like wall is covering part of the tv screen. I want to get the four coordinates of the portion of the tv screen visible to the camera.


I want to get the four coordinates of
the portion of the tv screen visible
to the camera.

Well this statement tells me you haven’t really thought deeply about the problem. Though we don’t know for which purpose you need those coordinates, but a quad viewed and obstructed by walls and other stuff can by clipped as various angles which would result in more than 4 vertices. Also if the view is tilted the quad is no longer a rectangle but becomes a polygon which may not have any symetries anymore.

Such visible area calculations are quite difficult and depending on the purpose have vastly different approaches and non is an easy solution.

If you’re really just interested in 4 corners (assuming the screen is always only clipped with perfect aligned occluders) the naive approach would be to raycast against the 4 corners and if obstructed you iteratively “home in” to the border up to your desired precision. A similar approach is possible by being more analytical about the occluder you’ve hit and trying to find a point on the boundary of that occluder. Though in complex scenes this can get really complex and expensive and if not done right may result in all sorts of potential bugs.

For things like that it always helps to know the actual purpose as there is no straight forward answer. Depending on the usecase there may be much simpler solutions for what you want to do.