diff options
author | lawnjelly <lawnjelly@gmail.com> | 2024-05-10 09:13:05 +0100 |
---|---|---|
committer | lawnjelly <lawnjelly@gmail.com> | 2024-05-10 09:13:05 +0100 |
commit | a76243a54963910f5d172fe1a4f6b320dba69db1 (patch) | |
tree | cf504fed6fe0367a40388861c2b7f6603e5a7d53 | |
parent | da5714ad6eaa9dd34209f0ff568eb779cae689f2 (diff) | |
download | redot-engine-a76243a54963910f5d172fe1a4f6b320dba69db1.tar.gz |
Tighter light culling - fix directional lights colinear case
Exactly the same fix as done already for non-directional lights.
-rw-r--r-- | servers/rendering/rendering_light_culler.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/servers/rendering/rendering_light_culler.cpp b/servers/rendering/rendering_light_culler.cpp index 0889898f0b..8dc2d85bdf 100644 --- a/servers/rendering/rendering_light_culler.cpp +++ b/servers/rendering/rendering_light_culler.cpp @@ -279,9 +279,11 @@ bool RenderingLightCuller::add_light_camera_planes_directional(LightCullPlanes & // Create a third point from the light direction. Vector3 pt2 = pt0 - p_light_source.dir; - // Create plane from 3 points. - Plane p(pt0, pt1, pt2); - r_cull_planes.add_cull_plane(p); + if (!_is_colinear_tri(pt0, pt1, pt2)) { + // Create plane from 3 points. + Plane p(pt0, pt1, pt2); + r_cull_planes.add_cull_plane(p); + } } // Last to 0 edge. @@ -295,9 +297,11 @@ bool RenderingLightCuller::add_light_camera_planes_directional(LightCullPlanes & // Create a third point from the light direction. Vector3 pt2 = pt0 - p_light_source.dir; - // Create plane from 3 points. - Plane p(pt0, pt1, pt2); - r_cull_planes.add_cull_plane(p); + if (!_is_colinear_tri(pt0, pt1, pt2)) { + // Create plane from 3 points. + Plane p(pt0, pt1, pt2); + r_cull_planes.add_cull_plane(p); + } } #ifdef LIGHT_CULLER_DEBUG_LOGGING |