mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Initial refactoring on shader usage and generation
`IShaderSource` was designed with the idea that if you want a shader, you must want it for a node. So it depends heavily on being given a tile material and the node drawtype. But this doesn't make sense neither in theory nor in practice. This commit takes a small step towards removing the incorrect abstraction.
This commit is contained in:
parent
eb8beb335e
commit
a6293b9861
14 changed files with 81 additions and 53 deletions
|
@ -1,6 +0,0 @@
|
|||
varying lowp vec4 varColor;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
gl_FragData[0] = varColor;
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
varying lowp vec4 varColor;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
gl_Position = mWorldViewProj * inVertexPosition;
|
||||
varColor = inVertexColor;
|
||||
}
|
|
@ -1,7 +1,3 @@
|
|||
#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
|
||||
|
||||
uniform sampler2D baseTexture;
|
||||
|
||||
uniform vec3 dayLight;
|
||||
|
@ -53,7 +49,7 @@ varying highp vec3 eyeVec;
|
|||
varying float nightRatio;
|
||||
|
||||
#ifdef ENABLE_DYNAMIC_SHADOWS
|
||||
#if (defined(MATERIAL_WAVING_LIQUID) && defined(ENABLE_WATER_REFLECTIONS) && ENABLE_WAVING_WATER)
|
||||
#if (defined(ENABLE_WATER_REFLECTIONS) && MATERIAL_WAVING_LIQUID && ENABLE_WAVING_WATER)
|
||||
vec4 perm(vec4 x)
|
||||
{
|
||||
return mod(((x * 34.0) + 1.0) * x, 289.0);
|
||||
|
@ -504,7 +500,7 @@ void main(void)
|
|||
vec3 viewVec = normalize(worldPosition + cameraOffset - cameraPosition);
|
||||
|
||||
// Water reflections
|
||||
#if (defined(MATERIAL_WAVING_LIQUID) && defined(ENABLE_WATER_REFLECTIONS) && ENABLE_WAVING_WATER)
|
||||
#if (defined(ENABLE_WATER_REFLECTIONS) && MATERIAL_WAVING_LIQUID && ENABLE_WAVING_WATER)
|
||||
vec3 wavePos = worldPosition * vec3(2.0, 0.0, 2.0);
|
||||
float off = animationTimer * WATER_WAVE_SPEED * 10.0;
|
||||
wavePos.x /= WATER_WAVE_LENGTH * 3.0;
|
||||
|
@ -532,7 +528,7 @@ void main(void)
|
|||
col.rgb += water_reflect_color * f_adj_shadow_strength * brightness_factor;
|
||||
#endif
|
||||
|
||||
#if (defined(ENABLE_NODE_SPECULAR) && !defined(MATERIAL_WAVING_LIQUID))
|
||||
#if (defined(ENABLE_NODE_SPECULAR) && !MATERIAL_WAVING_LIQUID)
|
||||
// Apply specular to blocks.
|
||||
if (dot(v_LightDirection, vNormal) < 0.0) {
|
||||
float intensity = 2.0 * (1.0 - (base.r * varColor.r));
|
||||
|
|
|
@ -108,8 +108,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 MATERIAL_WAVING_LIQUID && ENABLE_WAVING_WATER
|
||||
|
||||
//
|
||||
// Simple, fast noise function.
|
||||
|
@ -166,8 +165,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 MATERIAL_WAVING_LIQUID && ENABLE_WAVING_WATER
|
||||
// Generate waves with Perlin-type noise.
|
||||
// The constants are calibrated such that they roughly
|
||||
// correspond to the old sine waves.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue