Skip to content

Commit

Permalink
Add source for screen space dither
Browse files Browse the repository at this point in the history
  • Loading branch information
aevyrie committed Jul 11, 2022
1 parent b969bb7 commit 8d3439c
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions crates/bevy_pbr/src/render/pbr.wgsl
Expand Up @@ -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<f32>) -> vec4<f32> {
// Iestyn's RGB dither (7 asm instructions) from Portal 2 X360, slightly modified for VR.
var dither = vec3<f32>(dot(vec2<f32>(171.0, 231.0), frag_coord));
dither = fract(dither.rgb / vec3<f32>(103.0, 71.0, 97.0));
// Subtract 0.5 to avoid slightly brightening the whole viewport.
return vec4<f32>((dither.rgb - 0.5) / 255.0, 0.0);
var dither = vec3<f32>(dot(vec2<f32>(171.0, 231.0), frag_coord)).xxx;
dither = fract(dither.rgb / vec3<f32>(103.0, 71.0, 97.0));// - 0.5;
return vec4<f32>(dither.rgb / 255.0, 0.0);
}

[[stage(fragment)]]
Expand Down

0 comments on commit 8d3439c

Please sign in to comment.