// Circle mask render shader // Samples mask and draws green outside the circle @group(0) @binding(0) var mask_tex: texture_2d; @group(0) @binding(1) var mask_sampler: sampler; struct CommonUniforms { resolution: vec2, aspect_ratio: f32, time: f32, beat: f32, audio_intensity: f32, }; @group(0) @binding(2) var uniforms: CommonUniforms; struct VSOutput { @builtin(position) position: vec4, }; @vertex fn vs_main(@builtin(vertex_index) i: u32) -> VSOutput { var pos = array, 3>( vec2(-1, -1), vec2(3, -1), vec2(-1, 3)); return VSOutput(vec4(pos[i], 0.0, 1.0)); } @fragment fn fs_main(@builtin(position) p: vec4) -> @location(0) vec4 { let uv = p.xy / uniforms.resolution; let mask_value = textureSample(mask_tex, mask_sampler, uv).r; if (mask_value > 0.5) { discard; } return vec4(0.0, 1.0, 0.0, 1.0); }