Wednesday, February 22, 2012
Playing with Deferred Rendering in XNA
I've been meaning to do a deferred rendering of my graphics pipeline for a while, but hadn't gotten around to it until recently.
In standard forward rendering, your geometry shaders directly output the image that the user sees. In deferred rendering, they output an intermediate buffer (called a "G-Buffer") that contains more information for each pixel - generally color, normal and depth. The advantage to this is that it allows you to do various processing (most notably lighting) on the scene as a whole after all of the geometry has been rendered.
The simplifies the shaders significantly. In Block Zombies, for example, I have three main geometry shaders - one for the terrain, one for models and one for particles. In forward rendering, each shader needs to independently handle lighting, fog and shadowing. With deferred rendering, they don't need to do any of this - it gets done once on the entire scene.
Another huge benefit is the ability to have more lights in the scene. Block Zombies only has a single, directional light source. I would have loved to have more lighting - muzzle flashes, glow from flares, flashes from explosions - but it just wasn't practical in the forward rendering model. With deferred rendering, I can have pretty much as may lights as I want.
In the screenshot above, I have a very subtle directional light, a spotlight from a flashlight and point lights for all of the windows in all of the houses.
Overall, moving to deferred rendering is a big win for me and I think I'll use it as my primary rendering model going forward.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment