Fixed wall leaking with dynamic light ambiance

This commit is contained in:
Joshua Barretto 2021-02-10 23:15:59 +00:00
parent aabe1d7cfd
commit 31832e1245
6 changed files with 14 additions and 2 deletions

View File

@ -1,5 +1,7 @@
#version 330 core
#define FIGURE_SHADER
#include <constants.glsl>
#define LIGHTING_TYPE LIGHTING_TYPE_REFLECTION

View File

@ -2,6 +2,8 @@
#include <constants.glsl>
#define FIGURE_SHADER
#define LIGHTING_TYPE LIGHTING_TYPE_REFLECTION
#define LIGHTING_REFLECTION_KIND LIGHTING_REFLECTION_KIND_GLOSSY

View File

@ -183,7 +183,11 @@ float lights_at(vec3 wpos, vec3 wnorm, vec3 /*cam_to_frag*/view_dir, vec3 mu, ve
vec3 direct_light = PI * color * strength * square_factor * light_reflection_factor(/*direct_norm_dir*/wnorm, /*cam_to_frag*/view_dir, direct_light_dir, k_d, k_s, alpha, voxel_norm, voxel_lighting);
float computed_shadow = ShadowCalculationPoint(i, -difference, wnorm, wpos/*, light_distance*/);
// directed_light += is_direct ? max(computed_shadow, /*LIGHT_AMBIANCE*/0.0) * direct_light * square_factor : vec3(0.0);
vec3 ambiance = color * 1.0 / distance_2; // Non-physical hack, but it's pretty subtle and *damn* does it make character shadows look better
#ifdef FIGURE_SHADER
vec3 ambiance = color * 0.5 / distance_2; // Non-physical hack, but it's pretty subtle and *damn* does it make shadows on characters look better
#else
vec3 ambiance = vec3(0.0);
#endif
directed_light += (is_direct ? mix(LIGHT_AMBIANCE, 1.0, computed_shadow) * direct_light * square_factor : vec3(0.0)) + ambiance;
// directed_light += (is_direct ? 1.0 : LIGHT_AMBIANCE) * max(computed_shadow, /*LIGHT_AMBIANCE*/0.0) * direct_light * square_factor;// : vec3(0.0);
// directed_light += mix(LIGHT_AMBIANCE, 1.0, computed_shadow) * direct_light * square_factor;

View File

@ -1,6 +1,8 @@
#version 330 core
// #extension ARB_texture_storage : enable
#define FIGURE_SHADER
#include <constants.glsl>
#define LIGHTING_TYPE LIGHTING_TYPE_REFLECTION

View File

@ -1,5 +1,7 @@
#version 330 core
#define FIGURE_SHADER
#include <constants.glsl>
#define LIGHTING_TYPE LIGHTING_TYPE_REFLECTION

View File

@ -513,7 +513,7 @@ impl<V: RectRasterableVol> Terrain<V> {
(e as i32).div_euclid(sz as i32)
});
const AMBIANCE: f32 = 0.3; // 0-1, the proportion of light that should illuminate the rear of an object
const AMBIANCE: f32 = 0.15; // 0-1, the proportion of light that should illuminate the rear of an object
let (bias, total, max) = Spiral2d::new()
.take(9)