1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-04 12:00:25 +00:00
Files
godot/servers/rendering/renderer_rd/shaders/effects/blur_raster_inc.glsl
clayjohn 2e59cb41f4 Optimize glow and tonemap gather step in the mobile renderer
Mobile devices are typically bandwidth bound which means we need to do as few texture samples as possible.

They typically use TBDR GPUs which means that all rendering takes place on special optimized tiles. As a side effect, reading back memory from tile to VRAM is really slow, especially on Mali devices.

This commit uses a technique where you do a small blur while downsampling, and then another small blur while upsampling to get really high quality glow. While this doesn't reduce the renderpass count very much, it does reduce the texture read bandwidth by almost 10 times. Overall glow was more texture-read bound than memory write, bound, so this was a huge win.

A side effect of this new technique is that we can gather the glow as we upsample instead of gathering the glow in the final tonemap pass. Doing so allows us to significantly reduce the cost of the tonemap pass as well.
2025-10-30 21:56:26 -07:00

25 lines
608 B
GLSL

#define FLAG_HORIZONTAL (1 << 0)
#define FLAG_USE_ORTHOGONAL_PROJECTION (1 << 1)
#define FLAG_GLOW_FIRST_PASS (1 << 2)
layout(push_constant, std430) uniform Blur {
vec2 dest_pixel_size; // 08 - 08
vec2 source_pixel_size; // 08 - 16
vec2 pad; // 08 - 24
uint flags; // 04 - 28
float glow_level; // 04 - 32
// Glow.
float glow_strength; // 04 - 36
float glow_bloom; // 04 - 40
float glow_hdr_threshold; // 04 - 44
float glow_hdr_scale; // 04 - 48
float glow_exposure; // 04 - 52
float glow_white; // 04 - 56
float glow_luminance_cap; // 04 - 60
float luminance_multiplier; // 04 - 64
}
blur;