mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 10:31:50 +00:00
Merge pull request #997 from MihailRis/update-deferred-lighting
update advanced shading
This commit is contained in:
commit
e802753f06
3 changed files with 14 additions and 13 deletions
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue