Fix missing shadows when sun tilt is zero

This commit is contained in:
x2048 2023-03-11 13:49:40 +01:00 committed by GitHub
parent ad41d0af9d
commit 1de8a1e962
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 4 additions and 4 deletions

@ -241,7 +241,7 @@ void main(void)
float pFactor = getPerspectiveFactor(getRelativePosition(m_ShadowViewProj * mWorld * shadow_pos)); float pFactor = getPerspectiveFactor(getRelativePosition(m_ShadowViewProj * mWorld * shadow_pos));
if (f_normal_length > 0.0) { if (f_normal_length > 0.0) {
nNormal = normalize(vNormal); nNormal = normalize(vNormal);
cosLight = dot(nNormal, -v_LightDirection); cosLight = max(1e-5, dot(nNormal, -v_LightDirection));
float sinLight = pow(1 - pow(cosLight, 2.0), 0.5); float sinLight = pow(1 - pow(cosLight, 2.0), 0.5);
normalOffsetScale = 2.0 * pFactor * pFactor * sinLight * min(f_shadowfar, 500.0) / normalOffsetScale = 2.0 * pFactor * pFactor * sinLight * min(f_shadowfar, 500.0) /
xyPerspectiveBias1 / f_textureresolution; xyPerspectiveBias1 / f_textureresolution;

@ -146,7 +146,7 @@ void main(void)
float pFactor = getPerspectiveFactor(getRelativePosition(m_ShadowViewProj * mWorld * inVertexPosition)); float pFactor = getPerspectiveFactor(getRelativePosition(m_ShadowViewProj * mWorld * inVertexPosition));
if (f_normal_length > 0.0) { if (f_normal_length > 0.0) {
nNormal = normalize(vNormal); nNormal = normalize(vNormal);
cosLight = dot(nNormal, -v_LightDirection); cosLight = max(1e-5, dot(nNormal, -v_LightDirection));
float sinLight = pow(1 - pow(cosLight, 2.0), 0.5); float sinLight = pow(1 - pow(cosLight, 2.0), 0.5);
normalOffsetScale = 0.1 * pFactor * pFactor * sinLight * min(f_shadowfar, 500.0) / normalOffsetScale = 0.1 * pFactor * pFactor * sinLight * min(f_shadowfar, 500.0) /
xyPerspectiveBias1 / f_textureresolution; xyPerspectiveBias1 / f_textureresolution;