Skip to content

Commit

Permalink
Shaders: Fix OpenGL < 4.3 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
SmallJoker committed Feb 16, 2020
1 parent 3f67549 commit 478e753
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions client/shaders/nodes_shader/opengl_vertex.glsl
Expand Up @@ -46,9 +46,8 @@ float smoothTriangleWave(float x)
return smoothCurve(triangleWave(x)) * 2.0 - 1.0;
}

#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
// 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

//
// Simple, fast noise function.
Expand Down Expand Up @@ -115,9 +114,8 @@ float disp_z;

worldPosition = (mWorld * gl_Vertex).xyz;

#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
// 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
// Generate waves with Perlin-type noise.
// The constants are calibrated such that they roughly
// correspond to the old sine waves.
Expand Down Expand Up @@ -188,12 +186,12 @@ float disp_z;
color.rgb = gl_Color.rgb * (gl_Color.a * dayLight.rgb +
nightRatio * artificialLight.rgb) * 2;
color.a = 1;

// Emphase blue a bit in darker places
// See C++ implementation in mapblock_mesh.cpp final_color_blend()
float brightness = (color.r + color.g + color.b) / 3;
color.b += max(0.0, 0.021 - abs(0.2 * brightness - 0.021) +
0.07 * brightness);

gl_FrontColor = gl_BackColor = clamp(color, 0.0, 1.0);
}

0 comments on commit 478e753

Please sign in to comment.