3
\$\begingroup\$

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?

\$\endgroup\$
7
  • \$\begingroup\$ 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? \$\endgroup\$ Jan 23 '13 at 12:04
  • \$\begingroup\$ @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. \$\endgroup\$
    – danijar
    Jan 23 '13 at 12:14
  • 2
    \$\begingroup\$ What do you expect to gain from performing several passes, if one will suffice? \$\endgroup\$ Jan 23 '13 at 13:21
  • \$\begingroup\$ @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. \$\endgroup\$
    – danijar
    Jan 23 '13 at 13:30
  • 1
    \$\begingroup\$ Never do something just because someone else is doing it. =) \$\endgroup\$ Jan 23 '13 at 13:33
2
\$\begingroup\$

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.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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