summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
Diffstat (limited to 'client')
-rw-r--r--client/shaders/minimap_shader/opengl_vertex.glsl2
-rw-r--r--client/shaders/nodes_shader/opengl_fragment.glsl33
-rw-r--r--client/shaders/nodes_shader/opengl_vertex.glsl2
-rw-r--r--client/shaders/water_surface_shader/opengl_fragment.glsl33
-rw-r--r--client/shaders/water_surface_shader/opengl_vertex.glsl2
-rw-r--r--client/shaders/wielded_shader/opengl_fragment.glsl16
-rw-r--r--client/shaders/wielded_shader/opengl_vertex.glsl2
7 files changed, 50 insertions, 40 deletions
diff --git a/client/shaders/minimap_shader/opengl_vertex.glsl b/client/shaders/minimap_shader/opengl_vertex.glsl
index 06df5a3cf..88f9356d5 100644
--- a/client/shaders/minimap_shader/opengl_vertex.glsl
+++ b/client/shaders/minimap_shader/opengl_vertex.glsl
@@ -1,6 +1,4 @@
uniform mat4 mWorldViewProj;
-uniform mat4 mInvWorld;
-uniform mat4 mTransWorld;
uniform mat4 mWorld;
void main(void)
diff --git a/client/shaders/nodes_shader/opengl_fragment.glsl b/client/shaders/nodes_shader/opengl_fragment.glsl
index 6862842a7..71ded2b9d 100644
--- a/client/shaders/nodes_shader/opengl_fragment.glsl
+++ b/client/shaders/nodes_shader/opengl_fragment.glsl
@@ -19,6 +19,8 @@ bool normalTexturePresent = false;
const float e = 2.718281828459;
const float BS = 10.0;
+const float fogStart = FOG_START;
+const float fogShadingParameter = 1 / ( 1 - fogStart);
#ifdef ENABLE_TONE_MAPPING
@@ -194,24 +196,25 @@ void main(void)
vec4 col = vec4(color.rgb * gl_Color.rgb, 1.0);
-#if MATERIAL_TYPE == TILE_MATERIAL_LIQUID_TRANSPARENT
- float alpha = gl_Color.a;
- if (fogDistance != 0.0) {
- float d = max(0.0, min(vPosition.z / fogDistance * 1.5 - 0.6, 1.0));
- alpha = mix(alpha, 0.0, d);
- }
- col = vec4(col.rgb, alpha);
-#else
+#ifdef ENABLE_TONE_MAPPING
+ col = applyToneMapping(col);
+#endif
+
if (fogDistance != 0.0) {
- float d = max(0.0, min(vPosition.z / fogDistance * 1.5 - 0.6, 1.0));
- col = mix(col, skyBgColor, d);
+ // Due to a bug in some (older ?) graphics stacks (possibly in the glsl compiler ?),
+ // the fog will only be rendered correctly if the last operation before the
+ // clamp() is an addition. Else, the clamp() seems to be ignored.
+ // E.g. the following won't work:
+ // float clarity = clamp(fogShadingParameter
+ // * (fogDistance - length(eyeVec)) / fogDistance), 0.0, 1.0);
+ // As additions usually come for free following a multiplication, the new formula
+ // should be more efficient as well.
+ // Note: clarity = (1 - fogginess)
+ float clarity = clamp(fogShadingParameter
+ - fogShadingParameter * length(eyeVec) / fogDistance, 0.0, 1.0);
+ col = mix(skyBgColor, col, clarity);
}
col = vec4(col.rgb, base.a);
-#endif
-#ifdef ENABLE_TONE_MAPPING
- gl_FragColor = applyToneMapping(col);
-#else
gl_FragColor = col;
-#endif
}
diff --git a/client/shaders/nodes_shader/opengl_vertex.glsl b/client/shaders/nodes_shader/opengl_vertex.glsl
index 28c5f197e..44c48cc4c 100644
--- a/client/shaders/nodes_shader/opengl_vertex.glsl
+++ b/client/shaders/nodes_shader/opengl_vertex.glsl
@@ -1,6 +1,4 @@
uniform mat4 mWorldViewProj;
-uniform mat4 mInvWorld;
-uniform mat4 mTransWorld;
uniform mat4 mWorld;
uniform float dayNightRatio;
diff --git a/client/shaders/water_surface_shader/opengl_fragment.glsl b/client/shaders/water_surface_shader/opengl_fragment.glsl
index 1fa669541..c4e78470d 100644
--- a/client/shaders/water_surface_shader/opengl_fragment.glsl
+++ b/client/shaders/water_surface_shader/opengl_fragment.glsl
@@ -21,6 +21,8 @@ bool texSeamless = false;
const float e = 2.718281828459;
const float BS = 10.0;
+const float fogStart = FOG_START;
+const float fogShadingParameter = 1 / ( 1 - fogStart);
#ifdef ENABLE_TONE_MAPPING
@@ -150,24 +152,25 @@ vec4 base = texture2D(baseTexture, uv).rgba;
vec4 col = vec4(color.rgb * gl_Color.rgb, 1.0);
-#if MATERIAL_TYPE == TILE_MATERIAL_LIQUID_TRANSPARENT || MATERIAL_TYPE == TILE_MATERIAL_LIQUID_OPAQUE
- float alpha = gl_Color.a;
- if (fogDistance != 0.0) {
- float d = max(0.0, min(vPosition.z / fogDistance * 1.5 - 0.6, 1.0));
- alpha = mix(alpha, 0.0, d);
- }
- col = vec4(col.rgb, alpha);
-#else
+#ifdef ENABLE_TONE_MAPPING
+ col = applyToneMapping(col);
+#endif
+
if (fogDistance != 0.0) {
- float d = max(0.0, min(vPosition.z / fogDistance * 1.5 - 0.6, 1.0));
- col = mix(col, skyBgColor, d);
+ // Due to a bug in some (older ?) graphics stacks (possibly in the glsl compiler ?),
+ // the fog will only be rendered correctly if the last operation before the
+ // clamp() is an addition. Else, the clamp() seems to be ignored.
+ // E.g. the following won't work:
+ // float clarity = clamp(fogShadingParameter
+ // * (fogDistance - length(eyeVec)) / fogDistance), 0.0, 1.0);
+ // As additions usually come for free following a multiplication, the new formula
+ // should be more efficient as well.
+ // Note: clarity = (1 - fogginess)
+ float clarity = clamp(fogShadingParameter
+ - fogShadingParameter * length(eyeVec) / fogDistance, 0.0, 1.0);
+ col = mix(skyBgColor, col, clarity);
}
col = vec4(col.rgb, base.a);
-#endif
-#ifdef ENABLE_TONE_MAPPING
- gl_FragColor = applyToneMapping(col);
-#else
gl_FragColor = col;
-#endif
}
diff --git a/client/shaders/water_surface_shader/opengl_vertex.glsl b/client/shaders/water_surface_shader/opengl_vertex.glsl
index 9b461f4c1..a930e7b8f 100644
--- a/client/shaders/water_surface_shader/opengl_vertex.glsl
+++ b/client/shaders/water_surface_shader/opengl_vertex.glsl
@@ -1,6 +1,4 @@
uniform mat4 mWorldViewProj;
-uniform mat4 mInvWorld;
-uniform mat4 mTransWorld;
uniform mat4 mWorld;
uniform float dayNightRatio;
diff --git a/client/shaders/wielded_shader/opengl_fragment.glsl b/client/shaders/wielded_shader/opengl_fragment.glsl
index 75dd1b674..ba7a8f12d 100644
--- a/client/shaders/wielded_shader/opengl_fragment.glsl
+++ b/client/shaders/wielded_shader/opengl_fragment.glsl
@@ -19,6 +19,8 @@ bool texSeamless = false;
const float e = 2.718281828459;
const float BS = 10.0;
+const float fogStart = FOG_START;
+const float fogShadingParameter = 1 / ( 1 - fogStart);
void get_texture_flags()
{
@@ -107,8 +109,18 @@ void main(void)
vec4 col = vec4(color.rgb, base.a);
col *= gl_Color;
if (fogDistance != 0.0) {
- float d = max(0.0, min(vPosition.z / fogDistance * 1.5 - 0.6, 1.0));
- col = mix(col, skyBgColor, d);
+ // Due to a bug in some (older ?) graphics stacks (possibly in the glsl compiler ?),
+ // the fog will only be rendered correctly if the last operation before the
+ // clamp() is an addition. Else, the clamp() seems to be ignored.
+ // E.g. the following won't work:
+ // float clarity = clamp(fogShadingParameter
+ // * (fogDistance - length(eyeVec)) / fogDistance), 0.0, 1.0);
+ // As additions usually come for free following a multiplication, the new formula
+ // should be more efficient as well.
+ // Note: clarity = (1 - fogginess)
+ float clarity = clamp(fogShadingParameter
+ - fogShadingParameter * length(eyeVec) / fogDistance, 0.0, 1.0);
+ col = mix(skyBgColor, col, clarity);
}
gl_FragColor = vec4(col.rgb, base.a);
}
diff --git a/client/shaders/wielded_shader/opengl_vertex.glsl b/client/shaders/wielded_shader/opengl_vertex.glsl
index c33b0a7d3..86c626896 100644
--- a/client/shaders/wielded_shader/opengl_vertex.glsl
+++ b/client/shaders/wielded_shader/opengl_vertex.glsl
@@ -1,6 +1,4 @@
uniform mat4 mWorldViewProj;
-uniform mat4 mInvWorld;
-uniform mat4 mTransWorld;
uniform mat4 mWorld;
uniform float dayNightRatio;