Search across packages, versions, files, declarations, and comments. Use multiple terms to narrow results (AND), and add @vertex, @fragment, or @compute to filter by shader stage.
1#ifdef DITHER
2// From https://alex.vlachos.com/graphics/Alex_Vlachos_Advanced_VR_Rendering_GDC2015.pdf
3// 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;
11#endif
13#import bevy_pbr::forward_io::VertexOutput
15@group(2) @binding(0)
16var sky_texture: texture_cube<f32>;
17@group(2) @binding(1)
18var sky_sampler: sampler;
20@fragment
21fn fragment(
22 in: VertexOutput
23) -> @location(0) vec4<f32> {
24 let color = textureSample(sky_texture, sky_sampler, in.world_normal).xyz;
25#ifdef DITHER
26 return vec4<f32>(color + dither(in.position.xy), 1f);
27#else
28 return vec4<f32>(color, 1f);
29#endif
Contents