aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorParamat <paramat@users.noreply.github.com>2019-03-27 00:18:43 +0000
committerGitHub <noreply@github.com>2019-03-27 00:18:43 +0000
commit42e1a127140965cac1be6e51e48192e341c2a29e (patch)
tree9c1d824e6b70838a13afa4870f219108d4d97899 /src
parent5e7662ca168b47ed3e81901d53bff2eb712f571c (diff)
downloadminetest-42e1a127140965cac1be6e51e48192e341c2a29e.tar.gz
minetest-42e1a127140965cac1be6e51e48192e341c2a29e.tar.bz2
minetest-42e1a127140965cac1be6e51e48192e341c2a29e.zip
Require 'waving = 3' in a nodedef to apply the liquid waving shader (#8418)
Makes the liquid waving shader per-nodedef like waving leaves/plants, instead of being applied to all liquids. Like the waving leaves/plants shaders, the liquid waving shader can also be applied to meshes and nodeboxes. Derived from a PR by t0ny2.
Diffstat (limited to 'src')
-rw-r--r--src/client/shader.cpp10
-rw-r--r--src/client/tile.h8
-rw-r--r--src/nodedef.cpp12
3 files changed, 25 insertions, 5 deletions
diff --git a/src/client/shader.cpp b/src/client/shader.cpp
index 3b49a36ba..f36ff3d85 100644
--- a/src/client/shader.cpp
+++ b/src/client/shader.cpp
@@ -527,15 +527,18 @@ ShaderInfo generate_shader(const std::string &name, u8 material_type, u8 drawtyp
switch (material_type) {
case TILE_MATERIAL_OPAQUE:
case TILE_MATERIAL_LIQUID_OPAQUE:
+ case TILE_MATERIAL_WAVING_LIQUID_OPAQUE:
shaderinfo.base_material = video::EMT_SOLID;
break;
case TILE_MATERIAL_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_WAVING_LEAVES:
case TILE_MATERIAL_WAVING_PLANTS:
+ case TILE_MATERIAL_WAVING_LIQUID_BASIC:
shaderinfo.base_material = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
break;
}
@@ -631,10 +634,13 @@ ShaderInfo generate_shader(const std::string &name, u8 material_type, u8 drawtyp
"TILE_MATERIAL_LIQUID_OPAQUE",
"TILE_MATERIAL_WAVING_LEAVES",
"TILE_MATERIAL_WAVING_PLANTS",
- "TILE_MATERIAL_OPAQUE"
+ "TILE_MATERIAL_OPAQUE",
+ "TILE_MATERIAL_WAVING_LIQUID_BASIC",
+ "TILE_MATERIAL_WAVING_LIQUID_TRANSPARENT",
+ "TILE_MATERIAL_WAVING_LIQUID_OPAQUE",
};
- for (int i = 0; i < 7; i++){
+ for (int i = 0; i < 10; i++){
shaders_header += "#define ";
shaders_header += materialTypes[i];
shaders_header += " ";
diff --git a/src/client/tile.h b/src/client/tile.h
index 2a33dd160..d0c45b4a4 100644
--- a/src/client/tile.h
+++ b/src/client/tile.h
@@ -144,7 +144,10 @@ enum MaterialType{
TILE_MATERIAL_LIQUID_OPAQUE,
TILE_MATERIAL_WAVING_LEAVES,
TILE_MATERIAL_WAVING_PLANTS,
- TILE_MATERIAL_OPAQUE
+ TILE_MATERIAL_OPAQUE,
+ TILE_MATERIAL_WAVING_LIQUID_BASIC,
+ TILE_MATERIAL_WAVING_LIQUID_TRANSPARENT,
+ TILE_MATERIAL_WAVING_LIQUID_OPAQUE,
};
// Material flags
@@ -208,16 +211,19 @@ struct TileLayer
switch (material_type) {
case TILE_MATERIAL_OPAQUE:
case TILE_MATERIAL_LIQUID_OPAQUE:
+ case TILE_MATERIAL_WAVING_LIQUID_OPAQUE:
material.MaterialType = video::EMT_SOLID;
break;
case TILE_MATERIAL_BASIC:
case TILE_MATERIAL_WAVING_LEAVES:
case TILE_MATERIAL_WAVING_PLANTS:
+ case TILE_MATERIAL_WAVING_LIQUID_BASIC:
material.MaterialTypeParam = 0.5;
material.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
break;
case TILE_MATERIAL_ALPHA:
case TILE_MATERIAL_LIQUID_TRANSPARENT:
+ case TILE_MATERIAL_WAVING_LIQUID_TRANSPARENT:
material.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
break;
default:
diff --git a/src/nodedef.cpp b/src/nodedef.cpp
index 03a163bd3..83e3968c3 100644
--- a/src/nodedef.cpp
+++ b/src/nodedef.cpp
@@ -798,6 +798,8 @@ void ContentFeatures::updateTextures(ITextureSource *tsrc, IShaderSource *shdsrc
material_type = TILE_MATERIAL_WAVING_PLANTS;
else if (waving == 2)
material_type = TILE_MATERIAL_WAVING_LEAVES;
+ else if (waving == 3)
+ material_type = TILE_MATERIAL_WAVING_LIQUID_BASIC;
break;
case NDT_TORCHLIKE:
case NDT_SIGNLIKE:
@@ -815,8 +817,14 @@ void ContentFeatures::updateTextures(ITextureSource *tsrc, IShaderSource *shdsrc
correctAlpha(tdef, 6);
correctAlpha(tdef_overlay, 6);
correctAlpha(tdef_spec, CF_SPECIAL_COUNT);
- material_type = (alpha == 255) ?
- TILE_MATERIAL_LIQUID_OPAQUE : TILE_MATERIAL_LIQUID_TRANSPARENT;
+
+ if (waving == 3) {
+ material_type = (alpha == 255) ? TILE_MATERIAL_WAVING_LIQUID_OPAQUE :
+ TILE_MATERIAL_WAVING_LIQUID_TRANSPARENT;
+ } else {
+ material_type = (alpha == 255) ? TILE_MATERIAL_LIQUID_OPAQUE :
+ TILE_MATERIAL_LIQUID_TRANSPARENT;
+ }
}
u32 tile_shader = shdsrc->getShader("nodes_shader", material_type, drawtype);