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

Changed calculation for range clipping #325

Merged
merged 9 commits into from
Aug 3, 2021
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
3 changes: 3 additions & 0 deletions Migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ release will remove the deprecated code.
`Node::UserData` now returns no data for keys that don't exist (prior to Rendering 6.x, if
`Visual::UserData` was called with a key that doesn't exist, an `int` was returned by default).

1. **depth_camera_fs.glsl** and **depth_camera_final_fs.glsl**
+ Far clipping changed from clipping by depth to clipping by range, i.e. distance to point, so that the data generated will never exceed the specified max range of the camera.

## Ignition Rendering 4.0 to 4.1

## ABI break
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ void main()
// to be outside of min/max range

// clamp xyz
if (point.x > far - tolerance)
if (!isinf(point.x) && length(point) > far - tolerance)
{
if (isinf(max))
{
Expand Down
2 changes: 1 addition & 1 deletion ogre2/src/media/materials/programs/depth_camera_fs.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ void main()
}

// clamp xyz and set rgb to background color
if (point.x > far - tolerance)
Copy link
Contributor

Choose a reason for hiding this comment

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

can you make the same change to depth_camera_final_fs.glsl?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor Author

@Lobotuerk Lobotuerk Jul 8, 2021

Choose a reason for hiding this comment

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

Changing both that and https://github.com/ignitionrobotics/ign-rendering/blob/lobotuerk/depthRangeChange/test/integration/depth_camera.cc#L309-L311 tomaxVal make all tests pass, but I don't think that makes sense

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the problem is that because point was previously clamped to -inf so length(point) becomes +inf. So in depth_camera_final_fs.glsl we can change to something like:

if (!isinf(point.x) && length(point) > far - tolerance)

which just skips this additional clamping if it's already been clamped in the previous pass.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

34267e4 should take care of this

if (length(point) > far - tolerance)
{
if (isinf(max))
{
Expand Down