Skip to content

Commit

Permalink
Fix the sizes of small points
Browse files Browse the repository at this point in the history
  • Loading branch information
emilk committed Mar 23, 2023
1 parent e18a1c5 commit 1cf0f56
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions crates/re_renderer/shader/utils/sphere_quad.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,13 @@ fn sphere_quad_coverage(world_position: Vec3, radius: f32, point_center: Vec3) -
// https://www.shadertoy.com/view/MsSSWV
// (but rearranged and labeled to it's easier to understand!)
let d = ray_sphere_distance(ray, point_center, radius);
let smallest_distance_to_sphere = d.x;
let distance_to_sphere_surface = d.x;
let closest_ray_dist = d.y;
let pixel_world_size = approx_pixel_world_size_at(closest_ray_dist);

return 1.0 - saturate(smallest_distance_to_sphere / pixel_world_size);
let distance_to_surface_in_pixels = distance_to_sphere_surface / pixel_world_size;

// At the surface we have 50% coverage, and it decreases with distance.
// Not that we have signed distances to the sphere surface.
return saturate(0.5 - distance_to_surface_in_pixels);
}

0 comments on commit 1cf0f56

Please sign in to comment.