diff options
Diffstat (limited to 'client/shaders/nodes_shader/opengl_fragment.glsl')
-rw-r--r-- | client/shaders/nodes_shader/opengl_fragment.glsl | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/client/shaders/nodes_shader/opengl_fragment.glsl b/client/shaders/nodes_shader/opengl_fragment.glsl index 71ded2b9d..7c5b9b613 100644 --- a/client/shaders/nodes_shader/opengl_fragment.glsl +++ b/client/shaders/nodes_shader/opengl_fragment.glsl @@ -37,7 +37,7 @@ const float fogShadingParameter = 1 / ( 1 - fogStart); vec3 uncharted2Tonemap(vec3 x) { - return ((x * (0.22 * x + 0.03) + 0.002) / (x * (0.22 * x + 0.3) + 0.06)) - 0.03334; + return ((x * (0.22 * x + 0.03) + 0.002) / (x * (0.22 * x + 0.3) + 0.06)) - 0.03333; } vec4 applyToneMapping(vec4 color) @@ -163,7 +163,8 @@ void main(void) } #endif - if (GENERATE_NORMALMAPS == 1 && normalTexturePresent == false) { +#if GENERATE_NORMALMAPS == 1 + if (normalTexturePresent == false) { float tl = get_rgb_height(vec2(uv.x - SAMPLE_STEP, uv.y + SAMPLE_STEP)); float t = get_rgb_height(vec2(uv.x - SAMPLE_STEP, uv.y - SAMPLE_STEP)); float tr = get_rgb_height(vec2(uv.x + SAMPLE_STEP, uv.y + SAMPLE_STEP)); @@ -177,7 +178,7 @@ void main(void) bump = vec4(normalize(vec3 (dX, dY, NORMALMAPS_STRENGTH)), 1.0); use_normalmap = true; } - +#endif vec4 base = texture2D(baseTexture, uv).rgba; #ifdef ENABLE_BUMPMAPPING @@ -200,20 +201,18 @@ void main(void) col = applyToneMapping(col); #endif - if (fogDistance != 0.0) { - // 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); - } + // 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); gl_FragColor = col; |