forked from Mirrorlandia_minetest/minetest
Refactor the way you set material properties
Instead of using SMaterial::setFlag, you now set them directly on SMaterial or SMaterialLayer.
This commit is contained in:
parent
128d22e6ee
commit
307e380f30
@ -842,14 +842,12 @@ void ClientMap::renderMap(video::IVideoDriver* driver, s32 pass)
|
||||
auto &material = buf->getMaterial();
|
||||
|
||||
// Apply filter settings
|
||||
material.setFlag(video::EMF_TRILINEAR_FILTER,
|
||||
m_cache_trilinear_filter);
|
||||
material.setFlag(video::EMF_BILINEAR_FILTER,
|
||||
m_cache_bilinear_filter);
|
||||
material.setFlag(video::EMF_ANISOTROPIC_FILTER,
|
||||
m_cache_anistropic_filter);
|
||||
material.setFlag(video::EMF_WIREFRAME,
|
||||
m_control.show_wireframe);
|
||||
material.forEachTexture([this] (video::SMaterialLayer &tex) {
|
||||
tex.TrilinearFilter = m_cache_trilinear_filter;
|
||||
tex.BilinearFilter = m_cache_trilinear_filter;
|
||||
tex.AnisotropicFilter = m_cache_anistropic_filter ? 0xFF : 0;
|
||||
});
|
||||
material.Wireframe = m_control.show_wireframe;
|
||||
|
||||
// pass the shadow map texture to the buffer texture
|
||||
ShadowRenderer *shadow = m_rendering_engine->get_shadow_renderer();
|
||||
|
@ -47,14 +47,14 @@ Clouds::Clouds(scene::ISceneManager* mgr,
|
||||
scene::ISceneNode(mgr->getRootSceneNode(), mgr, id),
|
||||
m_seed(seed)
|
||||
{
|
||||
m_material.setFlag(video::EMF_LIGHTING, false);
|
||||
//m_material.setFlag(video::EMF_BACK_FACE_CULLING, false);
|
||||
m_material.setFlag(video::EMF_BACK_FACE_CULLING, true);
|
||||
m_material.setFlag(video::EMF_BILINEAR_FILTER, false);
|
||||
m_material.setFlag(video::EMF_FOG_ENABLE, true);
|
||||
m_material.setFlag(video::EMF_ANTI_ALIASING, true);
|
||||
//m_material.MaterialType = video::EMT_TRANSPARENT_VERTEX_ALPHA;
|
||||
m_material.Lighting = false;
|
||||
m_material.BackfaceCulling = true;
|
||||
m_material.FogEnable = true;
|
||||
m_material.AntiAliasing = video::EAAM_SIMPLE;
|
||||
m_material.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
|
||||
m_material.forEachTexture([] (video::SMaterialLayer &tex) {
|
||||
tex.BilinearFilter = false;
|
||||
});
|
||||
|
||||
m_params.height = 120;
|
||||
m_params.density = 0.4f;
|
||||
@ -103,7 +103,7 @@ void Clouds::render()
|
||||
|
||||
int num_faces_to_draw = m_enable_3d ? 6 : 1;
|
||||
|
||||
m_material.setFlag(video::EMF_BACK_FACE_CULLING, m_enable_3d);
|
||||
m_material.BackfaceCulling = m_enable_3d;
|
||||
|
||||
driver->setTransform(video::ETS_WORLD, AbsoluteTransformation);
|
||||
driver->setMaterial(m_material);
|
||||
|
@ -252,11 +252,11 @@ void TestCAO::addToScene(ITextureSource *tsrc, scene::ISceneManager *smgr)
|
||||
u16 indices[] = {0,1,2,2,3,0};
|
||||
buf->append(vertices, 4, indices, 6);
|
||||
// Set material
|
||||
buf->getMaterial().setFlag(video::EMF_LIGHTING, false);
|
||||
buf->getMaterial().setFlag(video::EMF_BACK_FACE_CULLING, false);
|
||||
buf->getMaterial().Lighting = false;
|
||||
buf->getMaterial().BackfaceCulling = false;
|
||||
buf->getMaterial().setTexture(0, tsrc->getTextureForMesh("rat.png"));
|
||||
buf->getMaterial().setFlag(video::EMF_BILINEAR_FILTER, false);
|
||||
buf->getMaterial().setFlag(video::EMF_FOG_ENABLE, true);
|
||||
buf->getMaterial().TextureLayer[0].BilinearFilter = false;
|
||||
buf->getMaterial().FogEnable = true;
|
||||
buf->getMaterial().MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
|
||||
// Add to mesh
|
||||
mesh->addMeshBuffer(buf);
|
||||
@ -643,16 +643,21 @@ void GenericCAO::addToScene(ITextureSource *tsrc, scene::ISceneManager *smgr)
|
||||
m_matrixnode->grab();
|
||||
};
|
||||
|
||||
auto setSceneNodeMaterial = [this] (scene::ISceneNode *node) {
|
||||
node->setMaterialFlag(video::EMF_LIGHTING, false);
|
||||
node->setMaterialFlag(video::EMF_BILINEAR_FILTER, false);
|
||||
node->setMaterialFlag(video::EMF_FOG_ENABLE, true);
|
||||
node->setMaterialType(m_material_type);
|
||||
|
||||
auto setMaterial = [this] (video::SMaterial &mat) {
|
||||
mat.MaterialType = m_material_type;
|
||||
mat.Lighting = false;
|
||||
mat.FogEnable = true;
|
||||
if (m_enable_shaders) {
|
||||
node->setMaterialFlag(video::EMF_GOURAUD_SHADING, false);
|
||||
node->setMaterialFlag(video::EMF_NORMALIZE_NORMALS, true);
|
||||
mat.GouraudShading = false;
|
||||
mat.NormalizeNormals = true;
|
||||
}
|
||||
mat.forEachTexture([] (video::SMaterialLayer &tex) {
|
||||
tex.BilinearFilter = false;
|
||||
});
|
||||
};
|
||||
|
||||
auto setSceneNodeMaterials = [setMaterial] (scene::ISceneNode *node) {
|
||||
node->forEachMaterial(setMaterial);
|
||||
};
|
||||
|
||||
if (m_prop.visual == "sprite") {
|
||||
@ -660,10 +665,12 @@ void GenericCAO::addToScene(ITextureSource *tsrc, scene::ISceneManager *smgr)
|
||||
m_spritenode = m_smgr->addBillboardSceneNode(
|
||||
m_matrixnode, v2f(1, 1), v3f(0,0,0), -1);
|
||||
m_spritenode->grab();
|
||||
m_spritenode->setMaterialTexture(0,
|
||||
tsrc->getTextureForMesh("no_texture.png"));
|
||||
video::ITexture *tex = tsrc->getTextureForMesh("no_texture.png");
|
||||
m_spritenode->forEachMaterial([tex] (video::SMaterial &mat) {
|
||||
mat.setTexture(0, tex);
|
||||
});
|
||||
|
||||
setSceneNodeMaterial(m_spritenode);
|
||||
setSceneNodeMaterials(m_spritenode);
|
||||
|
||||
m_spritenode->setSize(v2f(m_prop.visual_size.X,
|
||||
m_prop.visual_size.Y) * BS);
|
||||
@ -695,16 +702,11 @@ void GenericCAO::addToScene(ITextureSource *tsrc, scene::ISceneManager *smgr)
|
||||
}
|
||||
u16 indices[] = {0,1,2,2,3,0};
|
||||
buf->append(vertices, 4, indices, 6);
|
||||
// Set material
|
||||
buf->getMaterial().setFlag(video::EMF_LIGHTING, false);
|
||||
buf->getMaterial().setFlag(video::EMF_BILINEAR_FILTER, false);
|
||||
buf->getMaterial().setFlag(video::EMF_FOG_ENABLE, true);
|
||||
buf->getMaterial().MaterialType = m_material_type;
|
||||
|
||||
// Set material
|
||||
setMaterial(buf->getMaterial());
|
||||
if (m_enable_shaders) {
|
||||
buf->getMaterial().EmissiveColor = c;
|
||||
buf->getMaterial().setFlag(video::EMF_GOURAUD_SHADING, false);
|
||||
buf->getMaterial().setFlag(video::EMF_NORMALIZE_NORMALS, true);
|
||||
}
|
||||
|
||||
// Add to mesh
|
||||
@ -726,16 +728,11 @@ void GenericCAO::addToScene(ITextureSource *tsrc, scene::ISceneManager *smgr)
|
||||
}
|
||||
u16 indices[] = {0,1,2,2,3,0};
|
||||
buf->append(vertices, 4, indices, 6);
|
||||
// Set material
|
||||
buf->getMaterial().setFlag(video::EMF_LIGHTING, false);
|
||||
buf->getMaterial().setFlag(video::EMF_BILINEAR_FILTER, false);
|
||||
buf->getMaterial().setFlag(video::EMF_FOG_ENABLE, true);
|
||||
buf->getMaterial().MaterialType = m_material_type;
|
||||
|
||||
// Set material
|
||||
setMaterial(buf->getMaterial());
|
||||
if (m_enable_shaders) {
|
||||
buf->getMaterial().EmissiveColor = c;
|
||||
buf->getMaterial().setFlag(video::EMF_GOURAUD_SHADING, false);
|
||||
buf->getMaterial().setFlag(video::EMF_NORMALIZE_NORMALS, true);
|
||||
}
|
||||
|
||||
// Add to mesh
|
||||
@ -753,10 +750,12 @@ void GenericCAO::addToScene(ITextureSource *tsrc, scene::ISceneManager *smgr)
|
||||
mesh->drop();
|
||||
|
||||
m_meshnode->setScale(m_prop.visual_size);
|
||||
m_meshnode->setMaterialFlag(video::EMF_BACK_FACE_CULLING,
|
||||
m_prop.backface_culling);
|
||||
|
||||
setSceneNodeMaterial(m_meshnode);
|
||||
setSceneNodeMaterials(m_meshnode);
|
||||
|
||||
m_meshnode->forEachMaterial([this] (video::SMaterial &mat) {
|
||||
mat.BackfaceCulling = m_prop.backface_culling;
|
||||
});
|
||||
} else if (m_prop.visual == "mesh") {
|
||||
grabMatrixNode();
|
||||
scene::IAnimatedMesh *mesh = m_client->getMesh(m_prop.mesh, true);
|
||||
@ -779,10 +778,11 @@ void GenericCAO::addToScene(ITextureSource *tsrc, scene::ISceneManager *smgr)
|
||||
|
||||
setAnimatedMeshColor(m_animated_meshnode, video::SColor(0xFFFFFFFF));
|
||||
|
||||
setSceneNodeMaterial(m_animated_meshnode);
|
||||
setSceneNodeMaterials(m_animated_meshnode);
|
||||
|
||||
m_animated_meshnode->setMaterialFlag(video::EMF_BACK_FACE_CULLING,
|
||||
m_prop.backface_culling);
|
||||
m_animated_meshnode->forEachMaterial([this] (video::SMaterial &mat) {
|
||||
mat.BackfaceCulling = m_prop.backface_culling;
|
||||
});
|
||||
} else
|
||||
errorstream<<"GenericCAO::addToScene(): Could not load mesh "<<m_prop.mesh<<std::endl;
|
||||
} else if (m_prop.visual == "wielditem" || m_prop.visual == "item") {
|
||||
@ -1337,23 +1337,26 @@ void GenericCAO::updateTextures(std::string mod)
|
||||
if (!m_prop.textures.empty())
|
||||
texturestring = m_prop.textures[0];
|
||||
texturestring += mod;
|
||||
m_spritenode->getMaterial(0).MaterialType = m_material_type;
|
||||
m_spritenode->getMaterial(0).MaterialTypeParam = 0.5f;
|
||||
m_spritenode->setMaterialTexture(0,
|
||||
tsrc->getTextureForMesh(texturestring));
|
||||
|
||||
video::SMaterial &material = m_spritenode->getMaterial(0);
|
||||
material.MaterialType = m_material_type;
|
||||
material.MaterialTypeParam = 0.5f;
|
||||
material.setTexture(0, tsrc->getTextureForMesh(texturestring));
|
||||
|
||||
// This allows setting per-material colors. However, until a real lighting
|
||||
// system is added, the code below will have no effect. Once MineTest
|
||||
// has directional lighting, it should work automatically.
|
||||
if (!m_prop.colors.empty()) {
|
||||
m_spritenode->getMaterial(0).AmbientColor = m_prop.colors[0];
|
||||
m_spritenode->getMaterial(0).DiffuseColor = m_prop.colors[0];
|
||||
m_spritenode->getMaterial(0).SpecularColor = m_prop.colors[0];
|
||||
material.AmbientColor = m_prop.colors[0];
|
||||
material.DiffuseColor = m_prop.colors[0];
|
||||
material.SpecularColor = m_prop.colors[0];
|
||||
}
|
||||
|
||||
m_spritenode->getMaterial(0).setFlag(video::EMF_TRILINEAR_FILTER, use_trilinear_filter);
|
||||
m_spritenode->getMaterial(0).setFlag(video::EMF_BILINEAR_FILTER, use_bilinear_filter);
|
||||
m_spritenode->getMaterial(0).setFlag(video::EMF_ANISOTROPIC_FILTER, use_anisotropic_filter);
|
||||
material.forEachTexture([=] (video::SMaterialLayer &tex) {
|
||||
tex.TrilinearFilter = use_trilinear_filter;
|
||||
tex.BilinearFilter = use_bilinear_filter;
|
||||
tex.AnisotropicFilter = use_anisotropic_filter ? 0xFF : 0;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -1365,20 +1368,19 @@ void GenericCAO::updateTextures(std::string mod)
|
||||
if (texturestring.empty())
|
||||
continue; // Empty texture string means don't modify that material
|
||||
texturestring += mod;
|
||||
video::ITexture* texture = tsrc->getTextureForMesh(texturestring);
|
||||
video::ITexture *texture = tsrc->getTextureForMesh(texturestring);
|
||||
if (!texture) {
|
||||
errorstream<<"GenericCAO::updateTextures(): Could not load texture "<<texturestring<<std::endl;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Set material flags and texture
|
||||
video::SMaterial& material = m_animated_meshnode->getMaterial(i);
|
||||
video::SMaterial &material = m_animated_meshnode->getMaterial(i);
|
||||
material.MaterialType = m_material_type;
|
||||
material.MaterialTypeParam = 0.5f;
|
||||
material.TextureLayer[0].Texture = 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);
|
||||
material.Lighting = true;
|
||||
material.BackfaceCulling = m_prop.backface_culling;
|
||||
|
||||
// don't filter low-res textures, makes them look blurry
|
||||
// player models have a res of 64
|
||||
@ -1387,22 +1389,22 @@ void GenericCAO::updateTextures(std::string mod)
|
||||
use_trilinear_filter &= res > 64;
|
||||
use_bilinear_filter &= res > 64;
|
||||
|
||||
m_animated_meshnode->getMaterial(i)
|
||||
.setFlag(video::EMF_TRILINEAR_FILTER, use_trilinear_filter);
|
||||
m_animated_meshnode->getMaterial(i)
|
||||
.setFlag(video::EMF_BILINEAR_FILTER, use_bilinear_filter);
|
||||
m_animated_meshnode->getMaterial(i)
|
||||
.setFlag(video::EMF_ANISOTROPIC_FILTER, use_anisotropic_filter);
|
||||
material.forEachTexture([=] (video::SMaterialLayer &tex) {
|
||||
tex.TrilinearFilter = use_trilinear_filter;
|
||||
tex.BilinearFilter = use_bilinear_filter;
|
||||
tex.AnisotropicFilter = use_anisotropic_filter ? 0xFF : 0;
|
||||
});
|
||||
}
|
||||
for (u32 i = 0; i < m_prop.colors.size() &&
|
||||
i < m_animated_meshnode->getMaterialCount(); ++i)
|
||||
i < m_animated_meshnode->getMaterialCount(); ++i)
|
||||
{
|
||||
video::SMaterial &material = m_animated_meshnode->getMaterial(i);
|
||||
// This allows setting per-material colors. However, until a real lighting
|
||||
// system is added, the code below will have no effect. Once MineTest
|
||||
// has directional lighting, it should work automatically.
|
||||
m_animated_meshnode->getMaterial(i).AmbientColor = m_prop.colors[i];
|
||||
m_animated_meshnode->getMaterial(i).DiffuseColor = m_prop.colors[i];
|
||||
m_animated_meshnode->getMaterial(i).SpecularColor = m_prop.colors[i];
|
||||
material.AmbientColor = m_prop.colors[i];
|
||||
material.DiffuseColor = m_prop.colors[i];
|
||||
material.SpecularColor = m_prop.colors[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1417,15 +1419,12 @@ void GenericCAO::updateTextures(std::string mod)
|
||||
texturestring = m_prop.textures[i];
|
||||
texturestring += mod;
|
||||
|
||||
|
||||
// Set material flags and texture
|
||||
video::SMaterial& material = m_meshnode->getMaterial(i);
|
||||
video::SMaterial &material = m_meshnode->getMaterial(i);
|
||||
material.MaterialType = m_material_type;
|
||||
material.MaterialTypeParam = 0.5f;
|
||||
material.setFlag(video::EMF_LIGHTING, false);
|
||||
material.setFlag(video::EMF_BILINEAR_FILTER, false);
|
||||
material.setTexture(0,
|
||||
tsrc->getTextureForMesh(texturestring));
|
||||
material.Lighting = false;
|
||||
material.setTexture(0, tsrc->getTextureForMesh(texturestring));
|
||||
material.getTextureMatrix(0).makeIdentity();
|
||||
|
||||
// This allows setting per-material colors. However, until a real lighting
|
||||
@ -1433,14 +1432,16 @@ void GenericCAO::updateTextures(std::string mod)
|
||||
// has directional lighting, it should work automatically.
|
||||
if(m_prop.colors.size() > i)
|
||||
{
|
||||
m_meshnode->getMaterial(i).AmbientColor = m_prop.colors[i];
|
||||
m_meshnode->getMaterial(i).DiffuseColor = m_prop.colors[i];
|
||||
m_meshnode->getMaterial(i).SpecularColor = m_prop.colors[i];
|
||||
material.AmbientColor = m_prop.colors[i];
|
||||
material.DiffuseColor = m_prop.colors[i];
|
||||
material.SpecularColor = m_prop.colors[i];
|
||||
}
|
||||
|
||||
m_meshnode->getMaterial(i).setFlag(video::EMF_TRILINEAR_FILTER, use_trilinear_filter);
|
||||
m_meshnode->getMaterial(i).setFlag(video::EMF_BILINEAR_FILTER, use_bilinear_filter);
|
||||
m_meshnode->getMaterial(i).setFlag(video::EMF_ANISOTROPIC_FILTER, use_anisotropic_filter);
|
||||
material.forEachTexture([=] (video::SMaterialLayer &tex) {
|
||||
tex.TrilinearFilter = use_trilinear_filter;
|
||||
tex.BilinearFilter = use_bilinear_filter;
|
||||
tex.AnisotropicFilter = use_anisotropic_filter ? 0xFF : 0;
|
||||
});
|
||||
}
|
||||
} else if (m_prop.visual == "upright_sprite") {
|
||||
scene::IMesh *mesh = m_meshnode->getMesh();
|
||||
@ -1449,9 +1450,9 @@ void GenericCAO::updateTextures(std::string mod)
|
||||
if (!m_prop.textures.empty())
|
||||
tname = m_prop.textures[0];
|
||||
tname += mod;
|
||||
auto& material = m_meshnode->getMaterial(0);
|
||||
material.setTexture(0,
|
||||
tsrc->getTextureForMesh(tname));
|
||||
|
||||
auto &material = m_meshnode->getMaterial(0);
|
||||
material.setTexture(0, tsrc->getTextureForMesh(tname));
|
||||
|
||||
// This allows setting per-material colors. However, until a real lighting
|
||||
// system is added, the code below will have no effect. Once MineTest
|
||||
@ -1462,9 +1463,11 @@ void GenericCAO::updateTextures(std::string mod)
|
||||
material.SpecularColor = m_prop.colors[0];
|
||||
}
|
||||
|
||||
material.setFlag(video::EMF_TRILINEAR_FILTER, use_trilinear_filter);
|
||||
material.setFlag(video::EMF_BILINEAR_FILTER, use_bilinear_filter);
|
||||
material.setFlag(video::EMF_ANISOTROPIC_FILTER, use_anisotropic_filter);
|
||||
material.forEachTexture([=] (video::SMaterialLayer &tex) {
|
||||
tex.TrilinearFilter = use_trilinear_filter;
|
||||
tex.BilinearFilter = use_bilinear_filter;
|
||||
tex.AnisotropicFilter = use_anisotropic_filter ? 0xFF : 0;
|
||||
});
|
||||
}
|
||||
{
|
||||
std::string tname = "no_texture.png";
|
||||
@ -1473,9 +1476,9 @@ void GenericCAO::updateTextures(std::string mod)
|
||||
else if (!m_prop.textures.empty())
|
||||
tname = m_prop.textures[0];
|
||||
tname += mod;
|
||||
auto& material = m_meshnode->getMaterial(1);
|
||||
material.setTexture(0,
|
||||
tsrc->getTextureForMesh(tname));
|
||||
|
||||
auto &material = m_meshnode->getMaterial(1);
|
||||
material.setTexture(0, tsrc->getTextureForMesh(tname));
|
||||
|
||||
// This allows setting per-material colors. However, until a real lighting
|
||||
// system is added, the code below will have no effect. Once MineTest
|
||||
@ -1490,9 +1493,11 @@ void GenericCAO::updateTextures(std::string mod)
|
||||
material.SpecularColor = m_prop.colors[0];
|
||||
}
|
||||
|
||||
material.setFlag(video::EMF_TRILINEAR_FILTER, use_trilinear_filter);
|
||||
material.setFlag(video::EMF_BILINEAR_FILTER, use_bilinear_filter);
|
||||
material.setFlag(video::EMF_ANISOTROPIC_FILTER, use_anisotropic_filter);
|
||||
material.forEachTexture([=] (video::SMaterialLayer &tex) {
|
||||
tex.TrilinearFilter = use_trilinear_filter;
|
||||
tex.BilinearFilter = use_bilinear_filter;
|
||||
tex.AnisotropicFilter = use_anisotropic_filter ? 0xFF : 0;
|
||||
});
|
||||
}
|
||||
// Set mesh color (only if lighting is disabled)
|
||||
if (!m_prop.colors.empty() && m_prop.glow < 0)
|
||||
@ -1975,7 +1980,9 @@ void GenericCAO::updateMeshCulling()
|
||||
|
||||
if (m_prop.visual == "upright_sprite") {
|
||||
// upright sprite has no backface culling
|
||||
node->setMaterialFlag(video::EMF_FRONT_FACE_CULLING, hidden);
|
||||
node->forEachMaterial([=] (video::SMaterial &mat) {
|
||||
mat.FrontfaceCulling = hidden;
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1983,16 +1990,16 @@ void GenericCAO::updateMeshCulling()
|
||||
// Hide the mesh by culling both front and
|
||||
// back faces. Serious hackyness but it works for our
|
||||
// purposes. This also preserves the skeletal armature.
|
||||
node->setMaterialFlag(video::EMF_BACK_FACE_CULLING,
|
||||
true);
|
||||
node->setMaterialFlag(video::EMF_FRONT_FACE_CULLING,
|
||||
true);
|
||||
node->forEachMaterial([] (video::SMaterial &mat) {
|
||||
mat.BackfaceCulling = true;
|
||||
mat.FrontfaceCulling = true;
|
||||
});
|
||||
} else {
|
||||
// Restore mesh visibility.
|
||||
node->setMaterialFlag(video::EMF_BACK_FACE_CULLING,
|
||||
m_prop.backface_culling);
|
||||
node->setMaterialFlag(video::EMF_FRONT_FACE_CULLING,
|
||||
false);
|
||||
node->forEachMaterial([this] (video::SMaterial &mat) {
|
||||
mat.BackfaceCulling = m_prop.backface_culling;
|
||||
mat.FrontfaceCulling = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -36,13 +36,16 @@ public:
|
||||
infostream<<"SmokePuffCSO: constructing"<<std::endl;
|
||||
m_spritenode = smgr->addBillboardSceneNode(
|
||||
NULL, v2f(1,1), pos, -1);
|
||||
m_spritenode->setMaterialTexture(0,
|
||||
env->getGameDef()->tsrc()->getTextureForMesh("smoke_puff.png"));
|
||||
m_spritenode->setMaterialFlag(video::EMF_LIGHTING, false);
|
||||
m_spritenode->setMaterialFlag(video::EMF_BILINEAR_FILTER, false);
|
||||
//m_spritenode->setMaterialType(video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF);
|
||||
m_spritenode->setMaterialType(video::EMT_TRANSPARENT_ALPHA_CHANNEL);
|
||||
m_spritenode->setMaterialFlag(video::EMF_FOG_ENABLE, true);
|
||||
video::ITexture *tex = env->getGameDef()->tsrc()->getTextureForMesh("smoke_puff.png");
|
||||
m_spritenode->forEachMaterial([tex] (video::SMaterial &mat) {
|
||||
mat.setTexture(0, tex);
|
||||
mat.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
|
||||
mat.Lighting = false;
|
||||
mat.FogEnable = true;
|
||||
mat.forEachTexture([] (video::SMaterialLayer &tex) {
|
||||
tex.BilinearFilter = false;
|
||||
});
|
||||
});
|
||||
m_spritenode->setColor(video::SColor(255,0,0,0));
|
||||
m_spritenode->setVisible(true);
|
||||
m_spritenode->setSize(size);
|
||||
|
@ -112,7 +112,7 @@ Hud::Hud(Client *client, LocalPlayer *player,
|
||||
rangelim(g_settings->getS16("selectionbox_width"), 1, 5);
|
||||
} else if (m_mode == HIGHLIGHT_HALO) {
|
||||
m_selection_material.setTexture(0, tsrc->getTextureForMesh("halo.png"));
|
||||
m_selection_material.setFlag(video::EMF_BACK_FACE_CULLING, true);
|
||||
m_selection_material.BackfaceCulling = true;
|
||||
} else {
|
||||
m_selection_material.MaterialType = video::EMT_SOLID;
|
||||
}
|
||||
|
@ -763,11 +763,13 @@ MapBlockMesh::MapBlockMesh(MeshMakeData *data, v3s16 camera_offset):
|
||||
|
||||
// Create material
|
||||
video::SMaterial material;
|
||||
material.setFlag(video::EMF_LIGHTING, false);
|
||||
material.setFlag(video::EMF_BACK_FACE_CULLING, true);
|
||||
material.setFlag(video::EMF_BILINEAR_FILTER, false);
|
||||
material.setFlag(video::EMF_FOG_ENABLE, true);
|
||||
material.Lighting = false;
|
||||
material.BackfaceCulling = true;
|
||||
material.FogEnable = true;
|
||||
material.setTexture(0, p.layer.texture);
|
||||
material.forEachTexture([] (video::SMaterialLayer &tex) {
|
||||
tex.BilinearFilter = false;
|
||||
});
|
||||
|
||||
if (m_enable_shaders) {
|
||||
material.MaterialType = m_shdrsrc->getShaderInfo(
|
||||
|
@ -98,9 +98,11 @@ scene::IAnimatedMesh* createCubeMesh(v3f scale)
|
||||
scene::IMeshBuffer *buf = new scene::SMeshBuffer();
|
||||
buf->append(vertices + 4 * i, 4, indices, 6);
|
||||
// Set default material
|
||||
buf->getMaterial().setFlag(video::EMF_LIGHTING, false);
|
||||
buf->getMaterial().setFlag(video::EMF_BILINEAR_FILTER, false);
|
||||
buf->getMaterial().Lighting = false;
|
||||
buf->getMaterial().MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
|
||||
buf->getMaterial().forEachTexture([] (video::SMaterialLayer &tex) {
|
||||
tex.BilinearFilter = false;
|
||||
});
|
||||
// Add mesh buffer to mesh
|
||||
mesh->addMeshBuffer(buf);
|
||||
buf->drop();
|
||||
@ -406,8 +408,10 @@ scene::IMesh* convertNodeboxesToMesh(const std::vector<aabb3f> &boxes,
|
||||
for (u16 j = 0; j < 6; j++)
|
||||
{
|
||||
scene::IMeshBuffer *buf = new scene::SMeshBuffer();
|
||||
buf->getMaterial().setFlag(video::EMF_LIGHTING, false);
|
||||
buf->getMaterial().setFlag(video::EMF_BILINEAR_FILTER, false);
|
||||
buf->getMaterial().Lighting = false;
|
||||
buf->getMaterial().forEachTexture([] (video::SMaterialLayer &tex) {
|
||||
tex.BilinearFilter = false;
|
||||
});
|
||||
dst_mesh->addMeshBuffer(buf);
|
||||
buf->drop();
|
||||
}
|
||||
|
@ -608,7 +608,9 @@ void Minimap::drawMinimap(core::rect<s32> rect) {
|
||||
matrix.makeIdentity();
|
||||
|
||||
video::SMaterial &material = m_meshbuffer->getMaterial();
|
||||
material.setFlag(video::EMF_TRILINEAR_FILTER, true);
|
||||
material.forEachTexture([] (video::SMaterialLayer &tex) {
|
||||
tex.TrilinearFilter = true;
|
||||
});
|
||||
material.Lighting = false;
|
||||
material.TextureLayer[0].Texture = minimap_texture;
|
||||
material.TextureLayer[1].Texture = data->heightmap_texture;
|
||||
|
@ -89,13 +89,15 @@ Particle::Particle(
|
||||
}
|
||||
|
||||
// Texture
|
||||
m_material.setFlag(video::EMF_LIGHTING, false);
|
||||
m_material.setFlag(video::EMF_BACK_FACE_CULLING, false);
|
||||
m_material.setFlag(video::EMF_BILINEAR_FILTER, false);
|
||||
m_material.setFlag(video::EMF_FOG_ENABLE, true);
|
||||
m_material.Lighting = false;
|
||||
m_material.BackfaceCulling = false;
|
||||
m_material.FogEnable = true;
|
||||
m_material.forEachTexture([] (video::SMaterialLayer &tex) {
|
||||
tex.BilinearFilter = false;
|
||||
});
|
||||
|
||||
// correctly render layered transparent particles -- see #10398
|
||||
m_material.setFlag(video::EMF_ZWRITE_ENABLE, true);
|
||||
m_material.ZWriteEnable = video::EZW_AUTO;
|
||||
|
||||
// enable alpha blending and set blend mode
|
||||
m_material.MaterialType = video::EMT_ONETEXTURE_BLEND;
|
||||
|
@ -113,7 +113,9 @@ void ShadowRenderer::disable()
|
||||
}
|
||||
|
||||
for (auto node : m_shadow_node_array)
|
||||
node.node->setMaterialTexture(TEXTURE_LAYER_SHADOW, nullptr);
|
||||
node.node->forEachMaterial([] (video::SMaterial &mat) {
|
||||
mat.setTexture(TEXTURE_LAYER_SHADOW, nullptr);
|
||||
});
|
||||
}
|
||||
|
||||
void ShadowRenderer::initialize()
|
||||
@ -183,12 +185,16 @@ void ShadowRenderer::addNodeToShadowList(
|
||||
// node should never be ClientMap
|
||||
assert(strcmp(node->getName(), "ClientMap") != 0);
|
||||
|
||||
node->setMaterialTexture(TEXTURE_LAYER_SHADOW, shadowMapTextureFinal);
|
||||
node->forEachMaterial([this] (video::SMaterial &mat) {
|
||||
mat.setTexture(TEXTURE_LAYER_SHADOW, shadowMapTextureFinal);
|
||||
});
|
||||
}
|
||||
|
||||
void ShadowRenderer::removeNodeFromShadowList(scene::ISceneNode *node)
|
||||
{
|
||||
node->setMaterialTexture(TEXTURE_LAYER_SHADOW, nullptr);
|
||||
node->forEachMaterial([] (video::SMaterial &mat) {
|
||||
mat.setTexture(TEXTURE_LAYER_SHADOW, nullptr);
|
||||
});
|
||||
for (auto it = m_shadow_node_array.begin(); it != m_shadow_node_array.end();) {
|
||||
if (it->node == node) {
|
||||
it = m_shadow_node_array.erase(it);
|
||||
@ -258,7 +264,9 @@ void ShadowRenderer::updateSMTextures()
|
||||
assert(shadowMapTextureFinal != nullptr);
|
||||
|
||||
for (auto &node : m_shadow_node_array)
|
||||
node.node->setMaterialTexture(TEXTURE_LAYER_SHADOW, shadowMapTextureFinal);
|
||||
node.node->forEachMaterial([this] (video::SMaterial &mat) {
|
||||
mat.setTexture(TEXTURE_LAYER_SHADOW, shadowMapTextureFinal);
|
||||
});
|
||||
}
|
||||
|
||||
if (!m_shadow_node_array.empty()) {
|
||||
|
@ -50,9 +50,11 @@ static video::SMaterial baseMaterial()
|
||||
|
||||
static inline void disableTextureFiltering(video::SMaterial &mat)
|
||||
{
|
||||
mat.setFlag(video::E_MATERIAL_FLAG::EMF_BILINEAR_FILTER, false);
|
||||
mat.setFlag(video::E_MATERIAL_FLAG::EMF_TRILINEAR_FILTER, false);
|
||||
mat.setFlag(video::E_MATERIAL_FLAG::EMF_ANISOTROPIC_FILTER, false);
|
||||
mat.forEachTexture([] (video::SMaterialLayer &tex) {
|
||||
tex.BilinearFilter = false;
|
||||
tex.TrilinearFilter = false;
|
||||
tex.AnisotropicFilter = 0;
|
||||
});
|
||||
}
|
||||
|
||||
Sky::Sky(s32 id, RenderingEngine *rendering_engine, ITextureSource *tsrc, IShaderSource *ssrc) :
|
||||
|
@ -296,18 +296,15 @@ void WieldMeshSceneNode::setExtruded(const std::string &imagename,
|
||||
material.TextureLayer[0].TextureWrapV = video::ETC_CLAMP_TO_EDGE;
|
||||
material.MaterialType = m_material_type;
|
||||
material.MaterialTypeParam = 0.5f;
|
||||
material.setFlag(video::EMF_BACK_FACE_CULLING, true);
|
||||
material.BackfaceCulling = true;
|
||||
// Enable bi/trilinear filtering only for high resolution textures
|
||||
if (dim.Width > 32) {
|
||||
material.setFlag(video::EMF_BILINEAR_FILTER, m_bilinear_filter);
|
||||
material.setFlag(video::EMF_TRILINEAR_FILTER, m_trilinear_filter);
|
||||
} else {
|
||||
material.setFlag(video::EMF_BILINEAR_FILTER, false);
|
||||
material.setFlag(video::EMF_TRILINEAR_FILTER, false);
|
||||
}
|
||||
material.setFlag(video::EMF_ANISOTROPIC_FILTER, m_anisotropic_filter);
|
||||
material.forEachTexture([this, &dim] (video::SMaterialLayer &tex) {
|
||||
tex.BilinearFilter = dim.Width > 32 && m_bilinear_filter;
|
||||
tex.TrilinearFilter = dim.Width > 32 && m_trilinear_filter;
|
||||
tex.AnisotropicFilter = m_anisotropic_filter ? 0xFF : 0;
|
||||
});
|
||||
// mipmaps cause "thin black line" artifacts
|
||||
material.setFlag(video::EMF_USE_MIP_MAPS, false);
|
||||
material.UseMipMaps = false;
|
||||
if (m_enable_shaders) {
|
||||
material.setTexture(2, tsrc->getShaderFlagsTexture(false));
|
||||
}
|
||||
@ -465,9 +462,11 @@ void WieldMeshSceneNode::setItem(const ItemStack &item, Client *client, bool che
|
||||
video::SMaterial &material = m_meshnode->getMaterial(i);
|
||||
material.MaterialType = m_material_type;
|
||||
material.MaterialTypeParam = 0.5f;
|
||||
material.setFlag(video::EMF_BACK_FACE_CULLING, cull_backface);
|
||||
material.setFlag(video::EMF_BILINEAR_FILTER, m_bilinear_filter);
|
||||
material.setFlag(video::EMF_TRILINEAR_FILTER, m_trilinear_filter);
|
||||
material.BackfaceCulling = cull_backface;
|
||||
material.forEachTexture([this] (video::SMaterialLayer &tex) {
|
||||
tex.BilinearFilter = m_bilinear_filter;
|
||||
tex.TrilinearFilter = m_trilinear_filter;
|
||||
});
|
||||
}
|
||||
|
||||
// initialize the color
|
||||
@ -558,9 +557,11 @@ void WieldMeshSceneNode::changeToMesh(scene::IMesh *mesh)
|
||||
m_meshnode->setMesh(mesh);
|
||||
}
|
||||
|
||||
m_meshnode->setMaterialFlag(video::EMF_LIGHTING, m_lighting);
|
||||
// need to normalize normals when lighting is enabled (because of setScale())
|
||||
m_meshnode->setMaterialFlag(video::EMF_NORMALIZE_NORMALS, m_lighting);
|
||||
m_meshnode->forEachMaterial([this] (video::SMaterial &mat) {
|
||||
mat.Lighting = m_lighting;
|
||||
// need to normalize normals when lighting is enabled (because of setScale())
|
||||
mat.NormalizeNormals = m_lighting;
|
||||
});
|
||||
m_meshnode->setVisible(true);
|
||||
}
|
||||
|
||||
@ -653,10 +654,12 @@ void getItemMesh(Client *client, const ItemStack &item, ItemMesh *result)
|
||||
video::SMaterial &material = buf->getMaterial();
|
||||
material.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
|
||||
material.MaterialTypeParam = 0.5f;
|
||||
material.setFlag(video::EMF_BILINEAR_FILTER, false);
|
||||
material.setFlag(video::EMF_TRILINEAR_FILTER, false);
|
||||
material.setFlag(video::EMF_BACK_FACE_CULLING, cull_backface);
|
||||
material.setFlag(video::EMF_LIGHTING, false);
|
||||
material.forEachTexture([] (video::SMaterialLayer &tex) {
|
||||
tex.BilinearFilter = false;
|
||||
tex.TrilinearFilter = false;
|
||||
});
|
||||
material.BackfaceCulling = cull_backface;
|
||||
material.Lighting = false;
|
||||
}
|
||||
|
||||
rotateMeshXZby(mesh, -45);
|
||||
@ -698,10 +701,10 @@ scene::SMesh *getExtrudedMesh(ITextureSource *tsrc,
|
||||
video::SMaterial &material = mesh->getMeshBuffer(layer)->getMaterial();
|
||||
material.TextureLayer[0].TextureWrapU = video::ETC_CLAMP_TO_EDGE;
|
||||
material.TextureLayer[0].TextureWrapV = video::ETC_CLAMP_TO_EDGE;
|
||||
material.setFlag(video::EMF_BILINEAR_FILTER, false);
|
||||
material.setFlag(video::EMF_TRILINEAR_FILTER, false);
|
||||
material.setFlag(video::EMF_BACK_FACE_CULLING, true);
|
||||
material.setFlag(video::EMF_LIGHTING, false);
|
||||
material.TextureLayer[0].BilinearFilter = false;
|
||||
material.TextureLayer[0].TrilinearFilter = false;
|
||||
material.BackfaceCulling = true;
|
||||
material.Lighting = false;
|
||||
material.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
|
||||
material.MaterialTypeParam = 0.5f;
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ private:
|
||||
scene::IMeshSceneNode *m_meshnode = nullptr;
|
||||
video::E_MATERIAL_TYPE m_material_type;
|
||||
|
||||
// True if EMF_LIGHTING should be enabled.
|
||||
// True if SMaterial::Lighting should be enabled.
|
||||
bool m_lighting;
|
||||
|
||||
bool m_enable_shaders;
|
||||
|
@ -66,11 +66,11 @@ void GUIScene::setTexture(u32 idx, video::ITexture *texture)
|
||||
material.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
|
||||
material.MaterialTypeParam = 0.5f;
|
||||
material.TextureLayer[0].Texture = texture;
|
||||
material.setFlag(video::EMF_LIGHTING, false);
|
||||
material.setFlag(video::EMF_FOG_ENABLE, true);
|
||||
material.setFlag(video::EMF_BILINEAR_FILTER, false);
|
||||
material.setFlag(video::EMF_BACK_FACE_CULLING, false);
|
||||
material.setFlag(video::EMF_ZWRITE_ENABLE, true);
|
||||
material.Lighting = false;
|
||||
material.FogEnable = true;
|
||||
material.TextureLayer[0].BilinearFilter = false;
|
||||
material.BackfaceCulling = false;
|
||||
material.ZWriteEnable = video::EZW_AUTO;
|
||||
}
|
||||
|
||||
void GUIScene::draw()
|
||||
|
@ -1125,9 +1125,9 @@ core::array<scene::ISceneNode*> CGUITTFont::addTextSceneNode(const wchar_t* text
|
||||
|
||||
// the default font material
|
||||
SMaterial mat;
|
||||
mat.setFlag(video::EMF_LIGHTING, true);
|
||||
mat.setFlag(video::EMF_ZWRITE_ENABLE, false);
|
||||
mat.setFlag(video::EMF_NORMALIZE_NORMALS, true);
|
||||
mat.Lighting = true;
|
||||
mat.ZWriteEnable = video::EZW_OFF;
|
||||
mat.NormalizeNormals = true;
|
||||
mat.ColorMaterial = video::ECM_NONE;
|
||||
mat.MaterialType = use_transparency ? video::EMT_TRANSPARENT_ALPHA_CHANNEL : video::EMT_SOLID;
|
||||
mat.MaterialTypeParam = 0.01f;
|
||||
|
Loading…
Reference in New Issue
Block a user