summaryrefslogtreecommitdiff
path: root/src/client/clientmap.cpp
diff options
context:
space:
mode:
authorx2048 <codeforsmile@gmail.com>2022-04-07 22:13:50 +0200
committerGitHub <noreply@github.com>2022-04-07 22:13:50 +0200
commit48f7c5603e5b2dfca941d228e76e452bc269a1fa (patch)
tree7983bb05e762792e38ba22a59e8718cac5381747 /src/client/clientmap.cpp
parent0b5b2b2633609f646a534d353a2c587af4be46fa (diff)
downloadminetest-48f7c5603e5b2dfca941d228e76e452bc269a1fa.tar.gz
minetest-48f7c5603e5b2dfca941d228e76e452bc269a1fa.tar.bz2
minetest-48f7c5603e5b2dfca941d228e76e452bc269a1fa.zip
Adjust shadowmap distortion to use entire SM texture (#12166)
Diffstat (limited to 'src/client/clientmap.cpp')
-rw-r--r--src/client/clientmap.cpp36
1 files changed, 10 insertions, 26 deletions
diff --git a/src/client/clientmap.cpp b/src/client/clientmap.cpp
index f070a58bb..8a059c922 100644
--- a/src/client/clientmap.cpp
+++ b/src/client/clientmap.cpp
@@ -862,20 +862,14 @@ void ClientMap::renderMapShadows(video::IVideoDriver *driver,
/*
Custom update draw list for the pov of shadow light.
*/
-void ClientMap::updateDrawListShadow(const v3f &shadow_light_pos, const v3f &shadow_light_dir, float shadow_range)
+void ClientMap::updateDrawListShadow(v3f shadow_light_pos, v3f shadow_light_dir, float radius, float length)
{
ScopeProfiler sp(g_profiler, "CM::updateDrawListShadow()", SPT_AVG);
- const v3f camera_position = shadow_light_pos;
- const v3f camera_direction = shadow_light_dir;
- // I "fake" fov just to avoid creating a new function to handle orthographic
- // projection.
- const f32 camera_fov = m_camera_fov * 1.9f;
-
- v3s16 cam_pos_nodes = floatToInt(camera_position, BS);
+ v3s16 cam_pos_nodes = floatToInt(shadow_light_pos, BS);
v3s16 p_blocks_min;
v3s16 p_blocks_max;
- getBlocksInViewRange(cam_pos_nodes, &p_blocks_min, &p_blocks_max, shadow_range);
+ getBlocksInViewRange(cam_pos_nodes, &p_blocks_min, &p_blocks_max, radius + length);
std::vector<v2s16> blocks_in_range;
@@ -889,10 +883,10 @@ void ClientMap::updateDrawListShadow(const v3f &shadow_light_pos, const v3f &sha
// they are not inside the light frustum and it creates glitches.
// FIXME: This could be removed if we figure out why they are missing
// from the light frustum.
- for (auto &i : m_drawlist) {
- i.second->refGrab();
- m_drawlist_shadow[i.first] = i.second;
- }
+ // for (auto &i : m_drawlist) {
+ // i.second->refGrab();
+ // m_drawlist_shadow[i.first] = i.second;
+ // }
// Number of blocks currently loaded by the client
u32 blocks_loaded = 0;
@@ -919,23 +913,13 @@ void ClientMap::updateDrawListShadow(const v3f &shadow_light_pos, const v3f &sha
continue;
}
- float range = shadow_range;
-
- float d = 0.0;
- if (!isBlockInSight(block->getPos(), camera_position,
- camera_direction, camera_fov, range, &d))
+ v3f block_pos = intToFloat(block->getPos() * MAP_BLOCKSIZE, BS);
+ v3f projection = shadow_light_pos + shadow_light_dir * shadow_light_dir.dotProduct(block_pos - shadow_light_pos);
+ if (projection.getDistanceFrom(block_pos) > radius)
continue;
blocks_in_range_with_mesh++;
- /*
- Occlusion culling
- */
- if (isBlockOccluded(block, cam_pos_nodes)) {
- blocks_occlusion_culled++;
- continue;
- }
-
// This block is in range. Reset usage timer.
block->resetUsageTimer();