diff --git a/res/shaders/clouds.glslv b/res/shaders/clouds.glslv index 0b9c17774..e1576f633 100644 --- a/res/shaders/clouds.glslv +++ b/res/shaders/clouds.glslv @@ -22,7 +22,7 @@ void main() { vec3 pos3d = a_modelpos.xyz - u_cameraPos; - a_realnormal = v_normal.xyz * 2.0 - 1.0; + a_realnormal = vec3(0.0, 1.0, 0.0); a_normal = calc_screen_normal(a_realnormal); a_torchLight = vec4(calc_torch_light( diff --git a/res/shaders/effects/deferred_lighting.glsl b/res/shaders/effects/deferred_lighting.glsl index 55e267bf3..ebcf138aa 100644 --- a/res/shaders/effects/deferred_lighting.glsl +++ b/res/shaders/effects/deferred_lighting.glsl @@ -3,6 +3,7 @@ #define CLOUDS_FOG_FACTOR_MUL 0.3f #define CLOUDS_FOG_CURVE_MUL 0.4f +#define COLOR_TEMPERATURE_COMPENSATION 1.12f vec4 effect() { vec4 pos = texture(u_position, v_uv); @@ -26,8 +27,12 @@ vec4 effect() { float emission = texture(u_emission, v_uv).r; + float rg = 1.0; #ifdef ENABLE_SHADOWS - light *= calc_shadow(modelpos, normal, length(pos)); + float shadow_mul = calc_shadow(modelpos, normal, length(pos)); + light *= shadow_mul; + rg *= min(1.0, shadow_mul + emission) * COLOR_TEMPERATURE_COMPENSATION; + light *= 2.0; #endif light = max(light, emission); @@ -40,5 +45,5 @@ vec4 effect() { mix(1.0, CLOUDS_FOG_FACTOR_MUL, emission), mix(1.0, CLOUDS_FOG_CURVE_MUL, emission) ); - return vec4(mix(texture(u_screen, v_uv).rgb * mix(1.0, light, 1.0), fogColor, fog), 1.0); + return vec4(mix(texture(u_screen, v_uv).rgb * mix(1.0, light, 1.0) * vec3(rg, 0.5 + rg * 0.5, 1.0), fogColor, fog), 1.0); } diff --git a/res/shaders/lib/shadows.glsl b/res/shaders/lib/shadows.glsl index 658e9a699..a686683f2 100644 --- a/res/shaders/lib/shadows.glsl +++ b/res/shaders/lib/shadows.glsl @@ -25,18 +25,14 @@ float calc_shadow( projCoords.z -= 0.00001 / u_shadowsRes + bias; float shadow = 0.0; - if (dot(realnormal, u_sunDir) < 0.0) { - // 3x3 kernel - for (int y = -1; y <= 1; y++) { - for (int x = -1; x <= 1; x++) { - vec3 offset = vec3(x, y, -(abs(x) + abs(y)) * 0.8) * step * 1.0 * u_shadowsSoftness; - shadow += texture(shadowsMap, projCoords + offset); - } + // 3x3 kernel + for (int y = -1; y <= 1; y++) { + for (int x = -1; x <= 1; x++) { + vec3 offset = vec3(x, y, -(abs(x) + abs(y)) * 0.8) * step * 1.0 * u_shadowsSoftness; + shadow += texture(shadowsMap, projCoords + offset); } - shadow /= 9.0; - } else { - shadow = 0.0; } + shadow /= 9.0; return shadow; }