From 0e03cac3685af239e6491784a5ee3ca9a4390fb8 Mon Sep 17 00:00:00 2001 From: Kacpherek Date: Wed, 28 Oct 2026 06:10:38 +0100 Subject: [PATCH] Draw faint entity shadows instead of cutting them out Shadows used the entity fragment shader, which discards alpha under 0.1, so they vanished at block light 7 and below and faded out a few blocks away. rendertype_entity_shadow.fsh has no cutout. --- crates/horizon-client/src/entity.wgsl | 10 ++++++++++ crates/horizon-client/src/gfx.rs | 4 +++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/crates/horizon-client/src/entity.wgsl b/crates/horizon-client/src/entity.wgsl index 919c5edbb..b674b0941 100644 --- a/crates/horizon-client/src/entity.wgsl +++ b/crates/horizon-client/src/entity.wgsl @@ -263,6 +263,16 @@ fn crumbling_uv(uv: vec2, packed_origin: vec2, sprite_size: vec2, // rendertype_outline.fsh: the vertex colour (the team colour; outline vertices carry no // normal, so no cardinal light) wherever the texture is not fully clear. +// rendertype_entity_shadow.fsh: the shadow texture times the vertex colour, +// then fog, with no alpha cutout, so a faint shadow in dim light still draws. +@fragment fn fs_entity_shadow(in: Out) -> @location(0) vec4 { + var color = textureSample(atlas, atlas_sampler, in.uv) * in.color; + color *= in.light_color; + let f = max(linear_fog(in.spherical, globals.fog.x, globals.fog.y), + linear_fog(in.cylindrical, globals.fog.z, globals.fog.w)); + return vec4(mix(color.rgb, globals.fog_color.rgb, f * globals.fog_color.a), color.a); +} + @fragment fn fs_outline(in: Out) -> @location(0) vec4 { if textureSample(atlas, atlas_sampler, in.uv).a == 0.0 { discard; } return vec4(in.color.rgb, 1.0); diff --git a/crates/horizon-client/src/gfx.rs b/crates/horizon-client/src/gfx.rs index beb8b9060..367172eec 100644 --- a/crates/horizon-client/src/gfx.rs +++ b/crates/horizon-client/src/gfx.rs @@ -1966,7 +1966,7 @@ impl Renderer { // ulps covers that spread at any resolution while staying far below // the 0.001 a model's feet sit higher, so shadows never bleed onto // the feet. - let shadow_blob_pipeline = entity_pipeline( + let shadow_blob_pipeline = entity_pipeline_with( "Entity shadows", None, false, @@ -1978,6 +1978,8 @@ impl Renderer { }, alpha_blend, false, + "fs_entity_shadow", + wgpu::ColorWrites::ALL, ); // RenderPipelines.ITEM_TRANSLUCENT: blended, depth tested. Drawn before // translucent terrain, it cannot write depth: the water behind a