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

Depth offset moves lines and points in (Web)GL #4787

Open
s-nie opened this issue Jan 11, 2024 · 4 comments
Open

Depth offset moves lines and points in (Web)GL #4787

s-nie opened this issue Jan 11, 2024 · 4 comments
Labels
🪳 bug Something isn't working 🔺 re_renderer affects re_renderer itself

Comments

@s-nie
Copy link

s-nie commented Jan 11, 2024

This may be related to #1025. There are also mentions of reduced depth precision with GL in the source code, but I couldn't find anything mentioning this specific issue.

While implementing a custom viewport based on re_renderer, I noticed a strange behavior when lines and points have a depth offset value. There seems to be some sort of parallax effect when the objects are not centered in the view. The effect is more pronounced the larger the offset value is. In the video below, I used a value of 200 for the manipulator gizmos and 0 for the spiral objects.

output.mp4

To Reproduce
Steps to reproduce the behavior:

  1. Create a viewport
  2. Add points and lines to it with different depth offsets
  3. Move the camera in the viewport
  4. Run in (web)GL

Expected behavior
The depth offset does not cause any translation based on the camera position. In the video above that would mean that the gizmos stay centered on the spirals.

Rerun version
0.12.0

Additional context
Things look as expected with the vulkan backend.

@s-nie s-nie added 👀 needs triage This issue needs to be triaged by the Rerun team 🪳 bug Something isn't working labels Jan 11, 2024
@Wumpf Wumpf added 🔺 re_renderer affects re_renderer itself and removed 👀 needs triage This issue needs to be triaged by the Rerun team labels Jan 11, 2024
@Wumpf
Copy link
Member

Wumpf commented Jan 11, 2024

Thanks for the report and the (pretty cool! :)) video documenting the behavior!
You're right this is related to

The depth offset works with literally offsetting on the z axis which has all sort of problems. One of them being that it works very poorly in WebGL where we have to use much bigger steps which is the reason you're seeing this issue on WebGL but not with Vulkan. This happens because WebGL is the only platform where the normalized-device-coordinates depth range goes from -1 to 1 which messes with our depth precision (in particular because the conversion is patched in via wgpu which always assumes 0 to 1).

it's not written down, but we want to get away from the depth offset and instead have a way to influence the actual draw ordering, making this also related to

@s-nie
Copy link
Author

s-nie commented Jan 11, 2024

Thanks for the quick response and explanation! Makes sense, then I'll know to be careful with depth offsets for now. Feel free to close this issue then, as the overarching issue is tracked in #1025 anyway.

Kudos for making re_renderer modular by the way, that made it super convenient to use without pulling in a mountain of dependencies :)

@Wumpf
Copy link
Member

Wumpf commented Jan 11, 2024

Let's keep it around, it's a good issue that highlights specific shortcomings that we haven't written down anywhere else :)

@emilk
Copy link
Member

emilk commented Jan 11, 2024

We haven't tested it I think, but based on Andreas' comment this should work much better on WebGPU

emilk added a commit that referenced this issue Jul 5, 2024
## What
* Closes #5315

## egui changelog

