Deferred Shading...How to Render Sky w/o Lighting

How do I render my skydome w/out Lighting?

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 really need to figure this out.

Thanks for any help in advance…


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.

Them’s my 2 pintos.

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).

Hope that helps,

Someone once suggested me to set the zdepth in the shader (per vertex or fragment?), but I never got this to work. What’s the right way to do this?

In your lighting shader, just skip lighting on pixels where depth=1.0.