diff options
author | Rudolph Bester <Rudolph.f.bester@gmail.com> | 2024-10-06 18:54:18 +0200 |
---|---|---|
committer | Rudolph Bester <Rudolph.f.bester@gmail.com> | 2024-10-17 05:59:37 +0200 |
commit | ed3f990952c11c742fc4cc412caa7368efef3fa1 (patch) | |
tree | 8ea18f2fab8146d149f00854664dc6101c774d02 /servers | |
parent | f4af8201bac157b9d47e336203d3e8a8ef729de2 (diff) | |
download | redot-engine-ed3f990952c11c742fc4cc412caa7368efef3fa1.tar.gz |
Alternative fix to occlusion culling where all math is based on Euclidean distance.
Diffstat (limited to 'servers')
-rw-r--r-- | servers/rendering/renderer_scene_occlusion_cull.h | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/servers/rendering/renderer_scene_occlusion_cull.h b/servers/rendering/renderer_scene_occlusion_cull.h index df403c5484..0ef92dd9ff 100644 --- a/servers/rendering/renderer_scene_occlusion_cull.h +++ b/servers/rendering/renderer_scene_occlusion_cull.h @@ -72,7 +72,7 @@ public: return false; } - float min_depth = -closest_point_view.z * 0.95f; + float min_depth = (closest_point - p_cam_position).length(); Vector2 rect_min = Vector2(FLT_MAX, FLT_MAX); Vector2 rect_max = Vector2(FLT_MIN, FLT_MIN); @@ -83,6 +83,10 @@ public: Vector3 corner = Vector3(p_bounds[0] * c.x + p_bounds[3] * nc.x, p_bounds[1] * c.y + p_bounds[4] * nc.y, p_bounds[2] * c.z + p_bounds[5] * nc.z); Vector3 view = p_cam_inv_transform.xform(corner); + if (p_cam_projection.is_orthogonal()) { + min_depth = MIN(min_depth, view.z); + } + Plane vp = Plane(view, 1.0); Plane projected = p_cam_projection.xform4(vp); |