diff options
author | Dmitry Kostenko <codeforsmile@gmail.com> | 2022-02-20 00:04:48 +0100 |
---|---|---|
committer | x2048 <codeforsmile@gmail.com> | 2022-03-07 23:45:26 +0100 |
commit | 4801bdf45aaaa9238bc52a157e1d25c9d477d81a (patch) | |
tree | 7d557eda80e935b62129f40ae683e7685b28bc8f /src | |
parent | 25c1974e0d734b6e80d128b325e8e6b506a7401b (diff) | |
download | minetest-4801bdf45aaaa9238bc52a157e1d25c9d477d81a.tar.gz minetest-4801bdf45aaaa9238bc52a157e1d25c9d477d81a.tar.bz2 minetest-4801bdf45aaaa9238bc52a157e1d25c9d477d81a.zip |
Correct normal bias for entities
Remove use of magic constants.
Apply cameraOffset
Calculate distance projected on SM plane
Diffstat (limited to 'src')
-rw-r--r-- | src/client/shadows/dynamicshadows.cpp | 8 | ||||
-rw-r--r-- | src/client/shadows/dynamicshadows.h | 3 | ||||
-rw-r--r-- | src/client/shadows/dynamicshadowsrender.cpp | 8 |
3 files changed, 7 insertions, 12 deletions
diff --git a/src/client/shadows/dynamicshadows.cpp b/src/client/shadows/dynamicshadows.cpp index 6ef5a4f1d..a45bf64fe 100644 --- a/src/client/shadows/dynamicshadows.cpp +++ b/src/client/shadows/dynamicshadows.cpp @@ -58,15 +58,13 @@ void DirectionalLight::createSplitMatrices(const Camera *cam) const v3f &viewUp = cam->getCameraNode()->getUpVector(); v3f viewRight = look.crossProduct(viewUp); - v3f farCorner = look + viewRight * tanFovX + viewUp * tanFovY; + v3f farCorner = (look + viewRight * tanFovX + viewUp * tanFovY).normalize(); // Compute the frustumBoundingSphere radius v3f boundVec = (camPos + farCorner * sfFar) - newCenter; - radius = boundVec.getLength() * 2.0f; + radius = boundVec.getLength(); // boundVec.getLength(); - float vvolume = radius * 2.0f; - + float vvolume = radius; v3f frustumCenter = newCenter; - // probar radius multipliacdor en funcion del I, a menor I mas multiplicador v3f eye_displacement = direction * vvolume; // we must compute the viewmat with the position - the camera offset diff --git a/src/client/shadows/dynamicshadows.h b/src/client/shadows/dynamicshadows.h index d8be66be8..03dd36014 100644 --- a/src/client/shadows/dynamicshadows.h +++ b/src/client/shadows/dynamicshadows.h @@ -22,6 +22,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "irrlichttypes_bloated.h" #include <matrix4.h> #include "util/basic_macros.h" +#include "constants.h" class Camera; class Client; @@ -67,7 +68,7 @@ public: /// Gets the light's far value. f32 getMaxFarValue() const { - return farPlane; + return farPlane * BS; } diff --git a/src/client/shadows/dynamicshadowsrender.cpp b/src/client/shadows/dynamicshadowsrender.cpp index a913a9290..528415aaf 100644 --- a/src/client/shadows/dynamicshadowsrender.cpp +++ b/src/client/shadows/dynamicshadowsrender.cpp @@ -118,12 +118,8 @@ size_t ShadowRenderer::getDirectionalLightCount() const f32 ShadowRenderer::getMaxShadowFar() const { if (!m_light_list.empty()) { - float wanted_range = m_client->getEnv().getClientMap().getWantedRange(); - - float zMax = m_light_list[0].getMaxFarValue() > wanted_range - ? wanted_range - : m_light_list[0].getMaxFarValue(); - return zMax * MAP_BLOCKSIZE; + float zMax = m_light_list[0].getMaxFarValue(); + return zMax; } return 0.0f; } |