8
\$\begingroup\$

I've been implementing John Chapman's method for SSAO (an excellent tutorial by the way), and I've completed it all minus the final part: blurring it. I believe this is what the entire process should be like:

  • First pass: render normals and depth to textures. (plus diffuse/specular albedo and such)
  • Second pass: render scene without ambient occlusion to texture, render ambient occlusion to another texture.
  • Third pass: blur the AO texture, multiply with scene texture for end result.

Then, if I wanted to implement bloom and depth of field, would I need yet another pass (or two)? Do modern games really go through a ton of rendering passes to add effects, or is there something obvious I'm missing? Some way to drop the number of passes needed?

\$\endgroup\$

2 Answers 2

3
\$\begingroup\$

I'd say 2-3 passes is pretty normal. I suspect 4 is not uncommon.

For vertex-lit games, 1-2. Usually just the albedo pass then some post effect or another.

For pixel lit, 3+ is going to be the norm. 1st pass is g-buffer, z-buffer, surface normals and diffuse/albedo info as you describe it. Building blocks. 2nd pass we try to fit all other ops, but in certain instances -- like depth-of-field blur -- it may simply be impossible to eliminate the need for an additional pass just for that effect, since in nature one could consider DoF blur to be an effect created by the eyes' shallow depth of field, which can only occur after all light has fallen (which describes all passes after the first and before the DoF blur)... clearly, a camera with long focal depth could view the same scene without blurring. So the effect, as such, is a post-process on the actuality of the fully rendered scene. This would also apply for effects like distortion through glass.

Although there's certainly overhead to additional passes, I think what's more important is that you limit costly operations (particulary conditionals) in each shader pass.

\$\endgroup\$
3
\$\begingroup\$

Usually each post processing effect has it own pass unless the effects are "organically" coupled and/or are simple. For example, to simulate an old film camera, you could put the grayscale, sepia, noise, scratch and vignetting effects all inside the same shader, since each effect is a simple part of the goal effect. On the other hand, some other effects have a post or pre blur pass, because of the more complex computations that blurring requires.

It is important to note that the more complex the shader less flexible it is. So in a code maintainability perspective, assembling a shader as a weird set of effects is bad. In addition, the parallelism of a shader can be damaged if it uses a lot of registers (the case of huge shaders). This can lead to bad performance in some cases. If mixing the effects also leads to more divergence in conditional branches the performance penalty can be even worse.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .