Merge pull request #997 from MihailRis/update-deferred-lighting

update advanced shading
This commit is contained in:
MihailRis 2026-10-01 21:52:56 +03:00 • committed by GitHub
commit e802753f06
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 14 additions and 13 deletions

View file

@ -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(

View file

@ -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);
}

View file

@ -25,7 +25,6 @@ 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++) {
@ -34,9 +33,6 @@ float calc_shadow(
}
}
shadow /= 9.0;
} else {
shadow = 0.0;
}
return shadow;
}