Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Occlusion culling jitter #99941

Merged
merged 1 commit into from
Dec 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions modules/raycast/raycast_occlusion_cull.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -536,8 +536,6 @@ Projection RaycastOcclusionCull::_jitter_projection(const Projection &p_cam_proj
return p_cam_projection;
}

Projection p = p_cam_projection;

int32_t frame = Engine::get_singleton()->get_frames_drawn();
frame %= 9;

Expand Down Expand Up @@ -577,11 +575,11 @@ Projection RaycastOcclusionCull::_jitter_projection(const Projection &p_cam_proj
// Higher divergence gives fewer false hidden, but more false shown.
// False hidden is obvious to viewer, false shown is not.
// False shown can lower percentage that are occluded, and therefore performance.
jitter *= Vector2(1 / (float)p_viewport_size.x, 1 / (float)p_viewport_size.y) * 0.05f;

p.add_jitter_offset(jitter);
jitter *= Vector2(1 / (float)p_viewport_size.x, 1 / (float)p_viewport_size.y) * 0.9f;

return p;
Projection correction;
correction.add_jitter_offset(jitter);
return correction * p_cam_projection;
}

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