Graphics
August 9, 2024

SSAO and Bloom rewrites

Better looks, less performance hits!

author
[teh]Beherith
Last updated:
August 9, 2024

SSAO and Bloom rewrites

SSAO

Greatly reduced the VRAM usage Architectural changes:

Unit stencil texture

  • All features and units model bounding boxes are rendered onto a downsized texture, that may be requested and reused by any subsequent pass.

Gbuffer Fusion pass

  • Removed merging of misc tex buffers, saving a fullscreen buffers worth of vram and some gpu load
  • Removed merging of map and model normals, saving another fullscreen buffer, since these were also queried only once per fragment in ssao shader
  • In the gbuffer fusion shader, map model occlusion is indicated by a positive z in viewpos tex
  • The entire gbuffer fusion shader can be turned off, directly sampling the map and model depth buffers, this is most useful when rendering ssao to a downsampled target

SSAO

The ssao shader samples multiple neighbouring texels when downsampling, to reduce shimmer in the downsampled target. Random hemispherical samples are now generated across a fibonacci sphere for even surface distribution Outputs are now:

  • RG channel is viewpos xy normals, which is output as zero vector for ground fragments
  • B channel is relative depth of fragment
  • A is occlusion

Blur

  • Blur shader is now designed to work in a single pair of horizontal and vertical passes, and the dir uniform controls wether it - - should perform its final mixdown
  • Blur shader has correct offsets and weights
  • Compares the neighbouring normals and depths when blurring
  • Identifies samples that are outliers with no similar neighbours
  • Blur shader reuses the SSAO texture in its second pass, saving more vram
  • During final mixdown, occlusion is packed into alpha, and brightening (inverse occlusion) is passed into rgb

Compositing

  • A different gl blending operation is used, where the ssao alpha darkens the original image, and the ssao color brightens the original.

Bloom

  • Less VRAM usage
  • Fixed shimmering on low qualities
  • Uses Pixel Quad Message passing to massively reduce the number of passes and texture samples required
  • Wider kernels, smoother looks
  • Better performance

CAS

  • Uses Pixel Quad Message passing to massively reduce the number of texture samples

Unit Stencil API

  • For early bailing a lot of near-unit shading stuff. Useable on demand.

Thaks to @rlcevg for every bit of help. Thanks to @icexuick for tuning SSAO.

More Images

More microblogs