mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Point light ambiance for less harsh shadows
This commit is contained in:
parent
100cafa91b
commit
aabe1d7cfd
@ -182,7 +182,7 @@ void main() {
|
||||
|
||||
float ao = f_ao * sqrt(f_ao);//0.25 + f_ao * 0.75; ///*pow(f_ao, 0.5)*/f_ao * 0.85 + 0.15;
|
||||
|
||||
vec3 glow = pow(pow(model_glow.w, 2.0) * (max(dot(f_norm, normalize(model_glow.xyz)), 0.0) * 1.0 + max(1.0 - length(model_glow.xyz), 0.0)), 1) * 4 * GLOW_COLOR;
|
||||
vec3 glow = pow(pow(model_glow.w, 2.0) * (max(dot(f_norm, normalize(model_glow.xyz)) * 0.5 + 0.5, 0.0) * 1.0 + max(1.0 - length(model_glow.xyz), 0.0)), 1) * 4 * GLOW_COLOR;
|
||||
emitted_light += glow;
|
||||
|
||||
reflected_light *= ao;
|
||||
|
@ -183,7 +183,8 @@ 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);
|
||||
directed_light += is_direct ? mix(LIGHT_AMBIANCE, 1.0, computed_shadow) * 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
|
||||
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;
|
||||
// ambient_light += is_direct ? vec3(0.0) : vec3(0.0); // direct_light * square_factor * LIGHT_AMBIANCE;
|
||||
|
@ -513,7 +513,7 @@ impl<V: RectRasterableVol> Terrain<V> {
|
||||
(e as i32).div_euclid(sz as i32)
|
||||
});
|
||||
|
||||
const AMBIANCE: f32 = 0.2; // 0-1, the proportion of light that should illuminate the rear of an object
|
||||
const AMBIANCE: f32 = 0.3; // 0-1, the proportion of light that should illuminate the rear of an object
|
||||
|
||||
let (bias, total, max) = Spiral2d::new()
|
||||
.take(9)
|
||||
@ -531,13 +531,13 @@ impl<V: RectRasterableVol> Terrain<V> {
|
||||
let rpos = lpos.map(|e| e as f32 + 0.5) - wpos;
|
||||
let level = (*level as f32 - rpos.magnitude()).max(0.0) / SUNLIGHT as f32;
|
||||
(
|
||||
bias + rpos.try_normalized().unwrap_or_else(Vec3::zero) * level * (1.0 - AMBIANCE),
|
||||
bias + rpos.try_normalized().unwrap_or_else(Vec3::zero) * level,
|
||||
total + level,
|
||||
max.max(level),
|
||||
)
|
||||
});
|
||||
|
||||
(bias.try_normalized().unwrap_or_else(Vec3::zero) / total.max(0.001), self.glow_at_wpos(wpos.map(|e| e.floor() as i32)))
|
||||
(bias.try_normalized().unwrap_or_else(Vec3::zero) * (1.0 - AMBIANCE) / total.max(0.001), self.glow_at_wpos(wpos.map(|e| e.floor() as i32)))
|
||||
}
|
||||
|
||||
/// Maintain terrain data. To be called once per tick.
|
||||
|
Loading…
Reference in New Issue
Block a user