-
Notifications
You must be signed in to change notification settings - Fork 373
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
Improve the depth backprojection feature #1690
Merged
Merged
Changes from 17 commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
4df37f1
Replace the backproject scale with the familiar "meter"
emilk 61faf43
Assume depth images usually start at zero
emilk e18a1c5
Make the depth point radius scale more sane
emilk f783c0f
Fix an off-by-half error, giving all points an extra 0.5 pixels in ra…
emilk 89faaf8
Add a fudge-factor
emilk 8594073
Improve tooltip
emilk 9034c5c
Fix typos
emilk 5cb4e2d
Fix doclink
emilk 0317372
Fix the math
emilk a7fbbfc
fix typo
emilk 3deb14c
#[inline]
emilk ed32db8
Another typo
emilk 13d4844
typo
emilk 2b103f2
Adjust the feathering margins
emilk f661a25
Clean up the depth texture uploading
emilk 5603fa0
Better docs
emilk 37d8725
fix typos
emilk 4964a54
Use world depth values in the shader and simplify user code
emilk 0e72422
Better naming
emilk d5ee3c1
Fix bug in the image-hover code
emilk 51a21ac
Use same depth range for the color map in the depth projection shader
emilk 2c72031
Fix the gamma of the wgsl color map
emilk 8134e8a
Tweak default point radius to avoid Moiré patterns
emilk f489b2a
Final touches
emilk e321037
spell fix
emilk f2e1484
more typos
emilk 21cfdcf
Fix comment about why we use Depth16Unorm
emilk ea8c05e
Add lines to changelog
emilk ca8b777
max_depth -> max_depth_in_world
emilk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,9 @@ const COLORMAP_PLASMA: u32 = 3u; | |
const COLORMAP_MAGMA: u32 = 4u; | ||
const COLORMAP_INFERNO: u32 = 5u; | ||
|
||
/// Returns a gamma-space sRGB in 0-1 range. | ||
/// | ||
/// The input will be saturated to [0, 1] range. | ||
fn colormap_srgb(which: u32, t: f32) -> Vec3 { | ||
if which == COLORMAP_TURBO { | ||
return colormap_turbo_srgb(t); | ||
|
@@ -25,6 +28,13 @@ fn colormap_srgb(which: u32, t: f32) -> Vec3 { | |
} | ||
} | ||
|
||
/// Returns a linear-space sRGB in 0-1 range. | ||
/// | ||
/// The input will be saturated to [0, 1] range. | ||
fn colormap_linear(which: u32, t: f32) -> Vec3 { | ||
return linear_from_srgb(colormap_srgb(which, t)); | ||
} | ||
|
||
// --- Turbo color map --- | ||
|
||
// Polynomial approximation in GLSL for the Turbo colormap. | ||
|
@@ -38,7 +48,8 @@ fn colormap_srgb(which: u32, t: f32) -> Vec3 { | |
// Colormap Design: Anton Mikhailov ([email protected]) | ||
// GLSL Approximation: Ruofei Du ([email protected]) | ||
|
||
/// Returns a normalized sRGB polynomial approximation from Turbo color map, assuming `t` is | ||
/// Returns a gamma-space sRGB in 0-1 range. | ||
/// This is a polynomial approximation from Turbo color map, assuming `t` is | ||
/// normalized (it will be saturated no matter what). | ||
fn colormap_turbo_srgb(t: f32) -> Vec3 { | ||
let r4 = Vec4(0.13572138, 4.61539260, -42.66032258, 132.13108234); | ||
|
@@ -73,7 +84,8 @@ fn colormap_turbo_srgb(t: f32) -> Vec3 { | |
// | ||
// Data fitted from https://github.com/BIDS/colormap/blob/master/colormaps.py (CC0). | ||
|
||
/// Returns a normalized sRGB polynomial approximation from Viridis color map, assuming `t` is | ||
/// Returns a gamma-space sRGB in 0-1 range. | ||
/// This is a polynomial approximation from Viridis color map, assuming `t` is | ||
/// normalized (it will be saturated no matter what). | ||
fn colormap_viridis_srgb(t: f32) -> Vec3 { | ||
let c0 = Vec3(0.2777273272234177, 0.005407344544966578, 0.3340998053353061); | ||
|
@@ -87,7 +99,8 @@ fn colormap_viridis_srgb(t: f32) -> Vec3 { | |
return c0 + t * (c1 + t * (c2 + t * (c3 + t * (c4 + t * (c5 + t * c6))))); | ||
} | ||
|
||
/// Returns a normalized sRGB polynomial approximation from Plasma color map, assuming `t` is | ||
/// Returns a gamma-space sRGB in 0-1 range. | ||
/// This is a polynomial approximation from Plasma color map, assuming `t` is | ||
/// normalized (it will be saturated no matter what). | ||
fn colormap_plasma_srgb(t: f32) -> Vec3 { | ||
let c0 = Vec3(0.05873234392399702, 0.02333670892565664, 0.5433401826748754); | ||
|
@@ -101,7 +114,8 @@ fn colormap_plasma_srgb(t: f32) -> Vec3 { | |
return c0 + t * (c1 + t * (c2 + t * (c3 + t * (c4 + t * (c5 + t * c6))))); | ||
} | ||
|
||
/// Returns a normalized sRGB polynomial approximation from Magma color map, assuming `t` is | ||
/// Returns a gamma-space sRGB in 0-1 range. | ||
/// This is a polynomial approximation from Magma color map, assuming `t` is | ||
/// normalized (it will be saturated no matter what). | ||
fn colormap_magma_srgb(t: f32) -> Vec3 { | ||
let c0 = Vec3(-0.002136485053939582, -0.000749655052795221, -0.005386127855323933); | ||
|
@@ -115,7 +129,8 @@ fn colormap_magma_srgb(t: f32) -> Vec3 { | |
return c0 + t * (c1 + t * (c2 + t * (c3 + t * (c4 + t * (c5 + t * c6))))); | ||
} | ||
|
||
/// Returns a normalized sRGB polynomial approximation from Inferno color map, assuming `t` is | ||
/// Returns a gamma-space sRGB in 0-1 range. | ||
/// This is a polynomial approximation from Inferno color map, assuming `t` is | ||
/// normalized (it will be saturated no matter what). | ||
fn colormap_inferno_srgb(t: f32) -> Vec3 { | ||
let c0 = Vec3(0.0002189403691192265, 0.001651004631001012, -0.01948089843709184); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,9 +27,9 @@ fn sphere_quad_span_perspective( | |
let camera_offset = radius_sq * distance_to_camera_inv; | ||
var modified_radius = point_radius * distance_to_camera_inv * sqrt(distance_to_camera_sq - radius_sq); | ||
|
||
// We're computing a coverage mask in the fragment shader - make sure the quad doesn't cut off our antialiasing. | ||
// Add half a pixel of margin for the feathering we do for antialiasing the spheres. | ||
// It's fairly subtle but if we don't do this our spheres look slightly squarish | ||
modified_radius += frame.pixel_world_size_from_camera_distance * camera_distance; | ||
modified_radius += 0.5 * frame.pixel_world_size_from_camera_distance * camera_distance; | ||
Comment on lines
+30
to
+32
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thanks for following up on this. Given the previous change this should be safe, but have you checked if the point cloud in the multiview demo looks the exact same before after? (you can stop the movement with space and then take zoomed in screenshots if needed) |
||
|
||
return point_pos + pos_in_quad * modified_radius + camera_offset * quad_normal; | ||
|
||
|
@@ -48,9 +48,9 @@ fn sphere_quad_span_orthographic(point_pos: Vec3, point_radius: f32, top_bottom: | |
let quad_up = cross(quad_right, quad_normal); | ||
let pos_in_quad = top_bottom * quad_up + left_right * quad_right; | ||
|
||
// We're computing a coverage mask in the fragment shader - make sure the quad doesn't cut off our antialiasing. | ||
// Add half a pixel of margin for the feathering we do for antialiasing the spheres. | ||
// It's fairly subtle but if we don't do this our spheres look slightly squarish | ||
let radius = point_radius + frame.pixel_world_size_from_camera_distance; | ||
let radius = point_radius + 0.5 * frame.pixel_world_size_from_camera_distance; | ||
|
||
return point_pos + pos_in_quad * radius; | ||
} | ||
|
@@ -106,6 +106,6 @@ fn sphere_quad_coverage(world_position: Vec3, radius: f32, point_center: Vec3) - | |
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. | ||
// Note that we have signed distances to the sphere surface. | ||
return saturate(0.5 - distance_to_surface_in_pixels); | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
max_depth
being in world units catches me by surprise here