We have a flight simulator application where one of the primary views comes from the EO/IR ("skyball) camera connected to the bottom of the "ownship" aircraft. You can gimbal and zoom the camera. The problem is since this camera can zoom (reduce FOV) quite far we see Z-fighting. To address the Z-fighting I move the near plane out a few hundred meters and problem is fixed. However that introduces a new problem. Now you can't see the "ownship" because it is being clipped out by the near plane that is not very near the (air)plane, if you catch my drift! So to address that we create silly masks which are nothing more then quads that positioned from the camera's view point. We have to set their positions to cover up the aircraft mesh and then during the game loop we check if the camera's azimuth or elevation (pitch) angles are inside a mask quad, we say that the camera is "masked" by the ownship and therefore pull the near plane back to its normal position of about 0.1 meters.
This hack works pretty good until you are in a masked condition (you can see a wing in the view for example) but you are looking far off into the distance. You get the Z-fighting again because since we are maksed we have to pull the near plane back so we can see the wing or any other part of the aircraft. You can define as many mask (quads) that conform to the aircraft shape as seen from this camera but you can never get it a perfect fit.
But I want to see if we can do this better, without masks. I am using OpengGL 3.3+ and GLSL 330 and want to know if there is a better way to check if an object (the ownship 3d model) is in view, are any of its pixel fragments in the view port at any given time? I am not a GLSL expert so that's why I am coming to the experts.
There is another approach I thought about which eliminates the need for masking altogether but it may not work so well with our shadows. I'll just throw this one out but I want to focus on the current approach first. This approach renders two channels where one channel defines near and far planes close to the aircraft ownship, near == 0.1m and far==500m. The second channel defines the near as 500m and the far as 130000m (flight sim so we need a far far plane distance at a high altitutde). So the 2nd channel draws the further scene where the 1st channel leaves off. I tried this way and it did seem to work however our dynamic shadows have to be attached to only one channel. This requires drawing the scene twice and our scene can get pretty heavy so its not my first choice. That's why we went for the more hacky way first. I may need to work with this approach more, however.
In the mean time I want to pursue improving our current solution. Any ideas would be helpful.
Wow, its been many years since I've been on this site. Lots of changes that look great!