mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Improve self-shadowing based on light/normal angle
Add compatibility with colored shadows.
This commit is contained in:
parent
10be033791
commit
f2cccf8da7
2 changed files with 12 additions and 4 deletions
|
@ -507,8 +507,12 @@ void main(void)
|
|||
// Power ratio was measured on torches in MTG (brightness = 14).
|
||||
float adjusted_night_ratio = pow(nightRatio, 0.6);
|
||||
|
||||
if (f_normal_length != 0 && cosLight < 0.035) {
|
||||
shadow_int = max(shadow_int, 1 - clamp(cosLight, 0.0, 0.035)/0.035);
|
||||
// cosine of the normal-to-light angle when
|
||||
// we start to apply self-shadowing
|
||||
const float self_shadow_cutoff_cosine = 0.14;
|
||||
if (f_normal_length != 0 && cosLight < self_shadow_cutoff_cosine) {
|
||||
shadow_int = max(shadow_int, 1 - clamp(cosLight, 0.0, self_shadow_cutoff_cosine)/self_shadow_cutoff_cosine);
|
||||
shadow_color = mix(vec3(0.0), shadow_color, min(cosLight, self_shadow_cutoff_cosine)/self_shadow_cutoff_cosine);
|
||||
}
|
||||
|
||||
shadow_int *= f_adj_shadow_strength;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue