Increasing performance

Started by
2 comments, last by JohnnyCode 10 years, 6 months ago

Hi guys. wink.png

What I do when drawing full screen effects, is normally to sample a full screen quad, but at the native resolution. After a while I realized that it was becoming quite slow, with multiple full screen effects.

How do other people accomplish a steady performance when doing these full screen effects, multiple of them?

Could you decrease the resolution when performing these effects, so as an example, scaling down the screen when applying the bloom effect, or when blurring something?

Thanks, as usual. smile.png

-MIGI0027

FastCall22: "I want to make the distinction that my laptop is a whore-box that connects to different network"

Blog about... stuff (GDNet, WordPress): www.gamedev.net/blog/1882-the-cuboid-zone/, cuboidzone.wordpress.com/

Advertisement

Could you decrease the resolution when performing these effects, so as an example, scaling down the screen when applying the bloom effect, or when blurring something?

Yes, that is quite standard. When reducing resolution, you end up with a blurry image, so it goes hand in hand with blurring. The result is a blurrier image, faster happy.png

Often for bloom, you'll copy your scene to a half-resolution or quarter-resolution target, perform the blurring passes at that res, then apply the results back over the original full-resolution target.

Other effects such as DOF and SSAO can also be done at half resolution. However, often with these effects have some sharp edges (an unoccluded object overlapping an occluded one, or an in-focus object overlapping an out-of-focus one) that are required to remain sharp, and not be blurred accidentally due to the low resolution.

To fix this, when you apply the low-resolution results to the high-resolution scene, you have to use a bilateral upsampling filter. This means that instead of using the built-in bilinear texture filtering, you manually fetch the 4 closest low-resolution texels, and perform some computation to see if they are "valid" or not. For example, you might compare the depth value of each of the 4 low-resolutions texels to the depth value of the current pixel being shaded. If they differ by more than some threshold amount, then you do not use them.

Another thing you can do to increase performance is to merge multiple effects into one. For example, say you had a post-process fog effect and a bloom effect. When you apply the bloom, it has to blend a colour into every pixel on the screen, and so does the fog. You can save some bandwidth by merging these shaders so you only blend a colour once, instead of twice in a row.

Another common candidate here is to merge DOF and motion blur into a single effect.

Lastly, if you want to get really fancy, you can perform tile-based post processing. This is like tile-based deferred shading. Many effects don't affect every pixel on the screen, for example, DOF does not make any changes to pixels that are in-focus.

To do this, you first calculate for each "tile", say 8x8 pixels, whether any pixel inside that tile is out of focus. If it is, you output a 1 for that tile, otherwise a 0. These results are written to a texture that is num-tiles-wide x num-tiles-high. e.g. for 1280x720 resolution and 8x8 tiles, this tile texture would be 160x90. Then when performing DOF, you first check this tile texture and early exit if it contains a 0.0 for the current pixel's tile (or skip unneeded tiles in some other way).

Not too long ago I asked a question about strong guassian blur with focus on performance:

http://www.gamedev.net/topic/648412-gaussian-blur-with-large-radius/#entry5098093

You might find it helpful :)

Also, if you do not want to process entire quad, you can use stencil buffer as the reference to what pixels on screen to process. This is yet costy in case you do want to process entire quad, as this demand the stencil buffer pass to define what to shade.

This topic is closed to new replies.

Advertisement