forked from 1b-agent/opencadstudio-upstream
Image shader: fully transparent pixels are discarded
A transparent pixel wrote depth, hiding lines and objects under the image that were drawn after it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e9e05d89f3
commit
5de0ce069f
1 file changed
+5
@@ -64,5 +64,10 @@ fn vs_main(in: VertIn) -> VertOut {
|
|||||||
fn fs_main(in: VertOut) -> @location(0) vec4<f32> {
|
fn fs_main(in: VertOut) -> @location(0) vec4<f32> {
|
||||||
let col = textureSample(img_texture, img_sampler, in.uv);
|
let col = textureSample(img_texture, img_sampler, in.uv);
|
||||||
let alpha = select(1.0, col.a, img_params.use_alpha > 0.5);
|
let alpha = select(1.0, col.a, img_params.use_alpha > 0.5);
|
||||||
|
// A fully transparent pixel leaves no depth behind, so what lies under
|
||||||
|
// the image (drawn before or after it) shows through.
|
||||||
|
if (alpha * img_params.opacity <= 0.0) {
|
||||||
|
discard;
|
||||||
|
}
|
||||||
return vec4<f32>(col.rgb, alpha * img_params.opacity);
|
return vec4<f32>(col.rgb, alpha * img_params.opacity);
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user