Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm implementing deferred shading the first time. Doing so I came up with a conceptual question.

First I render the geometry in a framebuffer with muptiple rendering targets for depth, normals, and so on. Say that I want to apply several post effects, I think I have two options now. I could either render a quad with the depth, normals, ... texture to the screen buffer once applying all effects in that pass. Or I could perform one render pass to another framebuffer for each effect and lastly combine those effect in a pass to the screen buffer.

Would both ideas work and if so what is the common approach?

share|improve this question
What do you mean by "post effects"? Are you talking about lighting (which is generally what you do to g-buffers in deferred rendering)? Or are you talking about post-processing effects, like bloom, depth-of-field, or whatever? – Nicol Bolas Jan 23 '13 at 12:04
@NicolBolas. By post effect I mean everything you listed. Lighting and depth of field, and more. I think all of them are done the same way but using different shaders. – danijar Jan 23 '13 at 12:14
What do you expect to gain from performing several passes, if one will suffice? – Jari Komppa Jan 23 '13 at 13:21
@JariKomppa. At least the shader file wouldn't become unreadable big, but that wouldn't be a reason. There must be a purpose, I mean many games use it. – danijar Jan 23 '13 at 13:30
Never do something just because someone else is doing it. =) – Jari Komppa Jan 23 '13 at 13:33
up vote 1 down vote accepted

You need at least two passes for deferred shading, the first to fill the G-Buffer and the second for the lights. After that you need at least another pass for effects, you would probably render the light result to another framebuffer and then render the effects on this framebuffer. You can use this third pass for all the effects, if you write a single shader to apply those effects (though you lose some flexibility, and some effects may require all the previous effects to be fully applied before they can be used.) I suppose you can do it on the second pass, along with the lights, but I'm not sure how the blending of the effects would work.

I believe you need at least 3 passes for the effects, but I would leave the option for more passes for different effects, maybe you can group your effects into shaders that make sense together, that would save you a few passes but still be flexible and readable.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.