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 Buffer occasionally getting corrupted. #98758

Merged
merged 1 commit into from
Nov 10, 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
17 changes: 5 additions & 12 deletions modules/raycast/raycast_occlusion_cull.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,18 +90,11 @@ void RaycastOcclusionCull::RaycastHZBuffer::update_camera_rays(const Transform3D
td.camera_dir = -p_cam_transform.basis.get_column(2);
td.camera_orthogonal = p_cam_orthogonal;

Projection inv_camera_matrix = p_cam_projection.inverse();
Vector3 camera_corner_proj = Vector3(-1.0f, -1.0f, -1.0f);
Vector3 camera_corner_view = inv_camera_matrix.xform(camera_corner_proj);
td.pixel_corner = p_cam_transform.xform(camera_corner_view);

Vector3 top_corner_proj = Vector3(-1.0f, 1.0f, -1.0f);
Vector3 top_corner_view = inv_camera_matrix.xform(top_corner_proj);
Vector3 top_corner_world = p_cam_transform.xform(top_corner_view);

Vector3 left_corner_proj = Vector3(1.0f, -1.0f, -1.0f);
Vector3 left_corner_view = inv_camera_matrix.xform(left_corner_proj);
Vector3 left_corner_world = p_cam_transform.xform(left_corner_view);
// Calculate the world coordinates of the viewport.
Vector2 viewport_half = p_cam_projection.get_viewport_half_extents();
td.pixel_corner = p_cam_transform.xform(Vector3(-viewport_half.x, -viewport_half.y, -p_cam_projection.get_z_near()));
Vector3 top_corner_world = p_cam_transform.xform(Vector3(-viewport_half.x, viewport_half.y, -p_cam_projection.get_z_near()));
Vector3 left_corner_world = p_cam_transform.xform(Vector3(viewport_half.x, -viewport_half.y, -p_cam_projection.get_z_near()));
Comment on lines +95 to +97

This comment was marked as resolved.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has already been refactored the right way by #99974


td.pixel_u_interp = left_corner_world - td.pixel_corner;
td.pixel_v_interp = top_corner_world - td.pixel_corner;
Expand Down
Loading