mirror of
https://github.com/minetest/minetest.git
synced 2024-11-27 10:03:45 +01:00
Improve self-shadowing based on light/normal angle
Add compatibility with colored shadows.
This commit is contained in:
parent
10be033791
commit
f2cccf8da7
@ -514,8 +514,12 @@ void main(void)
|
|||||||
// Power ratio was measured on torches in MTG (brightness = 14).
|
// Power ratio was measured on torches in MTG (brightness = 14).
|
||||||
float adjusted_night_ratio = pow(max(0.0, nightRatio), 0.6);
|
float adjusted_night_ratio = pow(max(0.0, nightRatio), 0.6);
|
||||||
|
|
||||||
if (f_normal_length != 0 && cosLight < 0.035) {
|
// Apply self-shadowing when light falls at a narrow angle to the surface
|
||||||
shadow_int = max(shadow_int, 1 - clamp(cosLight, 0.0, 0.035)/0.035);
|
// Cosine of the cut-off angle.
|
||||||
|
const float self_shadow_cutoff_cosine = 0.035;
|
||||||
|
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;
|
shadow_int *= f_adj_shadow_strength;
|
||||||
|
@ -507,8 +507,12 @@ void main(void)
|
|||||||
// Power ratio was measured on torches in MTG (brightness = 14).
|
// Power ratio was measured on torches in MTG (brightness = 14).
|
||||||
float adjusted_night_ratio = pow(nightRatio, 0.6);
|
float adjusted_night_ratio = pow(nightRatio, 0.6);
|
||||||
|
|
||||||
if (f_normal_length != 0 && cosLight < 0.035) {
|
// cosine of the normal-to-light angle when
|
||||||
shadow_int = max(shadow_int, 1 - clamp(cosLight, 0.0, 0.035)/0.035);
|
// 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;
|
shadow_int *= f_adj_shadow_strength;
|
||||||
|
Loading…
Reference in New Issue
Block a user