aboutsummaryrefslogtreecommitdiff
path: root/src/client
diff options
context:
space:
mode:
authorDanila Shutov <dcbrwn2@gmail.com>2020-06-16 22:48:31 +0300
committerGitHub <noreply@github.com>2020-06-16 20:48:31 +0100
commit3a6dfda358112e2fb5d6f887a1a1e936eacddadd (patch)
tree340e1e0442ef8ba346b522580b2b6bee66246b30 /src/client
parent0a1181f7637adab6fe1ba5d3c09038912a06b37f (diff)
downloadminetest-3a6dfda358112e2fb5d6f887a1a1e936eacddadd.tar.gz
minetest-3a6dfda358112e2fb5d6f887a1a1e936eacddadd.tar.bz2
minetest-3a6dfda358112e2fb5d6f887a1a1e936eacddadd.zip
Make shading of CAOs optional (#10033)
Diffstat (limited to 'src/client')
-rw-r--r--src/client/content_cao.cpp15
-rw-r--r--src/client/mesh.cpp2
-rw-r--r--src/client/shader.cpp6
-rw-r--r--src/client/tile.h2
4 files changed, 19 insertions, 6 deletions
diff --git a/src/client/content_cao.cpp b/src/client/content_cao.cpp
index eec4e3de0..5352c35f4 100644
--- a/src/client/content_cao.cpp
+++ b/src/client/content_cao.cpp
@@ -577,10 +577,16 @@ void GenericCAO::addToScene(ITextureSource *tsrc)
if (m_enable_shaders) {
IShaderSource *shader_source = m_client->getShaderSource();
- u32 shader_id = shader_source->getShader(
- "object_shader",
- (m_prop.use_texture_alpha) ? TILE_MATERIAL_ALPHA : TILE_MATERIAL_BASIC,
- NDT_NORMAL);
+ MaterialType material_type;
+
+ if (m_prop.shaded && m_prop.glow == 0)
+ material_type = (m_prop.use_texture_alpha) ?
+ TILE_MATERIAL_ALPHA : TILE_MATERIAL_BASIC;
+ else
+ material_type = (m_prop.use_texture_alpha) ?
+ TILE_MATERIAL_PLAIN_ALPHA : TILE_MATERIAL_PLAIN;
+
+ u32 shader_id = shader_source->getShader("object_shader", material_type, NDT_NORMAL);
m_material_type = shader_source->getShaderInfo(shader_id).material;
} else {
m_material_type = (m_prop.use_texture_alpha) ?
@@ -1504,6 +1510,7 @@ bool GenericCAO::visualExpiryRequired(const ObjectProperties &new_) const
return old.backface_culling != new_.backface_culling ||
old.is_visible != new_.is_visible ||
old.mesh != new_.mesh ||
+ old.shaded != new_.shaded ||
old.use_texture_alpha != new_.use_texture_alpha ||
old.visual != new_.visual ||
old.visual_size != new_.visual_size ||
diff --git a/src/client/mesh.cpp b/src/client/mesh.cpp
index 68832849e..e1ec22068 100644
--- a/src/client/mesh.cpp
+++ b/src/client/mesh.cpp
@@ -341,7 +341,7 @@ bool checkMeshNormals(scene::IMesh *mesh)
// hurting the performance and covering only really weird broken models.
f32 length = buffer->getNormal(0).getLength();
- if (!std::isfinite(length) || std::fabs(length) < 1e-10f)
+ if (!std::isfinite(length) || length < 1e-10f)
return false;
}
diff --git a/src/client/shader.cpp b/src/client/shader.cpp
index eda415ce6..ee6079f7a 100644
--- a/src/client/shader.cpp
+++ b/src/client/shader.cpp
@@ -537,11 +537,13 @@ ShaderInfo generate_shader(const std::string &name, u8 material_type, u8 drawtyp
shaderinfo.base_material = video::EMT_SOLID;
break;
case TILE_MATERIAL_ALPHA:
+ case TILE_MATERIAL_PLAIN_ALPHA:
case TILE_MATERIAL_LIQUID_TRANSPARENT:
case TILE_MATERIAL_WAVING_LIQUID_TRANSPARENT:
shaderinfo.base_material = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
break;
case TILE_MATERIAL_BASIC:
+ case TILE_MATERIAL_PLAIN:
case TILE_MATERIAL_WAVING_LEAVES:
case TILE_MATERIAL_WAVING_PLANTS:
case TILE_MATERIAL_WAVING_LIQUID_BASIC:
@@ -644,9 +646,11 @@ ShaderInfo generate_shader(const std::string &name, u8 material_type, u8 drawtyp
"TILE_MATERIAL_WAVING_LIQUID_BASIC",
"TILE_MATERIAL_WAVING_LIQUID_TRANSPARENT",
"TILE_MATERIAL_WAVING_LIQUID_OPAQUE",
+ "TILE_MATERIAL_PLAIN",
+ "TILE_MATERIAL_PLAIN_ALPHA",
};
- for (int i = 0; i < 10; i++){
+ for (int i = 0; i < 12; i++){
shaders_header += "#define ";
shaders_header += materialTypes[i];
shaders_header += " ";
diff --git a/src/client/tile.h b/src/client/tile.h
index 533df676e..52e0a2b2b 100644
--- a/src/client/tile.h
+++ b/src/client/tile.h
@@ -150,6 +150,8 @@ enum MaterialType{
TILE_MATERIAL_WAVING_LIQUID_BASIC,
TILE_MATERIAL_WAVING_LIQUID_TRANSPARENT,
TILE_MATERIAL_WAVING_LIQUID_OPAQUE,
+ TILE_MATERIAL_PLAIN,
+ TILE_MATERIAL_PLAIN_ALPHA
};
// Material flags