Player body and attached entities do not cast dynamic shadows in first-person view
Luanti version
Luanti 5.17.0 (OSX)
Using LuaJIT 2.1.1764270282
Built by Clang 21.0
Running on Darwin/27.0.0 arm64
BUILD_TYPE=Release
RUN_IN_PLACE=0
USE_CURL=1
USE_GETTEXT=1
USE_SOUND=1
STATIC_SHAREDIR="luanti.app/Contents/Resources"
STATIC_LOCALEDIR="luanti.app/Contents/Resources/locale"Operating system and version
macOS (Apple Silicon)
CPU model
Apple M4 Max
GPU model
Apple M4 Max
Active renderer
OpenGL
(Formatted with AI assistance and verified against C++ engine source)
Goal
Allow the local player's body and attached entities (custom player rigs/proxies, armor, accessories) to cast dynamic shadows in first-person view (CAMERA_MODE_FIRST), matching third-person view.
Problem / Current Inconsistency
With dynamic shadows enabled (enable_dynamic_shadows = true):
- In third-person view (
F5), the player body, attachments, and wielded items cast dynamic shadows normally. - In first-person view, the body casts no shadow at all.
- Furthermore, there is an inconsistency with attachments: if a wielditem entity is attached to a body proxy entity (which is attached to the player), the wielditem does cast a shadow in first person, while the body entity itself does not, leaving a floating item shadow on the ground.
Technical Causes in src/client/content_cao.cpp
Native LocalPlayer Mesh: In
GenericCAO::updateMeshCulling(), the engine hides the player from the first-person camera by enabling both frontface and backface culling (mat.BackfaceCulling = true; mat.FrontfaceCulling = true;). This discards 100% of triangles on the GPU during rasterization, preventing depth from being written to the shadow map pass.Attached Entities (Proxies / Armor / Accessories): In
GenericCAO::step(), attached objects withm_attached_to_local == trueare hidden vianode->setVisible(false). Irrlicht removes invisible nodes from scene graph traversal entirely, skipping them during the shadow map pass (dynamicshadowsrender.cpp).The Attachment Inconsistency:
GenericCAO::updateAttachments()only checksparent->isLocalPlayer(). For nested attachments (item -> body proxy -> player), the child entity hasparent->isLocalPlayer() == falseand keepsnode->setVisible(true), allowing it to cast shadows while the parent body proxy is culled.
Proposed Solution
Decouple first-person camera view frustum culling from the directional light shadow map depth pass:
- The shadow map pass (which renders from the sun/light's perspective) should include the local player and its attachments using standard backface culling.
- The player's first-person view camera should continue to cull them to prevent mesh clipping into the viewport.
Steps to reproduce
- Enable dynamic shadows in minetest.conf / luanti.conf (
enable_dynamic_shadows = true). - Attach a body model entity to the player: local body = minetest.add_entity(player:get_pos(), "mod:player_body") body:set_attach(player, "", {x=0, y=0, z=0}, {x=0, y=0, z=0}, false)
- Attach a wielditem entity to a bone of that body entity: local wield = minetest.add_entity(player:get_pos(), "mod:wield_item") wield:set_attach(body, "Arm_R", {x=0, y=0, z=0}, {x=0, y=0, z=0}, false)
- Look at the ground outside in sunlight in third person: Both the body entity and the wielditem entity cast shadows as expected.
- Switch to first-person view:
- Actual result: Only the wielditem entity casts a shadow; the body entity shadow completely vanishes.
- Expected / Desired result: Both the body entity and wielditem entity should cast dynamic shadows on the ground in first-person view.
Source: luanti-org/luanti