### ⭐ Added
* Add `Image::uri()` [#4720](emilk/egui#4720) by
[@rustbasic](https://github.com/rustbasic)

### 🔧 Changed
* Better documentation for `Event::Zoom`
[#4778](emilk/egui#4778) by
[@emilk](https://github.com/emilk)
* Hide tooltips when scrolling
[#4784](emilk/egui#4784) by
[@emilk](https://github.com/emilk)
* Smoother animations [#4787](emilk/egui#4787)
by [@emilk](https://github.com/emilk)
* Hide tooltip on click [#4789](emilk/egui#4789)
by [@emilk](https://github.com/emilk)

### 🐛 Fixed
* Fix default height of top/bottom panels
[#4779](emilk/egui#4779) by
[@emilk](https://github.com/emilk)
* Show the innermost debug rectangle when pressing all modifier keys
[#4782](emilk/egui#4782) by
[@emilk](https://github.com/emilk)
* Fix occasional flickering of pointer-tooltips
[#4788](emilk/egui#4788) by
[@emilk](https://github.com/emilk)

## eframe changelog
* Web: only capture clicks/touches when actually over canvas
[#4775](emilk/egui#4775) by
[@lucasmerlin](https://github.com/lucasmerlin)

## Checklist
* [x] I have read and agree to [Contributor
Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and
the [Code of
Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md)
* [x] I've included a screenshot or gif (if applicable)
* [x] I have tested the web demo (if applicable):
* Using examples from latest `main` build:
[rerun.io/viewer](https://rerun.io/viewer/pr/6785?manifest_url=https://app.rerun.io/version/main/examples_manifest.json)
* Using full set of examples from `nightly` build:
[rerun.io/viewer](https://rerun.io/viewer/pr/6785?manifest_url=https://app.rerun.io/version/nightly/examples_manifest.json)
* [x] The PR title and labels are set such as to maximize their
usefulness for the next release's CHANGELOG
* [x] If applicable, add a new check to the [release
checklist](https://github.com/rerun-io/rerun/blob/main/tests/python/release_checklist)!

- [PR Build Summary](https://build.rerun.io/pr/6785)
- [Recent benchmark results](https://build.rerun.io/graphs/crates.html)
- [Wasm size tracking](https://build.rerun.io/graphs/sizes.html)

To run all checks from `main`, comment on the PR with `@rerun-bot
full-check`.
emilk added a commit that referenced this issue Jul 5, 2024
## What
* Closes #5315

## egui changelog

### ⭐ Added
* Add `Image::uri()` [#4720](emilk/egui#4720) by
[@rustbasic](https://github.com/rustbasic)

### 🔧 Changed
* Better documentation for `Event::Zoom`
[#4778](emilk/egui#4778) by
[@emilk](https://github.com/emilk)
* Hide tooltips when scrolling
[#4784](emilk/egui#4784) by
[@emilk](https://github.com/emilk)
* Smoother animations [#4787](emilk/egui#4787)
by [@emilk](https://github.com/emilk)
* Hide tooltip on click [#4789](emilk/egui#4789)
by [@emilk](https://github.com/emilk)

### 🐛 Fixed
* Fix default height of top/bottom panels
[#4779](emilk/egui#4779) by
[@emilk](https://github.com/emilk)
* Show the innermost debug rectangle when pressing all modifier keys
[#4782](emilk/egui#4782) by
[@emilk](https://github.com/emilk)
* Fix occasional flickering of pointer-tooltips
[#4788](emilk/egui#4788) by
[@emilk](https://github.com/emilk)

## eframe changelog
* Web: only capture clicks/touches when actually over canvas
[#4775](emilk/egui#4775) by
[@lucasmerlin](https://github.com/lucasmerlin)

## Checklist
* [x] I have read and agree to [Contributor
Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and
the [Code of
Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md)
* [x] I've included a screenshot or gif (if applicable)
* [x] I have tested the web demo (if applicable):
* Using examples from latest `main` build:
[rerun.io/viewer](https://rerun.io/viewer/pr/6785?manifest_url=https://app.rerun.io/version/main/examples_manifest.json)
* Using full set of examples from `nightly` build:
[rerun.io/viewer](https://rerun.io/viewer/pr/6785?manifest_url=https://app.rerun.io/version/nightly/examples_manifest.json)
* [x] The PR title and labels are set such as to maximize their
usefulness for the next release's CHANGELOG
* [x] If applicable, add a new check to the [release
checklist](https://github.com/rerun-io/rerun/blob/main/tests/python/release_checklist)!

- [PR Build Summary](https://build.rerun.io/pr/6785)
- [Recent benchmark results](https://build.rerun.io/graphs/crates.html)
- [Wasm size tracking](https://build.rerun.io/graphs/sizes.html)

To run all checks from `main`, comment on the PR with `@rerun-bot
full-check`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🪳 bug Something isn't working 🔺 re_renderer affects re_renderer itself
Projects
None yet
Development

No branches or pull requests

3 participants