Fixed drop shadows

This commit is contained in:
Joshua Barretto 2022-12-30 17:01:26 +00:00
parent 367ec3e8f4
commit 4bd7ec26d3
5 changed files with 17 additions and 6 deletions

View File

@ -259,6 +259,8 @@ void main() {
reflected_light *= ao;
emitted_light *= ao;
reflected_light *= point_shadow;
emitted_light *= point_shadow;
/* reflected_light *= cloud_shadow(f_pos); */
/* vec3 point_light = light_at(f_pos, f_norm);
emitted_light += point_light;

View File

@ -94,9 +94,9 @@ vec3 light_at(vec3 wpos, vec3 wnorm) {
float shadow_at(vec3 wpos, vec3 wnorm) {
float shadow = 1.0;
#if (SHADOW_MODE == SHADOW_MODE_NONE || SHADOW_MODE == SHADOW_MODE_MAP)
#if (SHADOW_MODE == SHADOW_MODE_NONE)
return shadow;
#elif (SHADOW_MODE == SHADOW_MODE_CHEAP)
#elif (SHADOW_MODE == SHADOW_MODE_CHEAP || SHADOW_MODE == SHADOW_MODE_MAP)
for (uint i = 0u; i < light_shadow_count.y; i ++) {
// Only access the array once
@ -106,11 +106,13 @@ float shadow_at(vec3 wpos, vec3 wnorm) {
float radius = S.shadow_pos_radius.w;
vec3 diff = shadow_pos - wpos;
if (diff.z >= 0.0) {
diff.z = -sign(diff.z) * diff.z * 0.1;
}
#if (SHADOW_MODE == SHADOW_MODE_CHEAP)
if (diff.z >= 0.0) {
diff.z = -sign(diff.z) * diff.z * 0.1;
}
#endif
float shade = max(pow(diff.x * diff.x + diff.y * diff.y + diff.z * diff.z, 0.35) / pow(radius * radius * 0.5, 0.5), 0.5);
float shade = max(pow(diff.x * diff.x + diff.y * diff.y + diff.z * diff.z, 0.3) / pow(radius * radius * 0.5, 0.5), 0.5);
// float shade = max(pow(dot(diff, diff) / (radius * radius * 0.5), 0.25), 0.5);
// float shade = dot(diff, diff) / (radius * radius * 0.5);

View File

@ -99,6 +99,9 @@ void main() {
max_light += lights_at(f_pos, f_norm, view_dir, mu, cam_attenuation, fluid_alt, k_a, k_d, k_s, alpha, f_norm, 1.0, emitted_light, reflected_light);
emitted_light *= point_shadow;
reflected_light *= point_shadow;
// Allow particles to glow at night
// TODO: Not this
emitted_light += max(f_col.rgb - 1.0, vec3(0));

View File

@ -120,6 +120,8 @@ void main() {
float ao = f_ao;
emitted_light *= ao;
reflected_light *= ao;
emitted_light *= point_shadow;
reflected_light *= point_shadow;
surf_color = illuminate(max_light, view_dir, surf_color * emitted_light, surf_color * reflected_light);

View File

@ -403,6 +403,8 @@ void main() {
max_light += lights_at(f_pos, f_norm, view_dir, mu, cam_attenuation, fluid_alt, k_a, k_d, k_s, alpha, f_norm, 1.0, emitted_light, reflected_light);
reflected_light *= 0.4 + f_ao * 0.6;
emitted_light *= point_shadow;
reflected_light *= point_shadow;
#ifndef EXPERIMENTAL_NOCAUSTICS
#if (FLUID_MODE >= FLUID_MODE_MEDIUM)