diff --git a/client/shaders/nodes_shader/opengl_fragment.glsl b/client/shaders/nodes_shader/opengl_fragment.glsl index c560a8505f6df..a086d968fc5a5 100644 --- a/client/shaders/nodes_shader/opengl_fragment.glsl +++ b/client/shaders/nodes_shader/opengl_fragment.glsl @@ -1,3 +1,4 @@ +// Does not include wannabe liquids #if (MATERIAL_TYPE == TILE_MATERIAL_WAVING_LIQUID_TRANSPARENT || MATERIAL_TYPE == TILE_MATERIAL_WAVING_LIQUID_OPAQUE || MATERIAL_TYPE == TILE_MATERIAL_WAVING_LIQUID_BASIC || MATERIAL_TYPE == TILE_MATERIAL_LIQUID_TRANSPARENT) #define MATERIAL_WAVING_LIQUID 1 #endif diff --git a/client/shaders/nodes_shader/opengl_vertex.glsl b/client/shaders/nodes_shader/opengl_vertex.glsl index 8455e312f02fc..2e8f5edc667a7 100644 --- a/client/shaders/nodes_shader/opengl_vertex.glsl +++ b/client/shaders/nodes_shader/opengl_vertex.glsl @@ -1,3 +1,8 @@ +// OpenGL < 4.3 does not support continued preprocessor lines +#define IS_WAVING_ACTUAL_LIQUID (MATERIAL_TYPE == TILE_MATERIAL_WAVING_LIQUID_TRANSPARENT || MATERIAL_TYPE == TILE_MATERIAL_WAVING_LIQUID_OPAQUE || MATERIAL_TYPE == TILE_MATERIAL_WAVING_LIQUID_BASIC) +#define IS_WAVING_WANNABE_LIQUID (MATERIAL_TYPE == TILE_MATERIAL_WAVING_WANNABELIQUID_TRANSPARENT || MATERIAL_TYPE == TILE_MATERIAL_WAVING_WANNABELIQUID_OPAQUE || MATERIAL_TYPE == TILE_MATERIAL_WAVING_WANNABELIQUID_BASIC) +#define IS_LIQUID_WAVING ((IS_WAVING_ACTUAL_LIQUID || IS_WAVING_WANNABE_LIQUID) && ENABLE_WAVING_WATER) + uniform mat4 mWorld; // Color of the light emitted by the sun. uniform vec3 dayLight; @@ -108,8 +113,7 @@ float smoothTriangleWave(float x) return smoothCurve(triangleWave(x)) * 2.0 - 1.0; } -// OpenGL < 4.3 does not support continued preprocessor lines -#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 +#if IS_LIQUID_WAVING // // Simple, fast noise function. @@ -166,8 +170,7 @@ void main(void) #endif vec4 pos = inVertexPosition; -// OpenGL < 4.3 does not support continued preprocessor lines -#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 +#if IS_LIQUID_WAVING // Generate waves with Perlin-type noise. // The constants are calibrated such that they roughly // correspond to the old sine waves. @@ -177,11 +180,16 @@ void main(void) wavePos.x /= WATER_WAVE_LENGTH * 3.0; wavePos.z /= WATER_WAVE_LENGTH * 2.0; wavePos.z += animationTimer * WATER_WAVE_SPEED * 10.0; +#if IS_WAVING_ACTUAL_LIQUID // Flowing liquid waveheight is scaled by node height, so it doesn't wave // into the floor. // Also, vertices that are exactly on the border do not wave, see // cur_liquid.y_offset_allow_wave in content_mapblock.h. float nodecorner_height = fract(pos.y * (1.0 / BS) + 0.5 + 0.001); +#else + // Wannabe liquids (e.g. waterlilies) always wave the same + float nodecorner_height = 1.0f; +#endif pos.y += (snoise(wavePos) - 1.0) * WATER_WAVE_HEIGHT * 5.0 * nodecorner_height; #elif MATERIAL_TYPE == TILE_MATERIAL_WAVING_LEAVES && ENABLE_WAVING_LEAVES pos.x += disp_x; diff --git a/src/client/shader.cpp b/src/client/shader.cpp index 8d2d5744a8090..69a391be6f68c 100644 --- a/src/client/shader.cpp +++ b/src/client/shader.cpp @@ -515,12 +515,14 @@ ShaderInfo ShaderSource::generateShader(const std::string &name, case TILE_MATERIAL_OPAQUE: case TILE_MATERIAL_LIQUID_OPAQUE: case TILE_MATERIAL_WAVING_LIQUID_OPAQUE: + case TILE_MATERIAL_WAVING_WANNABELIQUID_OPAQUE: 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: + case TILE_MATERIAL_WAVING_WANNABELIQUID_TRANSPARENT: shaderinfo.base_material = video::EMT_TRANSPARENT_ALPHA_CHANNEL; break; case TILE_MATERIAL_BASIC: @@ -528,6 +530,7 @@ ShaderInfo ShaderSource::generateShader(const std::string &name, case TILE_MATERIAL_WAVING_LEAVES: case TILE_MATERIAL_WAVING_PLANTS: case TILE_MATERIAL_WAVING_LIQUID_BASIC: + case TILE_MATERIAL_WAVING_WANNABELIQUID_BASIC: shaderinfo.base_material = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF; break; } @@ -649,6 +652,9 @@ ShaderInfo ShaderSource::generateShader(const std::string &name, PROVIDE(TILE_MATERIAL_WAVING_LIQUID_BASIC); PROVIDE(TILE_MATERIAL_WAVING_LIQUID_TRANSPARENT); PROVIDE(TILE_MATERIAL_WAVING_LIQUID_OPAQUE); + PROVIDE(TILE_MATERIAL_WAVING_WANNABELIQUID_BASIC); + PROVIDE(TILE_MATERIAL_WAVING_WANNABELIQUID_TRANSPARENT); + PROVIDE(TILE_MATERIAL_WAVING_WANNABELIQUID_OPAQUE); PROVIDE(TILE_MATERIAL_PLAIN); PROVIDE(TILE_MATERIAL_PLAIN_ALPHA); diff --git a/src/client/tile.cpp b/src/client/tile.cpp index ad5811d648104..700d898e76069 100644 --- a/src/client/tile.cpp +++ b/src/client/tile.cpp @@ -11,18 +11,21 @@ void TileLayer::applyMaterialOptions(video::SMaterial &material) const case TILE_MATERIAL_OPAQUE: case TILE_MATERIAL_LIQUID_OPAQUE: case TILE_MATERIAL_WAVING_LIQUID_OPAQUE: + case TILE_MATERIAL_WAVING_WANNABELIQUID_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: + case TILE_MATERIAL_WAVING_WANNABELIQUID_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: + case TILE_MATERIAL_WAVING_WANNABELIQUID_TRANSPARENT: material.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL; break; default: diff --git a/src/client/tile.h b/src/client/tile.h index df02d224422eb..9db400767a5b4 100644 --- a/src/client/tile.h +++ b/src/client/tile.h @@ -20,6 +20,9 @@ enum MaterialType{ TILE_MATERIAL_WAVING_LIQUID_BASIC, TILE_MATERIAL_WAVING_LIQUID_TRANSPARENT, TILE_MATERIAL_WAVING_LIQUID_OPAQUE, + TILE_MATERIAL_WAVING_WANNABELIQUID_BASIC, + TILE_MATERIAL_WAVING_WANNABELIQUID_TRANSPARENT, + TILE_MATERIAL_WAVING_WANNABELIQUID_OPAQUE, TILE_MATERIAL_PLAIN, TILE_MATERIAL_PLAIN_ALPHA }; diff --git a/src/nodedef.cpp b/src/nodedef.cpp index 2037bb118fad1..f96ac085f81e1 100644 --- a/src/nodedef.cpp +++ b/src/nodedef.cpp @@ -873,8 +873,10 @@ void ContentFeatures::updateTextures(ITextureSource *tsrc, IShaderSource *shdsrc material_type = TILE_MATERIAL_WAVING_LEAVES; } else if (waving == 3) { material_type = alpha == ALPHAMODE_OPAQUE ? - TILE_MATERIAL_WAVING_LIQUID_OPAQUE : (alpha == ALPHAMODE_CLIP ? - TILE_MATERIAL_WAVING_LIQUID_BASIC : TILE_MATERIAL_WAVING_LIQUID_TRANSPARENT); + TILE_MATERIAL_WAVING_WANNABELIQUID_OPAQUE : + (alpha == ALPHAMODE_CLIP ? + TILE_MATERIAL_WAVING_WANNABELIQUID_BASIC : + TILE_MATERIAL_WAVING_WANNABELIQUID_TRANSPARENT); } break; case NDT_TORCHLIKE: