I am looking for an efficient and reasonable method.
I have thought of 2 different methods sofar, but I’m not sure what I should do.
Can I attach the same DepthTexture to 2 different FBO’s? If I can, then I can render the SkyDome after I’ve rendered everything with lighting.
I’ve also thought about using stencil textures. It seems that with FBO’s you need to create a Stencil + Depth Texture; Then I need to share that Stencil + Depth Texture between the two FBO.
I think the modern approach is to model the atmosphere (aerial perspective, etc) and clouds with some light scattering techniques, if you’re going for realism. There’s boat loads of literature on the optics of it all, but the implementation probably depends a lot on the look you’re after, your hardware, and how much perf you’re willing to throw at it.
Yes you can attach your depth-texture to two different FBOs. Stencil also works, but that’s not necessary and doesn’t have any benefits. Simply render your scene, light it and then render the sky. You can use glDepthRange (0.999999, 1.0) to render only to those pixels, that have not been rendered to before (only those pixels in the depth-buffer that have still the value 1.0).