forked from Mirrorlandia_minetest/minetest
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.
This commit is contained in:
parent
5e7662ca16
commit
42e1a12714
@ -254,7 +254,7 @@ local function formspec(tabview, name, tabdata)
|
|||||||
.. dump(core.settings:get_bool("generate_normalmaps")) .. "]" ..
|
.. dump(core.settings:get_bool("generate_normalmaps")) .. "]" ..
|
||||||
"checkbox[8.25,2;cb_parallax;" .. fgettext("Parallax Occlusion") .. ";"
|
"checkbox[8.25,2;cb_parallax;" .. fgettext("Parallax Occlusion") .. ";"
|
||||||
.. dump(core.settings:get_bool("enable_parallax_occlusion")) .. "]" ..
|
.. dump(core.settings:get_bool("enable_parallax_occlusion")) .. "]" ..
|
||||||
"checkbox[8.25,2.5;cb_waving_water;" .. fgettext("Waving Water") .. ";"
|
"checkbox[8.25,2.5;cb_waving_water;" .. fgettext("Waving Liquids") .. ";"
|
||||||
.. dump(core.settings:get_bool("enable_waving_water")) .. "]" ..
|
.. dump(core.settings:get_bool("enable_waving_water")) .. "]" ..
|
||||||
"checkbox[8.25,3;cb_waving_leaves;" .. fgettext("Waving Leaves") .. ";"
|
"checkbox[8.25,3;cb_waving_leaves;" .. fgettext("Waving Leaves") .. ";"
|
||||||
.. dump(core.settings:get_bool("enable_waving_leaves")) .. "]" ..
|
.. dump(core.settings:get_bool("enable_waving_leaves")) .. "]" ..
|
||||||
@ -271,7 +271,7 @@ local function formspec(tabview, name, tabdata)
|
|||||||
"label[8.38,2.2;" .. core.colorize("#888888",
|
"label[8.38,2.2;" .. core.colorize("#888888",
|
||||||
fgettext("Parallax Occlusion")) .. "]" ..
|
fgettext("Parallax Occlusion")) .. "]" ..
|
||||||
"label[8.38,2.7;" .. core.colorize("#888888",
|
"label[8.38,2.7;" .. core.colorize("#888888",
|
||||||
fgettext("Waving Water")) .. "]" ..
|
fgettext("Waving Liquids")) .. "]" ..
|
||||||
"label[8.38,3.2;" .. core.colorize("#888888",
|
"label[8.38,3.2;" .. core.colorize("#888888",
|
||||||
fgettext("Waving Leaves")) .. "]" ..
|
fgettext("Waving Leaves")) .. "]" ..
|
||||||
"label[8.38,3.7;" .. core.colorize("#888888",
|
"label[8.38,3.7;" .. core.colorize("#888888",
|
||||||
|
@ -68,7 +68,7 @@ float disp_z;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#if (MATERIAL_TYPE == TILE_MATERIAL_LIQUID_TRANSPARENT || MATERIAL_TYPE == TILE_MATERIAL_LIQUID_OPAQUE) && ENABLE_WAVING_WATER
|
#if (MATERIAL_TYPE == TILE_MATERIAL_WAVING_LIQUID_TRANSPARENT || MATERIAL_TYPE == TILE_MATERIAL_WAVING_LIQUID_OPAQUE || MATERIAL_TYPE == TILE_MATERIAL_WAVING_LIQUID_BASIC) && ENABLE_WAVING_WATER
|
||||||
vec4 pos = gl_Vertex;
|
vec4 pos = gl_Vertex;
|
||||||
pos.y -= 2.0;
|
pos.y -= 2.0;
|
||||||
float posYbuf = (pos.z / WATER_WAVE_LENGTH + animationTimer * WATER_WAVE_SPEED * WATER_WAVE_LENGTH);
|
float posYbuf = (pos.z / WATER_WAVE_LENGTH + animationTimer * WATER_WAVE_SPEED * WATER_WAVE_LENGTH);
|
||||||
|
@ -6135,12 +6135,15 @@ Used by `minetest.register_node`.
|
|||||||
legacy_wallmounted = false,
|
legacy_wallmounted = false,
|
||||||
|
|
||||||
waving = 0,
|
waving = 0,
|
||||||
-- Valid for mesh, nodebox, plantlike, allfaces_optional nodes.
|
-- Valid for drawtypes:
|
||||||
-- 1 - wave node like plants (top of node moves, bottom is fixed)
|
-- mesh, nodebox, plantlike, allfaces_optional, liquid, flowingliquid.
|
||||||
|
-- 1 - wave node like plants (node top moves side-to-side, bottom is fixed)
|
||||||
-- 2 - wave node like leaves (whole node moves side-to-side)
|
-- 2 - wave node like leaves (whole node moves side-to-side)
|
||||||
-- caveats: not all models will properly wave.
|
-- 3 - wave node like liquids (whole node moves up and down)
|
||||||
-- plantlike drawtype nodes can only wave like plants.
|
-- Not all models will properly wave.
|
||||||
-- allfaces_optional drawtype nodes can only wave like leaves.
|
-- plantlike drawtype can only wave like plants.
|
||||||
|
-- allfaces_optional drawtype can only wave like leaves.
|
||||||
|
-- liquid, flowingliquid drawtypes can only wave like liquids.
|
||||||
|
|
||||||
sounds = {
|
sounds = {
|
||||||
footstep = <SimpleSoundSpec>,
|
footstep = <SimpleSoundSpec>,
|
||||||
|
@ -527,15 +527,18 @@ ShaderInfo generate_shader(const std::string &name, u8 material_type, u8 drawtyp
|
|||||||
switch (material_type) {
|
switch (material_type) {
|
||||||
case TILE_MATERIAL_OPAQUE:
|
case TILE_MATERIAL_OPAQUE:
|
||||||
case TILE_MATERIAL_LIQUID_OPAQUE:
|
case TILE_MATERIAL_LIQUID_OPAQUE:
|
||||||
|
case TILE_MATERIAL_WAVING_LIQUID_OPAQUE:
|
||||||
shaderinfo.base_material = video::EMT_SOLID;
|
shaderinfo.base_material = video::EMT_SOLID;
|
||||||
break;
|
break;
|
||||||
case TILE_MATERIAL_ALPHA:
|
case TILE_MATERIAL_ALPHA:
|
||||||
case TILE_MATERIAL_LIQUID_TRANSPARENT:
|
case TILE_MATERIAL_LIQUID_TRANSPARENT:
|
||||||
|
case TILE_MATERIAL_WAVING_LIQUID_TRANSPARENT:
|
||||||
shaderinfo.base_material = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
|
shaderinfo.base_material = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
|
||||||
break;
|
break;
|
||||||
case TILE_MATERIAL_BASIC:
|
case TILE_MATERIAL_BASIC:
|
||||||
case TILE_MATERIAL_WAVING_LEAVES:
|
case TILE_MATERIAL_WAVING_LEAVES:
|
||||||
case TILE_MATERIAL_WAVING_PLANTS:
|
case TILE_MATERIAL_WAVING_PLANTS:
|
||||||
|
case TILE_MATERIAL_WAVING_LIQUID_BASIC:
|
||||||
shaderinfo.base_material = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
|
shaderinfo.base_material = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -631,10 +634,13 @@ ShaderInfo generate_shader(const std::string &name, u8 material_type, u8 drawtyp
|
|||||||
"TILE_MATERIAL_LIQUID_OPAQUE",
|
"TILE_MATERIAL_LIQUID_OPAQUE",
|
||||||
"TILE_MATERIAL_WAVING_LEAVES",
|
"TILE_MATERIAL_WAVING_LEAVES",
|
||||||
"TILE_MATERIAL_WAVING_PLANTS",
|
"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 += "#define ";
|
||||||
shaders_header += materialTypes[i];
|
shaders_header += materialTypes[i];
|
||||||
shaders_header += " ";
|
shaders_header += " ";
|
||||||
|
@ -144,7 +144,10 @@ enum MaterialType{
|
|||||||
TILE_MATERIAL_LIQUID_OPAQUE,
|
TILE_MATERIAL_LIQUID_OPAQUE,
|
||||||
TILE_MATERIAL_WAVING_LEAVES,
|
TILE_MATERIAL_WAVING_LEAVES,
|
||||||
TILE_MATERIAL_WAVING_PLANTS,
|
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
|
// Material flags
|
||||||
@ -208,16 +211,19 @@ struct TileLayer
|
|||||||
switch (material_type) {
|
switch (material_type) {
|
||||||
case TILE_MATERIAL_OPAQUE:
|
case TILE_MATERIAL_OPAQUE:
|
||||||
case TILE_MATERIAL_LIQUID_OPAQUE:
|
case TILE_MATERIAL_LIQUID_OPAQUE:
|
||||||
|
case TILE_MATERIAL_WAVING_LIQUID_OPAQUE:
|
||||||
material.MaterialType = video::EMT_SOLID;
|
material.MaterialType = video::EMT_SOLID;
|
||||||
break;
|
break;
|
||||||
case TILE_MATERIAL_BASIC:
|
case TILE_MATERIAL_BASIC:
|
||||||
case TILE_MATERIAL_WAVING_LEAVES:
|
case TILE_MATERIAL_WAVING_LEAVES:
|
||||||
case TILE_MATERIAL_WAVING_PLANTS:
|
case TILE_MATERIAL_WAVING_PLANTS:
|
||||||
|
case TILE_MATERIAL_WAVING_LIQUID_BASIC:
|
||||||
material.MaterialTypeParam = 0.5;
|
material.MaterialTypeParam = 0.5;
|
||||||
material.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
|
material.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
|
||||||
break;
|
break;
|
||||||
case TILE_MATERIAL_ALPHA:
|
case TILE_MATERIAL_ALPHA:
|
||||||
case TILE_MATERIAL_LIQUID_TRANSPARENT:
|
case TILE_MATERIAL_LIQUID_TRANSPARENT:
|
||||||
|
case TILE_MATERIAL_WAVING_LIQUID_TRANSPARENT:
|
||||||
material.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
|
material.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -798,6 +798,8 @@ void ContentFeatures::updateTextures(ITextureSource *tsrc, IShaderSource *shdsrc
|
|||||||
material_type = TILE_MATERIAL_WAVING_PLANTS;
|
material_type = TILE_MATERIAL_WAVING_PLANTS;
|
||||||
else if (waving == 2)
|
else if (waving == 2)
|
||||||
material_type = TILE_MATERIAL_WAVING_LEAVES;
|
material_type = TILE_MATERIAL_WAVING_LEAVES;
|
||||||
|
else if (waving == 3)
|
||||||
|
material_type = TILE_MATERIAL_WAVING_LIQUID_BASIC;
|
||||||
break;
|
break;
|
||||||
case NDT_TORCHLIKE:
|
case NDT_TORCHLIKE:
|
||||||
case NDT_SIGNLIKE:
|
case NDT_SIGNLIKE:
|
||||||
@ -815,8 +817,14 @@ void ContentFeatures::updateTextures(ITextureSource *tsrc, IShaderSource *shdsrc
|
|||||||
correctAlpha(tdef, 6);
|
correctAlpha(tdef, 6);
|
||||||
correctAlpha(tdef_overlay, 6);
|
correctAlpha(tdef_overlay, 6);
|
||||||
correctAlpha(tdef_spec, CF_SPECIAL_COUNT);
|
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);
|
u32 tile_shader = shdsrc->getShader("nodes_shader", material_type, drawtype);
|
||||||
|
Loading…
Reference in New Issue
Block a user