diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2022-08-15 19:08:34 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2022-08-15 19:36:19 +0300 |
commit | b43b62191cde60fee65f8ff1ad108b271f42295d (patch) | |
tree | c1262b5422c33f8fc21adbc4613c9fa22bc95528 /source/blender/draw/engines/eevee_next/shaders/eevee_hiz_debug_frag.glsl | |
parent | 3195a381200eb98e6add8b0504f701318186946d (diff) |
EEVEE-Next: HiZ Buffer: New implementation
This new implementation does all downsampling in a single compute shader
dispatch, removing a lot of complexity from the previous recursive
downsampling.
This is heavilly inspired by the Single-Pass-Downsampler from GPUOpen:
https://github.com/GPUOpen-Effects/FidelityFX-SPD
However I do not implement all the optimization bits as they require
vulkan (GL_KHR_shader_subgroup) and is not as versatile (it is only
for HiZ).
Timers inside renderdoc report ~0.4ms of saving on a 2048*1024 render for
the whole downsampling. Note that the previous implementation only
processed 6 mips where the new one processes 8 mips.
```
EEVEE ~1.0ms
EEVEE-Next ~0.6ms
```
Padding has been bumped to be of 128px for processing 8 mips.
A new debug option has been added (debug value 2) to validate the HiZ.
Diffstat (limited to 'source/blender/draw/engines/eevee_next/shaders/eevee_hiz_debug_frag.glsl')
-rw-r--r-- | source/blender/draw/engines/eevee_next/shaders/eevee_hiz_debug_frag.glsl | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/source/blender/draw/engines/eevee_next/shaders/eevee_hiz_debug_frag.glsl b/source/blender/draw/engines/eevee_next/shaders/eevee_hiz_debug_frag.glsl new file mode 100644 index 00000000000..e93d0f472fa --- /dev/null +++ b/source/blender/draw/engines/eevee_next/shaders/eevee_hiz_debug_frag.glsl @@ -0,0 +1,24 @@ + +/** + * Debug hiz down sampling pass. + * Output red if above any max pixels, blue otherwise. + */ + +void main() +{ + ivec2 texel = ivec2(gl_FragCoord.xy); + + float depth0 = texelFetch(hiz_tx, texel, 0).r; + + vec4 color = vec4(0.1, 0.1, 1.0, 1.0); + for (int i = 1; i < HIZ_MIP_COUNT; i++) { + ivec2 lvl_texel = texel / ivec2(uvec2(1) << uint(i)); + lvl_texel = min(lvl_texel, textureSize(hiz_tx, i) - 1); + if (texelFetch(hiz_tx, lvl_texel, i).r < depth0) { + color = vec4(1.0, 0.1, 0.1, 1.0); + break; + } + } + out_debug_color_add = vec4(color.rgb, 0.0) * 0.2; + out_debug_color_mul = color; +} |