diff --git a/src/shaders/block_face3d.wgsl b/src/shaders/block_face3d.wgsl index 4d2b59bd5..e4fd13046 100644 --- a/src/shaders/block_face3d.wgsl +++ b/src/shaders/block_face3d.wgsl @@ -41,5 +41,5 @@ fn vs_main(v: VertexIn) -> VertexOut { @fragment fn fs_main(in: VertexOut) -> @location(0) vec4 { - return in.color; + return vec4(in.color.rgb, select(1.0, in.color.a, u.transparency_enable > 0.5)); } diff --git a/src/shaders/block_text.wgsl b/src/shaders/block_text.wgsl index e8e854598..9fe5f6931 100644 --- a/src/shaders/block_text.wgsl +++ b/src/shaders/block_text.wgsl @@ -72,5 +72,5 @@ fn fs_main(in: VertOut) -> @location(0) vec4 { if alpha <= 0.0 { discard; } - return vec4(in.color.rgb, in.color.a * alpha); + return vec4(in.color.rgb, select(1.0, in.color.a, u.transparency_enable > 0.5) * alpha); } diff --git a/src/shaders/face3d.wgsl b/src/shaders/face3d.wgsl index e2c2639b3..46b9f4c55 100644 --- a/src/shaders/face3d.wgsl +++ b/src/shaders/face3d.wgsl @@ -50,5 +50,5 @@ fn vs_main(v: VertexIn) -> VertexOut { @fragment fn fs_main(in: VertexOut) -> @location(0) vec4 { - return in.color; + return vec4(in.color.rgb, select(1.0, in.color.a, u.transparency_enable > 0.5)); } diff --git a/src/shaders/hatch.wgsl b/src/shaders/hatch.wgsl index b8800c41e..5b689cec3 100644 --- a/src/shaders/hatch.wgsl +++ b/src/shaders/hatch.wgsl @@ -218,6 +218,11 @@ fn check_family( // ── Fragment shader ────────────────────────────────────────────────────── +// Entity transparency shows only while transparency display is on. +fn shown(color: vec4) -> vec4 { + return vec4(color.rgb, select(1.0, color.a, u.transparency_enable > 0.5)); +} + @fragment fn fs_main(v: VOut) -> @location(0) vec4 { // Taken here, in uniform control flow — see check_family. let ddx_xz = dpdx(v.xz); @@ -227,7 +232,7 @@ fn check_family( // Mode dispatch. if inst.mode == 1u { - return inst.color; + return shown(inst.color); } else if inst.mode == 2u { let proj = v.xz.x * inst.grad_cos + v.xz.y * inst.grad_sin; var t = clamp((proj - inst.grad_min) / inst.grad_range, 0.0, 1.0); @@ -241,7 +246,7 @@ fn check_family( if (inst.grad_kind & 16u) != 0u { t = 1.0 - t; } - return mix(inst.color, inst.color2, t); + return shown(mix(inst.color, inst.color2, t)); } else if inst.mode == 3u { // Radial gradient: centre is (grad_cos, grad_sin), radius is grad_range. let d = length(v.xz - vec2(inst.grad_cos, inst.grad_sin)); @@ -255,7 +260,7 @@ fn check_family( } // Radial stops run OUTSIDE-IN: colour 1 at the rim, colour 2 at the // centre; the INV bit above swaps them back. - return mix(inst.color2, inst.color, t); + return shown(mix(inst.color2, inst.color, t)); } // Pattern LOD. Keep every family visible until all family spacings @@ -274,7 +279,7 @@ fn check_family( } } if all_families_subpixel { - return inst.color; + return shown(inst.color); } // Pattern evaluation. @@ -283,7 +288,7 @@ fn check_family( for (var i = 0u; i < inst.family_count; i++) { let fam = families[inst.family_offset + i]; if check_family(v.xz, ddx_xz, ddy_xz, fam, cos_off, sin_off, inst.scale) { - return inst.color; + return shown(inst.color); } } discard; diff --git a/src/shaders/hatch_texture.wgsl b/src/shaders/hatch_texture.wgsl index a46457d39..60bba158e 100644 --- a/src/shaders/hatch_texture.wgsl +++ b/src/shaders/hatch_texture.wgsl @@ -200,6 +200,11 @@ fn check_family( // ── Fragment shader ──────────────────────────────────────────────────────── +// Entity transparency shows only while transparency display is on. +fn shown(color: vec4) -> vec4 { + return vec4(color.rgb, select(1.0, color.a, u.transparency_enable > 0.5)); +} + @fragment fn fs_main(v: VOut) -> @location(0) vec4 { // Taken here, in uniform control flow — see check_family. let ddx_xz = dpdx(v.xz); @@ -209,7 +214,7 @@ fn check_family( let gk = (h.mode >> 8u) & 15u; let ginv = ((h.mode >> 8u) & 16u) != 0u; if base_mode == 1u { - return h.color; + return shown(h.color); } else if base_mode == 2u { let proj = v.xz.x * h.grad_cos + v.xz.y * h.grad_sin; var t = clamp((proj - h.grad_min) / h.grad_range, 0.0, 1.0); @@ -222,7 +227,7 @@ fn check_family( if ginv { t = 1.0 - t; } - return mix(h.color, h.color2, t); + return shown(mix(h.color, h.color2, t)); } else if base_mode == 3u { // Radial gradient: centre is (grad_cos, grad_sin), radius is grad_range. let d = length(v.xz - vec2(h.grad_cos, h.grad_sin)); @@ -234,7 +239,7 @@ fn check_family( t = 1.0 - t; } // Radial stops run outside-in (colour 2 at the centre) — see hatch.wgsl. - return mix(h.color2, h.color, t); + return shown(mix(h.color2, h.color, t)); } // Keep every family visible until all family spacings project below 2 px, @@ -252,7 +257,7 @@ fn check_family( } } if all_families_subpixel { - return h.color; + return shown(h.color); } let cos_off = cos(h.angle_offset); @@ -260,7 +265,7 @@ fn check_family( for (var i = 0u; i < h.n_families; i++) { let fam = load_family(i); if check_family(v.xz, ddx_xz, ddy_xz, fam, cos_off, sin_off, h.scale) { - return h.color; + return shown(h.color); } } discard; diff --git a/src/shaders/text.wgsl b/src/shaders/text.wgsl index 9062f8320..dc5e5bdec 100644 --- a/src/shaders/text.wgsl +++ b/src/shaders/text.wgsl @@ -82,5 +82,5 @@ fn fs_main(in: VertOut) -> @location(0) vec4 { if alpha <= 0.0 { discard; } - return vec4(in.color.rgb, in.color.a * alpha); + return vec4(in.color.rgb, select(1.0, in.color.a, u.transparency_enable > 0.5) * alpha); }