I am making a game in which the player can “take a picture”, and all the objects that are visible to the player will be affected in some way. This has proven to be a harder task than I first realized (I currently have 20 tabs open after having done several hours of research on the matter, with implementations in C# and ShaderLab alike). I also haven’t found any example games or projects that could help in this endeavor, despite my best efforts.
For clarity, I’m not looking for
IsVisible() or any function that works regardless of obstruction (e.g. a wall or another object that is super close to the camera won’t stop
isVisible() from returning true on an object). I’d also prefer not to purchase from the Unity Asset Store, though I’m not afraid to cut my losses if this becomes too difficult on my own.
As an example, imagine 3 cubes within the camera’s frustum planes, colored red, green, and blue; their transform positions aren’t aligned on any axis. The red cube is visible to the player, the green cube is partially obstructed by the red cube, but the blue cube is hidden because of where red and green are positioned. All three objects are considered visible to the renderer, but to the player this wouldn’t be the case. Is there a script, shader, or some combination therein that can detect that the red cube is visible, the green cube is visible, but the blue cube is not visible?