diff --git a/crates/bevy_pbr/src/render/pbr.wgsl b/crates/bevy_pbr/src/render/pbr.wgsl index 403c71554e42d..8b88ad1c9d1b3 100644 --- a/crates/bevy_pbr/src/render/pbr.wgsl +++ b/crates/bevy_pbr/src/render/pbr.wgsl @@ -24,12 +24,12 @@ struct FragmentInput { #endif }; +// Source: Advanced VR Rendering, GDC 2015, Alex Vlachos, Valve, Slide 49 +// https://media.steampowered.com/apps/valve/2015/Alex_Vlachos_Advanced_VR_Rendering_GDC2015.pdf fn screen_space_dither(frag_coord: vec2) -> vec4 { - // Iestyn's RGB dither (7 asm instructions) from Portal 2 X360, slightly modified for VR. - var dither = vec3(dot(vec2(171.0, 231.0), frag_coord)); - dither = fract(dither.rgb / vec3(103.0, 71.0, 97.0)); - // Subtract 0.5 to avoid slightly brightening the whole viewport. - return vec4((dither.rgb - 0.5) / 255.0, 0.0); + var dither = vec3(dot(vec2(171.0, 231.0), frag_coord)).xxx; + dither = fract(dither.rgb / vec3(103.0, 71.0, 97.0));// - 0.5; + return vec4(dither.rgb / 255.0, 0.0); } [[stage(fragment)]]