Skip to content

Fix world grid not scaling correctly when camera is below the grid #9867

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

Merged
merged 1 commit into from
May 2, 2025
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions crates/viewer/re_renderer/shader/utils/plane.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ struct Plane {
}

/// How far away is a given point from the plane?
///
/// Returns a *signed* distance! Positive, when the point is above the plane, negative when below.
fn distance_to_plane(plane: Plane, point: vec3f) -> f32 {
return dot(plane.normal, point) - plane.distance;
}
2 changes: 1 addition & 1 deletion crates/viewer/re_renderer/shader/world_grid.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ struct VertexOutput {
@vertex
fn main_vs(@builtin(vertex_index) v_idx: u32) -> VertexOutput {
var out: VertexOutput;
let camera_plane_distance_world = distance_to_plane(config.plane, frame.camera_position);
let camera_plane_distance_world = abs(distance_to_plane(config.plane, frame.camera_position));

// Scale the plane geometry based on the distance to the camera.
// This preserves relative precision MUCH better than a fixed scale.
Expand Down
Loading