mirror of
https://github.com/minetest/minetest.git
synced 2024-12-22 14:12:24 +01:00
Fix CAO mesh lighting with shaders disabled
the 'Lighting' material flag does not have portable behavior
This commit is contained in:
parent
740dc0162e
commit
65af606729
@ -186,6 +186,12 @@ static bool logOnce(const std::ostringstream &from, std::ostream &log_to)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void setEmissiveColor(scene::ISceneNode *node, video::SColor color)
|
||||||
|
{
|
||||||
|
for (u32 i = 0; i < node->getMaterialCount(); ++i)
|
||||||
|
node->getMaterial(i).EmissiveColor = color;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
TestCAO
|
TestCAO
|
||||||
*/
|
*/
|
||||||
@ -774,8 +780,6 @@ void GenericCAO::addToScene(ITextureSource *tsrc, scene::ISceneManager *smgr)
|
|||||||
// set vertex colors to ensure alpha is set
|
// set vertex colors to ensure alpha is set
|
||||||
setMeshColor(m_animated_meshnode->getMesh(), video::SColor(0xFFFFFFFF));
|
setMeshColor(m_animated_meshnode->getMesh(), video::SColor(0xFFFFFFFF));
|
||||||
|
|
||||||
setAnimatedMeshColor(m_animated_meshnode, video::SColor(0xFFFFFFFF));
|
|
||||||
|
|
||||||
setSceneNodeMaterials(m_animated_meshnode);
|
setSceneNodeMaterials(m_animated_meshnode);
|
||||||
|
|
||||||
m_animated_meshnode->forEachMaterial([this] (auto &mat) {
|
m_animated_meshnode->forEachMaterial([this] (auto &mat) {
|
||||||
@ -923,26 +927,15 @@ void GenericCAO::setNodeLight(const video::SColor &light_color)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (m_enable_shaders) {
|
if (m_enable_shaders) {
|
||||||
if (m_prop.visual == "upright_sprite") {
|
auto *node = getSceneNode();
|
||||||
if (!m_meshnode)
|
|
||||||
return;
|
|
||||||
for (u32 i = 0; i < m_meshnode->getMaterialCount(); ++i)
|
|
||||||
m_meshnode->getMaterial(i).EmissiveColor = light_color;
|
|
||||||
} else {
|
|
||||||
scene::ISceneNode *node = getSceneNode();
|
|
||||||
if (!node)
|
if (!node)
|
||||||
return;
|
return;
|
||||||
|
setEmissiveColor(node, light_color);
|
||||||
for (u32 i = 0; i < node->getMaterialCount(); ++i) {
|
|
||||||
video::SMaterial &material = node->getMaterial(i);
|
|
||||||
material.EmissiveColor = light_color;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (m_meshnode) {
|
if (m_meshnode) {
|
||||||
setMeshColor(m_meshnode->getMesh(), light_color);
|
setMeshColor(m_meshnode->getMesh(), light_color);
|
||||||
} else if (m_animated_meshnode) {
|
} else if (m_animated_meshnode) {
|
||||||
setAnimatedMeshColor(m_animated_meshnode, light_color);
|
setMeshColor(m_animated_meshnode->getMesh(), light_color);
|
||||||
} else if (m_spritenode) {
|
} else if (m_spritenode) {
|
||||||
m_spritenode->setColor(light_color);
|
m_spritenode->setColor(light_color);
|
||||||
}
|
}
|
||||||
@ -1404,7 +1397,6 @@ void GenericCAO::updateTextures(std::string mod)
|
|||||||
material.MaterialType = m_material_type;
|
material.MaterialType = m_material_type;
|
||||||
material.MaterialTypeParam = m_material_type_param;
|
material.MaterialTypeParam = m_material_type_param;
|
||||||
material.TextureLayers[0].Texture = texture;
|
material.TextureLayers[0].Texture = texture;
|
||||||
material.Lighting = true;
|
|
||||||
material.BackfaceCulling = m_prop.backface_culling;
|
material.BackfaceCulling = m_prop.backface_culling;
|
||||||
|
|
||||||
// don't filter low-res textures, makes them look blurry
|
// don't filter low-res textures, makes them look blurry
|
||||||
|
@ -181,13 +181,6 @@ void setMeshBufferColor(scene::IMeshBuffer *buf, const video::SColor &color)
|
|||||||
((video::S3DVertex *) (vertices + i * stride))->Color = color;
|
((video::S3DVertex *) (vertices + i * stride))->Color = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setAnimatedMeshColor(scene::IAnimatedMeshSceneNode *node, const video::SColor &color)
|
|
||||||
{
|
|
||||||
for (u32 i = 0; i < node->getMaterialCount(); ++i) {
|
|
||||||
node->getMaterial(i).EmissiveColor = color;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void setMeshColor(scene::IMesh *mesh, const video::SColor &color)
|
void setMeshColor(scene::IMesh *mesh, const video::SColor &color)
|
||||||
{
|
{
|
||||||
if (mesh == NULL)
|
if (mesh == NULL)
|
||||||
|
@ -59,11 +59,6 @@ void setMeshBufferColor(scene::IMeshBuffer *buf, const video::SColor &color);
|
|||||||
*/
|
*/
|
||||||
void setMeshColor(scene::IMesh *mesh, const video::SColor &color);
|
void setMeshColor(scene::IMesh *mesh, const video::SColor &color);
|
||||||
|
|
||||||
/*
|
|
||||||
Set a constant color for an animated mesh
|
|
||||||
*/
|
|
||||||
void setAnimatedMeshColor(scene::IAnimatedMeshSceneNode *node, const video::SColor &color);
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Overwrites the color of a mesh buffer.
|
* Overwrites the color of a mesh buffer.
|
||||||
* The color is darkened based on the normal vector of the vertices.
|
* The color is darkened based on the normal vector of the vertices.
|
||||||
|
Loading…
Reference in New Issue
Block a user