Sign in to follow this  
Quat

Deferred Rendering Sun

Recommended Posts

I am using cones and spheres to render spotlights and point lights to my light buffer. For the sun (directional light), I am rendering a fullscreen quad. The problem is with my fullscreen quad: I will execute my directional lighting pixel shaders over the skybox area, which is wasteful.

My thought was that when I laydown my gbuffer, I set the stencil buffer to 1 to mark the areas I have drawn to. Then when I render my light meshes, I only render to areas where the stencil buffer is marked 1. Is this the common solution?

Share this post


Link to post
Share on other sites
Yeah, it's simple and effective since early stencil cull will kill most of the skybox pixels before they ever get shaded. You could also use dynamic branching to early out in your pixel shader, but in general that won't perform as well as stenciling.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this