var positions: array, 6> = array, 6>( vec2(-1.0, 1.0), vec2(-1.0, -1.0), vec2(1.0, -1.0), vec2(-1.0, 1.0), vec2(1.0, 1.0), vec2(1.0, -1.0) ); var uvs: array, 6> = array, 6>( vec2(0.0, 0.0), vec2(0.0, 1.0), vec2(1.0, 1.0), vec2(0.0, 0.0), vec2(1.0, 0.0), vec2(1.0, 1.0) ); @group(0) @binding(0) var depth_sampler: sampler; @group(0) @binding(1) var depth_texture: texture_2d; struct Output { @builtin(position) position: vec4, @location(0) uv: vec2, } @vertex fn vs_main(@builtin(vertex_index) v_index: u32) -> Output { var out: Output; out.position = vec4(positions[v_index], 0.0, 1.0); out.uv = uvs[v_index]; return out; } @fragment fn fs_main(input: Output) -> @location(0) vec4 { let depth = textureSample(depth_texture, depth_sampler, input.uv).r; if (depth > .9999) { discard; } let c = 1.0 - depth; return vec4(c, c, c, 1.0); }