forked from Mirrorlandia_minetest/minetest
Render shadows on entities.
Fixes problem with mod 'drawers'.
This commit is contained in:
parent
b9e886726c
commit
2bba53b2c3
@ -1322,6 +1322,12 @@ void GenericCAO::updateTextures(std::string mod)
|
|||||||
m_current_texture_modifier = mod;
|
m_current_texture_modifier = mod;
|
||||||
m_glow = m_prop.glow;
|
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_spritenode) {
|
||||||
if (m_prop.visual == "sprite") {
|
if (m_prop.visual == "sprite") {
|
||||||
std::string texturestring = "no_texture.png";
|
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->getMaterial(0).MaterialTypeParam = 0.5f;
|
||||||
m_spritenode->setMaterialTexture(0,
|
m_spritenode->setMaterialTexture(0,
|
||||||
tsrc->getTextureForMesh(texturestring));
|
tsrc->getTextureForMesh(texturestring));
|
||||||
|
m_spritenode->setMaterialTexture(TEXTURE_LAYER_SHADOW, shadow_texture);
|
||||||
|
|
||||||
// This allows setting per-material colors. However, until a real lighting
|
// This allows setting per-material colors. However, until a real lighting
|
||||||
// system is added, the code below will have no effect. Once MineTest
|
// 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.MaterialType = m_material_type;
|
||||||
material.MaterialTypeParam = 0.5f;
|
material.MaterialTypeParam = 0.5f;
|
||||||
material.TextureLayer[0].Texture = texture;
|
material.TextureLayer[0].Texture = texture;
|
||||||
|
material.TextureLayer[TEXTURE_LAYER_SHADOW].Texture = shadow_texture;
|
||||||
material.setFlag(video::EMF_LIGHTING, true);
|
material.setFlag(video::EMF_LIGHTING, true);
|
||||||
material.setFlag(video::EMF_BILINEAR_FILTER, false);
|
material.setFlag(video::EMF_BILINEAR_FILTER, false);
|
||||||
material.setFlag(video::EMF_BACK_FACE_CULLING, m_prop.backface_culling);
|
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.setFlag(video::EMF_BILINEAR_FILTER, false);
|
||||||
material.setTexture(0,
|
material.setTexture(0,
|
||||||
tsrc->getTextureForMesh(texturestring));
|
tsrc->getTextureForMesh(texturestring));
|
||||||
|
material.setTexture(TEXTURE_LAYER_SHADOW, shadow_texture);
|
||||||
material.getTextureMatrix(0).makeIdentity();
|
material.getTextureMatrix(0).makeIdentity();
|
||||||
|
|
||||||
// This allows setting per-material colors. However, until a real lighting
|
// 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);
|
scene::IMeshBuffer *buf = mesh->getMeshBuffer(0);
|
||||||
buf->getMaterial().setTexture(0,
|
buf->getMaterial().setTexture(0,
|
||||||
tsrc->getTextureForMesh(tname));
|
tsrc->getTextureForMesh(tname));
|
||||||
|
buf->getMaterial().setTexture(TEXTURE_LAYER_SHADOW, shadow_texture);
|
||||||
|
|
||||||
// This allows setting per-material colors. However, until a real lighting
|
// This allows setting per-material colors. However, until a real lighting
|
||||||
// system is added, the code below will have no effect. Once MineTest
|
// 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);
|
scene::IMeshBuffer *buf = mesh->getMeshBuffer(1);
|
||||||
buf->getMaterial().setTexture(0,
|
buf->getMaterial().setTexture(0,
|
||||||
tsrc->getTextureForMesh(tname));
|
tsrc->getTextureForMesh(tname));
|
||||||
|
buf->getMaterial().setTexture(TEXTURE_LAYER_SHADOW, shadow_texture);
|
||||||
|
|
||||||
// This allows setting per-material colors. However, until a real lighting
|
// This allows setting per-material colors. However, until a real lighting
|
||||||
// system is added, the code below will have no effect. Once MineTest
|
// system is added, the code below will have no effect. Once MineTest
|
||||||
|
Loading…
Reference in New Issue
Block a user