1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-08-06 17:41:04 +00:00

Improve shadow rendering with non-default camera FOV (#11385)

* Adjust minimum filter radius for perspective

* Expand shadow frustum when camera FOV changes, reuse FOV distance adjustment from numeric.cpp

* Read shadow_soft_radius setting as float

* Use adaptive filter radius to accomodate for PSM distortion

* Adjust filter radius for texture resolution
This commit is contained in:
x2048 2021-07-11 17:15:19 +02:00 committed by GitHub
parent 1d25d1f7ad
commit f5706d444b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 37 additions and 23 deletions

View file

@ -159,7 +159,7 @@ bool isBlockInSight(v3s16 blockpos_b, v3f camera_pos, v3f camera_dir,
return true;
}
s16 adjustDist(s16 dist, float zoom_fov)
inline float adjustDist(float dist, float zoom_fov)
{
// 1.775 ~= 72 * PI / 180 * 1.4, the default FOV on the client.
// The heuristic threshold for zooming is half of that.
@ -167,8 +167,13 @@ s16 adjustDist(s16 dist, float zoom_fov)
if (zoom_fov < 0.001f || zoom_fov > threshold_fov)
return dist;
return std::round(dist * std::cbrt((1.0f - std::cos(threshold_fov)) /
(1.0f - std::cos(zoom_fov / 2.0f))));
return dist * std::cbrt((1.0f - std::cos(threshold_fov)) /
(1.0f - std::cos(zoom_fov / 2.0f)));
}
s16 adjustDist(s16 dist, float zoom_fov)
{
return std::round(adjustDist((float)dist, zoom_fov));
}
void setPitchYawRollRad(core::matrix4 &m, const v3f &rot)