From 8d3439cdb2f8eb012337e29c73c10a3c249e1866 Mon Sep 17 00:00:00 2001 From: Aevyrie Date: Mon, 11 Jul 2022 01:21:28 -0700 Subject: [PATCH] Add source for screen space dither --- crates/bevy_pbr/src/render/pbr.wgsl | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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)]]