diff options
author | x2048 <codeforsmile@gmail.com> | 2021-07-11 17:15:19 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-11 08:15:19 -0700 |
commit | f5706d444b02ccc1fcd854968087172d50cfcca2 (patch) | |
tree | 073af762f7981cf49b0be4fdbd203ecc341df811 /src/util | |
parent | 1d25d1f7ad35f739e8a64c2bdb44105998aed19b (diff) | |
download | minetest-f5706d444b02ccc1fcd854968087172d50cfcca2.tar.gz minetest-f5706d444b02ccc1fcd854968087172d50cfcca2.tar.bz2 minetest-f5706d444b02ccc1fcd854968087172d50cfcca2.zip |
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
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/numeric.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/util/numeric.cpp b/src/util/numeric.cpp index 99e4cfb5c..702ddce95 100644 --- a/src/util/numeric.cpp +++ b/src/util/numeric.cpp @@ -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) |