mirror of
https://github.com/bevyengine/bevy
synced 2024-11-22 12:43:34 +00:00
Fix ssao only sampling mip 0 (#11292)
# Objective Fixes https://github.com/bevyengine/bevy/issues/11222 ## Solution SSAO's sample_mip_level was always giving negative values because it was in UV space (0..1) when it needed to be in pixel units (0..resolution). Fixing it so it properly samples lower mip levels when appropriate is a pretty large speedup (~3.2ms -> ~1ms at 4k, ~507us-> 256us at 1080p on a 6800xt), and I didn't notice any obvious visual quality differences. --------- Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
This commit is contained in:
parent
ce5bae55f6
commit
64a15f1b10
1 changed files with 2 additions and 1 deletions
|
@ -139,7 +139,8 @@ fn gtao(@builtin(global_invocation_id) global_id: vec3<u32>) {
|
||||||
s *= s; // https://github.com/GameTechDev/XeGTAO#sample-distribution
|
s *= s; // https://github.com/GameTechDev/XeGTAO#sample-distribution
|
||||||
let sample = s * sample_mul;
|
let sample = s * sample_mul;
|
||||||
|
|
||||||
let sample_mip_level = clamp(log2(length(sample)) - 3.3, 0.0, 5.0); // https://github.com/GameTechDev/XeGTAO#memory-bandwidth-bottleneck
|
// * view.viewport.zw gets us from [0, 1] to [0, viewport_size], which is needed for this to get the correct mip levels
|
||||||
|
let sample_mip_level = clamp(log2(length(sample * view.viewport.zw)) - 3.3, 0.0, 5.0); // https://github.com/GameTechDev/XeGTAO#memory-bandwidth-bottleneck
|
||||||
let sample_position_1 = load_and_reconstruct_view_space_position(uv + sample, sample_mip_level);
|
let sample_position_1 = load_and_reconstruct_view_space_position(uv + sample, sample_mip_level);
|
||||||
let sample_position_2 = load_and_reconstruct_view_space_position(uv - sample, sample_mip_level);
|
let sample_position_2 = load_and_reconstruct_view_space_position(uv - sample, sample_mip_level);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue