Skip to content

Commit

Permalink
Fix twice as wide alpha-to-coverage edge on circles, leading to artif…
Browse files Browse the repository at this point in the history
…acts (#2053)

* Fix twice as wide alpha-to-coverage edge on circles, leading to artifacts

* rename distance_pixel_difference to feathering_radius
  • Loading branch information
Wumpf committed May 5, 2023
1 parent 6c14940 commit 11aec5e
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions crates/re_renderer/shader/point_cloud.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,9 @@ fn vs_main(@builtin(vertex_index) vertex_idx: u32) -> VertexOut {
/// 2D primitives are always facing the camera - the difference to sphere_quad_coverage is that
/// perspective projection is not taken into account.
fn circle_quad_coverage(world_position: Vec3, radius: f32, circle_center: Vec3) -> f32 {
let to_center = circle_center - world_position;
let distance = length(to_center);
let distance_pixel_difference = fwidth(distance);
return smoothstep(radius + distance_pixel_difference, radius - distance_pixel_difference, distance);
let distance = distance(circle_center, world_position);
let feathering_radius = fwidth(distance) * 0.5;
return smoothstep(radius + feathering_radius, radius - feathering_radius, distance);
}

fn coverage(world_position: Vec3, radius: f32, point_center: Vec3) -> f32 {
Expand Down

0 comments on commit 11aec5e

Please sign in to comment.