Skip to content

Commit

Permalink
Shaders: Harmonize Irrlicht and shader fog calculations
Browse files Browse the repository at this point in the history
  • Loading branch information
lhofhansl authored and paramat committed Oct 24, 2016
1 parent 74eb7f5 commit 779d2c5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions client/shaders/nodes_shader/opengl_fragment.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -197,14 +197,14 @@ void main(void)
#if MATERIAL_TYPE == TILE_MATERIAL_LIQUID_TRANSPARENT
float alpha = gl_Color.a;
if (fogDistance != 0.0) {
float d = max(0.0, min(length(eyeVec) / fogDistance * 1.5 - 0.6, 1.0));
alpha = mix(alpha, 0.0, d);
float d = clamp((fogDistance - length(eyeVec)) / (fogDistance * 0.6), 0.0, 1.0);
alpha = mix(0.0, alpha, d);
}
col = vec4(col.rgb, alpha);
#else
if (fogDistance != 0.0) {
float d = max(0.0, min(length(eyeVec) / fogDistance * 1.5 - 0.6, 1.0));
col = mix(col, skyBgColor, d);
float d = clamp((fogDistance - length(eyeVec)) / (fogDistance * 0.6), 0.0, 1.0);
col = mix(skyBgColor, col, d);
}
col = vec4(col.rgb, base.a);
#endif
Expand Down
8 changes: 4 additions & 4 deletions client/shaders/water_surface_shader/opengl_fragment.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -153,14 +153,14 @@ vec4 base = texture2D(baseTexture, uv).rgba;
#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(length(eyeVec) / fogDistance * 1.5 - 0.6, 1.0));
alpha = mix(alpha, 0.0, d);
float d = clamp((fogDistance - length(eyeVec)) / (fogDistance * 0.6), 0.0, 1.0);
alpha = mix(0.0, alpha, d);
}
col = vec4(col.rgb, alpha);
#else
if (fogDistance != 0.0) {
float d = max(0.0, min(length(eyeVec) / fogDistance * 1.5 - 0.6, 1.0));
col = mix(col, skyBgColor, d);
float d = clamp((fogDistance - length(eyeVec)) / (fogDistance * 0.6), 0.0, 1.0);
col = mix(skyBgColor, col, d);
}
col = vec4(col.rgb, base.a);
#endif
Expand Down
4 changes: 2 additions & 2 deletions client/shaders/wielded_shader/opengl_fragment.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ void main(void)
vec4 col = vec4(color.rgb, base.a);
col *= gl_Color;
if (fogDistance != 0.0) {
float d = max(0.0, min(length(eyeVec) / fogDistance * 1.5 - 0.6, 1.0));
col = mix(col, skyBgColor, d);
float d = clamp((fogDistance - length(eyeVec)) / (fogDistance * 0.6), 0.0, 1.0);
col = mix(skyBgColor, col, d);
}
gl_FragColor = vec4(col.rgb, base.a);
}

0 comments on commit 779d2c5

Please sign in to comment.