Merge pull request #34519 from MadEqua/fix-contact-shadows
Fix contact shadow when light is outside of viewport.
This commit is contained in:
commit
34ddb7ac59
1 changed files with 13 additions and 9 deletions
|
@ -897,18 +897,22 @@ float contact_shadow_compute(vec3 pos, vec3 dir, float max_distance) {
|
||||||
bias += incr * 2.0;
|
bias += incr * 2.0;
|
||||||
|
|
||||||
vec3 uv_depth = (source.xyz / source.w) * 0.5 + 0.5;
|
vec3 uv_depth = (source.xyz / source.w) * 0.5 + 0.5;
|
||||||
float depth = texture(depth_buffer, uv_depth.xy).r;
|
if (uv_depth.x > 0.0 && uv_depth.x < 1.0 && uv_depth.y > 0.0 && uv_depth.y < 1.0) {
|
||||||
|
float depth = texture(depth_buffer, uv_depth.xy).r;
|
||||||
|
|
||||||
if (depth < uv_depth.z) {
|
if (depth < uv_depth.z) {
|
||||||
if (depth > (bias.z / bias.w) * 0.5 + 0.5) {
|
if (depth > (bias.z / bias.w) * 0.5 + 0.5) {
|
||||||
return min(pow(ratio, 4.0), 1.0);
|
return min(pow(ratio, 4.0), 1.0);
|
||||||
} else {
|
} else {
|
||||||
return 1.0;
|
return 1.0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
ratio += ratio_incr;
|
ratio += ratio_incr;
|
||||||
steps -= 1.0;
|
steps -= 1.0;
|
||||||
|
} else {
|
||||||
|
return 1.0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1.0;
|
return 1.0;
|
||||||
|
|
Loading…
Reference in a new issue