From 2bba53b2c3f0045c326f6c7578104ffaef53ceac Mon Sep 17 00:00:00 2001 From: Dmitry Kostenko Date: Mon, 1 Nov 2021 01:51:17 +0100 Subject: [PATCH] Render shadows on entities. Fixes problem with mod 'drawers'. --- src/client/content_cao.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/client/content_cao.cpp b/src/client/content_cao.cpp index 1d4636a08..03a2ee830 100644 --- a/src/client/content_cao.cpp +++ b/src/client/content_cao.cpp @@ -1322,6 +1322,12 @@ void GenericCAO::updateTextures(std::string mod) m_current_texture_modifier = mod; m_glow = m_prop.glow; + video::ITexture *shadow_texture = nullptr; + if (auto shadow = RenderingEngine::get_shadow_renderer()) + shadow_texture = shadow->get_texture(); + + const u32 TEXTURE_LAYER_SHADOW = 3; + if (m_spritenode) { if (m_prop.visual == "sprite") { std::string texturestring = "no_texture.png"; @@ -1332,6 +1338,7 @@ void GenericCAO::updateTextures(std::string mod) m_spritenode->getMaterial(0).MaterialTypeParam = 0.5f; m_spritenode->setMaterialTexture(0, tsrc->getTextureForMesh(texturestring)); + m_spritenode->setMaterialTexture(TEXTURE_LAYER_SHADOW, shadow_texture); // This allows setting per-material colors. However, until a real lighting // system is added, the code below will have no effect. Once MineTest @@ -1367,6 +1374,7 @@ void GenericCAO::updateTextures(std::string mod) material.MaterialType = m_material_type; material.MaterialTypeParam = 0.5f; material.TextureLayer[0].Texture = texture; + material.TextureLayer[TEXTURE_LAYER_SHADOW].Texture = shadow_texture; material.setFlag(video::EMF_LIGHTING, true); material.setFlag(video::EMF_BILINEAR_FILTER, false); material.setFlag(video::EMF_BACK_FACE_CULLING, m_prop.backface_culling); @@ -1417,6 +1425,7 @@ void GenericCAO::updateTextures(std::string mod) material.setFlag(video::EMF_BILINEAR_FILTER, false); material.setTexture(0, tsrc->getTextureForMesh(texturestring)); + material.setTexture(TEXTURE_LAYER_SHADOW, shadow_texture); material.getTextureMatrix(0).makeIdentity(); // This allows setting per-material colors. However, until a real lighting @@ -1443,6 +1452,7 @@ void GenericCAO::updateTextures(std::string mod) scene::IMeshBuffer *buf = mesh->getMeshBuffer(0); buf->getMaterial().setTexture(0, tsrc->getTextureForMesh(tname)); + buf->getMaterial().setTexture(TEXTURE_LAYER_SHADOW, shadow_texture); // This allows setting per-material colors. However, until a real lighting // system is added, the code below will have no effect. Once MineTest @@ -1467,6 +1477,7 @@ void GenericCAO::updateTextures(std::string mod) scene::IMeshBuffer *buf = mesh->getMeshBuffer(1); buf->getMaterial().setTexture(0, tsrc->getTextureForMesh(tname)); + buf->getMaterial().setTexture(TEXTURE_LAYER_SHADOW, shadow_texture); // This allows setting per-material colors. However, until a real lighting // system is added, the code below will have no effect. Once MineTest