From 408a75aeb32f1f1e34d03f4ff9a42098fcf8514b Mon Sep 17 00:00:00 2001 From: Kacpherek Date: Mon, 26 Oct 2026 11:45:03 +0100 Subject: [PATCH 1/5] Decorated pot: draw one face of its top and bottom planes --- .../horizon-client/src/block_entity_render.rs | 23 ++++++++++++++++++- .../horizon-client/src/item_render/special.rs | 2 +- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/crates/horizon-client/src/block_entity_render.rs b/crates/horizon-client/src/block_entity_render.rs index 10c5e2509..3d8c0258b 100644 --- a/crates/horizon-client/src/block_entity_render.rs +++ b/crates/horizon-client/src/block_entity_render.rs @@ -66,6 +66,24 @@ impl ModelPart { children, } } + /// `parse` of the entity model layer `layer`. Vanilla culls back faces for the pot's + /// `top` and `bottom` planes (`DecoratedPotRenderer.createBaseLayer`), so only the + /// up face of `top` and the down face of `bottom` show; ours draws both faces of each + /// plane, which fight for the same pixels, so the culled face is dropped here. + pub fn parse_layer(layer: &str, v: &Value) -> Self { + let mut part = Self::parse(v); + if layer == "minecraft:decorated_pot_base#main" { + // `ModelPart.Cube` polygon order: down, up, west, north, east, south. + for (name, face) in [("top", 1), ("bottom", 0)] { + if let Some((_, plane)) = part.children.iter_mut().find(|(n, _)| n == name) + && let Some(&polygon) = plane.polygons.get(face) + { + plane.polygons = vec![polygon]; + } + } + } + part + } pub fn child(&self, name: &str) -> Option<&ModelPart> { self.children .iter() @@ -794,7 +812,10 @@ impl BlockEntityRenderer { let all: Value = serde_json::from_slice(&std::fs::read(root.join("entity-models.json"))?)?; let models = MODELS .iter() - .filter_map(|(key, layer)| all.get(*layer).map(|v| (*key, ModelPart::parse(v)))) + .filter_map(|(key, layer)| { + all.get(*layer) + .map(|v| (*key, ModelPart::parse_layer(layer, v))) + }) .collect(); let mut renderer = Self::new(models, registry); renderer.visibility = Some(Mutex::new(crate::models::load_visibility(root, registry)?)); diff --git a/crates/horizon-client/src/item_render/special.rs b/crates/horizon-client/src/item_render/special.rs index d42378db1..6f4980169 100644 --- a/crates/horizon-client/src/item_render/special.rs +++ b/crates/horizon-client/src/item_render/special.rs @@ -60,7 +60,7 @@ pub(super) fn load_parts(root: &Path) -> HashMap { .chain(COPPER_GOLEM_LAYERS.iter()) .filter_map(|(key, layer)| { all.get(*layer) - .map(|v| ((*key).to_owned(), ModelPart::parse(v))) + .map(|v| ((*key).to_owned(), ModelPart::parse_layer(layer, v))) }) .collect() } From d338bcd070a6c2bf2568c1f57900bf222299929b Mon Sep 17 00:00:00 2001 From: Ludovic Marie <136255825+ludovic111@users.noreply.github.com> Date: Mon, 26 Oct 2026 13:16:31 +0100 Subject: [PATCH 2/5] Decorated pot: say why only the outer faces stay Co-Authored-By: Claude Opus 5.5 --- crates/horizon-client/src/block_entity_render.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/horizon-client/src/block_entity_render.rs b/crates/horizon-client/src/block_entity_render.rs index 3d8c0258b..1bbc7a207 100644 --- a/crates/horizon-client/src/block_entity_render.rs +++ b/crates/horizon-client/src/block_entity_render.rs @@ -66,10 +66,10 @@ impl ModelPart { children, } } - /// `parse` of the entity model layer `layer`. Vanilla culls back faces for the pot's - /// `top` and `bottom` planes (`DecoratedPotRenderer.createBaseLayer`), so only the - /// up face of `top` and the down face of `bottom` show; ours draws both faces of each - /// plane, which fight for the same pixels, so the culled face is dropped here. + /// `parse` of the entity model layer `layer`. The pot's `top` and `bottom` are flat + /// boxes (`DecoratedPotRenderer.createBaseLayer`) drawn with a culling render type, so + /// from outside only `top`'s up face and `bottom`'s down face show. Both faces of each + /// plane would fight for the same pixels here: keep the outer one. pub fn parse_layer(layer: &str, v: &Value) -> Self { let mut part = Self::parse(v); if layer == "minecraft:decorated_pot_base#main" { From 83a6f5c7b9b76071bc7798b63f11085d37beb61a Mon Sep 17 00:00:00 2001 From: Kacpherek Date: Mon, 26 Oct 2026 16:27:13 +0100 Subject: [PATCH 3/5] Revert "Decorated pot: say why only the outer faces stay" This reverts commit d338bcd070a6c2bf2568c1f57900bf222299929b. --- crates/horizon-client/src/block_entity_render.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/horizon-client/src/block_entity_render.rs b/crates/horizon-client/src/block_entity_render.rs index 1bbc7a207..3d8c0258b 100644 --- a/crates/horizon-client/src/block_entity_render.rs +++ b/crates/horizon-client/src/block_entity_render.rs @@ -66,10 +66,10 @@ impl ModelPart { children, } } - /// `parse` of the entity model layer `layer`. The pot's `top` and `bottom` are flat - /// boxes (`DecoratedPotRenderer.createBaseLayer`) drawn with a culling render type, so - /// from outside only `top`'s up face and `bottom`'s down face show. Both faces of each - /// plane would fight for the same pixels here: keep the outer one. + /// `parse` of the entity model layer `layer`. Vanilla culls back faces for the pot's + /// `top` and `bottom` planes (`DecoratedPotRenderer.createBaseLayer`), so only the + /// up face of `top` and the down face of `bottom` show; ours draws both faces of each + /// plane, which fight for the same pixels, so the culled face is dropped here. pub fn parse_layer(layer: &str, v: &Value) -> Self { let mut part = Self::parse(v); if layer == "minecraft:decorated_pot_base#main" { From 9841ce7824d8a65fbc66f5a2d2ecef07defd4912 Mon Sep 17 00:00:00 2001 From: Kacpherek Date: Mon, 26 Oct 2026 16:27:13 +0100 Subject: [PATCH 4/5] Revert "Decorated pot: draw one face of its top and bottom planes" This reverts commit 408a75aeb32f1f1e34d03f4ff9a42098fcf8514b. --- .../horizon-client/src/block_entity_render.rs | 23 +------------------ .../horizon-client/src/item_render/special.rs | 2 +- 2 files changed, 2 insertions(+), 23 deletions(-) diff --git a/crates/horizon-client/src/block_entity_render.rs b/crates/horizon-client/src/block_entity_render.rs index 3d8c0258b..10c5e2509 100644 --- a/crates/horizon-client/src/block_entity_render.rs +++ b/crates/horizon-client/src/block_entity_render.rs @@ -66,24 +66,6 @@ impl ModelPart { children, } } - /// `parse` of the entity model layer `layer`. Vanilla culls back faces for the pot's - /// `top` and `bottom` planes (`DecoratedPotRenderer.createBaseLayer`), so only the - /// up face of `top` and the down face of `bottom` show; ours draws both faces of each - /// plane, which fight for the same pixels, so the culled face is dropped here. - pub fn parse_layer(layer: &str, v: &Value) -> Self { - let mut part = Self::parse(v); - if layer == "minecraft:decorated_pot_base#main" { - // `ModelPart.Cube` polygon order: down, up, west, north, east, south. - for (name, face) in [("top", 1), ("bottom", 0)] { - if let Some((_, plane)) = part.children.iter_mut().find(|(n, _)| n == name) - && let Some(&polygon) = plane.polygons.get(face) - { - plane.polygons = vec![polygon]; - } - } - } - part - } pub fn child(&self, name: &str) -> Option<&ModelPart> { self.children .iter() @@ -812,10 +794,7 @@ impl BlockEntityRenderer { let all: Value = serde_json::from_slice(&std::fs::read(root.join("entity-models.json"))?)?; let models = MODELS .iter() - .filter_map(|(key, layer)| { - all.get(*layer) - .map(|v| (*key, ModelPart::parse_layer(layer, v))) - }) + .filter_map(|(key, layer)| all.get(*layer).map(|v| (*key, ModelPart::parse(v)))) .collect(); let mut renderer = Self::new(models, registry); renderer.visibility = Some(Mutex::new(crate::models::load_visibility(root, registry)?)); diff --git a/crates/horizon-client/src/item_render/special.rs b/crates/horizon-client/src/item_render/special.rs index 6f4980169..d42378db1 100644 --- a/crates/horizon-client/src/item_render/special.rs +++ b/crates/horizon-client/src/item_render/special.rs @@ -60,7 +60,7 @@ pub(super) fn load_parts(root: &Path) -> HashMap { .chain(COPPER_GOLEM_LAYERS.iter()) .filter_map(|(key, layer)| { all.get(*layer) - .map(|v| ((*key).to_owned(), ModelPart::parse_layer(layer, v))) + .map(|v| ((*key).to_owned(), ModelPart::parse(v))) }) .collect() } From c987778e97f2290abce276333ffc22ba24f6ef78 Mon Sep 17 00:00:00 2001 From: Kacpherek Date: Mon, 26 Oct 2026 16:34:24 +0100 Subject: [PATCH 5/5] Decorated pot: keep every quad and cull back faces like entitySolid --- crates/horizon-client/src/block_entity_render.rs | 12 +++++++++++- crates/horizon-client/src/entity.wgsl | 9 +++++++-- crates/horizon-client/src/item_render.rs | 7 +++++-- crates/horizon-client/src/item_render/gui.rs | 1 + crates/horizon-client/src/item_render/special.rs | 14 ++++++++++++++ crates/horizon-client/src/mesher.rs | 6 +++++- 6 files changed, 43 insertions(+), 6 deletions(-) diff --git a/crates/horizon-client/src/block_entity_render.rs b/crates/horizon-client/src/block_entity_render.rs index 10c5e2509..f28008d16 100644 --- a/crates/horizon-client/src/block_entity_render.rs +++ b/crates/horizon-client/src/block_entity_render.rs @@ -5,7 +5,11 @@ //! (`entity-models.json`); transforms, animation and textures follow each //! vanilla renderer. Faces are lit like the `entity` shader: the lightmap at //! the block plus `minecraft_mix_light` with the level's two diffuse lights. -use crate::{hud::Rect, mesher::Vertex, world::World}; +use crate::{ + hud::Rect, + mesher::{CULL_BACK, Vertex}, + world::World, +}; use glam::{DVec3, Mat4, Quat, Vec3}; use horizon_core::geometry::{ Direction, @@ -1384,6 +1388,7 @@ impl BlockEntityRenderer { m *= around(Mat4::from_rotation_y(turn * decay), pivot); } } + let first = out.len(); if let Some(paint) = paint("entity/decorated_pot/decorated_pot_base", 0xFFFFFF, packed) { @@ -1401,6 +1406,11 @@ impl BlockEntityRenderer { draw_part(part, side, m, &none, paint, out); } } + // `DecoratedPotRenderer` submits every part with `entitySolid`, which culls + // back faces: the flat `top` and `bottom` planes show one side each. + for vertex in &mut out[first..] { + vertex.normal = CULL_BACK; + } } Kind::EndPortal => { // TheEndPortalRenderer.TRANSFORMATION: y from 6/16 to 12/16; only the diff --git a/crates/horizon-client/src/entity.wgsl b/crates/horizon-client/src/entity.wgsl index 2e865dfb1..4bd8983d9 100644 --- a/crates/horizon-client/src/entity.wgsl +++ b/crates/horizon-client/src/entity.wgsl @@ -44,6 +44,8 @@ struct Out { // entity.vsh's lightMapColor, multiplied in after the overlay. @location(9) light_color: vec4, @location(10) @interpolate(flat) weather_rect: vec4, + // 1 drops the quad's back-facing pixels (Vertex::normal w = 1), like a culling render type. + @location(11) @interpolate(flat) cull: u32, } // Shipped light.glsl; normals are already transformed and RGBA8_SNORM packed. fn entity_light(normal: vec3, nether: bool) -> f32 { @@ -92,7 +94,10 @@ fn entity_vertex(position: vec3, uv: vec2, // minecraft_mix_light: the vertex colour times the cardinal light only. var c = color; var back = c; - if normal.w != 0.0 { + // Normal w: 0 keeps the baked colour, +-127 shades by the normal, and a small positive 1 + // keeps the baked colour but culls back faces (entitySolid models such as the decorated pot). + out.cull = select(0u, 1u, normal.w > 0.0 && normal.w < 0.5); + if abs(normal.w) >= 0.5 { c = vec4(c.rgb * entity_light(normal.xyz, globals.time.y != 0.0), c.a); back = select(c, vec4(back.rgb * entity_light(-normal.xyz, globals.time.y != 0.0), back.a), normal.w < 0.0); } @@ -187,7 +192,7 @@ fn linear_fog(d: f32, start: f32, end: f32) -> f32 { // clouds.fsh: alpha fades out towards the cloud fog end. return vec4(color.rgb, color.a * (1.0 - linear_fog(in.spherical, 0.0, globals.fog_ends.y))); } - if color.a < 0.1 { discard; } + if color.a < 0.1 || (in.cull != 0u && !front) { discard; } // entity.fsh calculateFinalColor: the overlay (hurt red, TNT white) over the // lit texture, then the lightmap, then the glint and fog. color = vec4(mix(in.overlay_color.rgb, color.rgb, in.overlay_color.a), color.a); diff --git a/crates/horizon-client/src/item_render.rs b/crates/horizon-client/src/item_render.rs index c2f5c8400..540f7c23c 100644 --- a/crates/horizon-client/src/item_render.rs +++ b/crates/horizon-client/src/item_render.rs @@ -12,7 +12,7 @@ mod special; use crate::{ block_entity_render::{ModelPart, diffuse}, hud::Rect, - mesher::Vertex, + mesher::{CULL_BACK, Vertex}, }; use glam::{Mat3, Mat4, Vec3}; use horizon_assets::{ @@ -46,6 +46,8 @@ pub struct ItemQuad { pub foil: Foil, /// `MaterialInfo.lightEmission` (block light floor). pub light_emission: u8, + /// The render type culls back faces (`entitySolid`): world drawing discards them. + pub cull_back: bool, } /// Which glint render type a quad uses. #[derive(Clone, Copy, Debug, PartialEq, Eq)] @@ -246,6 +248,7 @@ fn submit_quads( color: argb(color), foil, light_emission: q.light_emission, + cull_back: false, }); } } @@ -692,7 +695,7 @@ impl ItemSink for WorldSink<'_> { let overlay = if q.foil == Foil::None { 0 } else { 7 }; for (p, uv) in q.pos.iter().zip(q.uv) { self.out.push(Vertex { - normal: [0; 4], + normal: if q.cull_back { CULL_BACK } else { [0; 4] }, pos: p.to_array(), uv, layer: overlay, diff --git a/crates/horizon-client/src/item_render/gui.rs b/crates/horizon-client/src/item_render/gui.rs index e3d7cc876..93645559a 100644 --- a/crates/horizon-client/src/item_render/gui.rs +++ b/crates/horizon-client/src/item_render/gui.rs @@ -269,6 +269,7 @@ mod tests { color, foil: Foil::None, light_emission: 0, + cull_back: false, } } diff --git a/crates/horizon-client/src/item_render/special.rs b/crates/horizon-client/src/item_render/special.rs index d42378db1..8a54f49bb 100644 --- a/crates/horizon-client/src/item_render/special.rs +++ b/crates/horizon-client/src/item_render/special.rs @@ -65,6 +65,17 @@ pub(super) fn load_parts(root: &Path) -> HashMap { .collect() } +/// Marks every quad passed on as drawn with a back-face-culling render type (`entitySolid`). +struct CullBack<'a>(&'a mut dyn ItemSink); +impl ItemSink for CullBack<'_> { + fn quad(&mut self, quad: ItemQuad) { + self.0.quad(ItemQuad { + cull_back: true, + ..quad + }); + } +} + /// A pose override for a named part (`setupAnim`). type Adjust<'a> = &'a dyn Fn(&str, &mut [f32; 9]); fn none(_: &str, _: &mut [f32; 9]) {} @@ -119,6 +130,7 @@ fn draw( color, foil, light_emission: 0, + cull_back: false, }); } for (child_name, child) in &part.children { @@ -569,6 +581,8 @@ pub(super) fn submit( } SpecialKind::DecoratedPot => { let sides = pot_sides(argument); + // `DecoratedPotRenderer` draws every part with `entitySolid`. + let sink = &mut CullBack(sink); if let Some(base) = renderer.part("decorated_pot_base") && let Some(r) = sprites .get("entity/decorated_pot/decorated_pot_base") diff --git a/crates/horizon-client/src/mesher.rs b/crates/horizon-client/src/mesher.rs index fff3c6aa0..788eb316d 100644 --- a/crates/horizon-client/src/mesher.rs +++ b/crates/horizon-client/src/mesher.rs @@ -36,9 +36,13 @@ pub struct Vertex { pub color: u32, /// Smooth light, 16x fixed point: sky in bits 0..8, block in bits 8..16. pub light: u32, - /// RGBA8_SNORM face normal; w = -127 for two-sided lighting, 0 to keep baked/unlit colour. + /// RGBA8_SNORM face normal; w = -127 for two-sided lighting, 0 to keep baked/unlit colour, + /// [`CULL_BACK`] to keep it and also drop back-facing pixels. pub normal: [i8; 4], } +/// `Vertex::normal` of a baked-colour quad of an `entitySolid` model: the render type culls +/// back faces, which the entity pipelines here do not, so `entity.wgsl` discards them. +pub const CULL_BACK: [i8; 4] = [0, 0, 0, 1]; /// A section vertex: vanilla's `DefaultVertexFormat.BLOCK` (position, colour, /// UV0, UV2) with the sprite's array layer beside the light, in 24 bytes /// rather than vanilla's 28: the UV is fixed point, which holds model UVs