Skip to content

Commit 6960b33

Browse files
committed
Fix occlusion culling jitter
1 parent 893bbdf commit 6960b33

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

modules/raycast/raycast_occlusion_cull.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -536,8 +536,6 @@ Projection RaycastOcclusionCull::_jitter_projection(const Projection &p_cam_proj
536536
return p_cam_projection;
537537
}
538538

539-
Projection p = p_cam_projection;
540-
541539
int32_t frame = Engine::get_singleton()->get_frames_drawn();
542540
frame %= 9;
543541

@@ -577,11 +575,11 @@ Projection RaycastOcclusionCull::_jitter_projection(const Projection &p_cam_proj
577575
// Higher divergence gives fewer false hidden, but more false shown.
578576
// False hidden is obvious to viewer, false shown is not.
579577
// False shown can lower percentage that are occluded, and therefore performance.
580-
jitter *= Vector2(1 / (float)p_viewport_size.x, 1 / (float)p_viewport_size.y) * 0.05f;
581-
582-
p.add_jitter_offset(jitter);
578+
jitter *= Vector2(1 / (float)p_viewport_size.x, 1 / (float)p_viewport_size.y) * 0.9f;
583579

584-
return p;
580+
Projection correction;
581+
correction.add_jitter_offset(jitter);
582+
return correction * p_cam_projection;
585583
}
586584

587585
void RaycastOcclusionCull::buffer_update(RID p_buffer, const Transform3D &p_cam_transform, const Projection &p_cam_projection, bool p_cam_orthogonal) {

0 commit comments

Comments
 (0)