aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDmitry Kostenko <codeforsmile@gmail.com>2021-11-01 01:51:17 +0100
committerx2048 <codeforsmile@gmail.com>2022-03-07 23:45:26 +0100
commit2bba53b2c3f0045c326f6c7578104ffaef53ceac (patch)
tree27c13c09d18fa5c10225eab6fb8ea727b9eedacf /src
parentb9e886726c68613d39459acc8cb1a2f663b0362c (diff)
downloadhax-minetest-server-2bba53b2c3f0045c326f6c7578104ffaef53ceac.tar.gz
hax-minetest-server-2bba53b2c3f0045c326f6c7578104ffaef53ceac.zip
Render shadows on entities.
Fixes problem with mod 'drawers'.
Diffstat (limited to 'src')
-rw-r--r--src/client/content_cao.cpp11
1 files changed, 11 insertions, 0 deletions
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