1#ifdef DITHER2// From https://alex.vlachos.com/graphics/Alex_Vlachos_Advanced_VR_Rendering_GDC2015.pdf3// and https://www.shadertoy.com/view/MslGR8 (5th one starting from the bottom)4fn dither(frag_coord: vec2<f32>) -> vec3<f32> {5 // Iestyn's RGB dither (7 asm instructions) from Portal 2 X360, slightly modified for VR.6 var dither = vec3<f32>(dot(vec2<f32>(171.0, 231.0), frag_coord));7 dither = fract(dither.rgb / vec3<f32>(103.0, 71.0, 97.0));8 // Subtract 0.5 to avoid slightly brightening the whole viewport.9 return (dither.rgb - 0.5) / 255.0;10}11#endif13#import bevy_pbr::forward_io::VertexOutput15@group(2) @binding(0)16var sky_texture: texture_cube<f32>;17@group(2) @binding(1)18var sky_sampler: sampler;20@fragment21fn fragment(22 in: VertexOutput23) -> @location(0) vec4<f32> {24 let color = textureSample(sky_texture, sky_sampler, in.world_normal).xyz;25#ifdef DITHER26 return vec4<f32>(color + dither(in.position.xy), 1f);27#else28 return vec4<f32>(color, 1f);29#endif30}