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

2D primitives ordering/layering #1988

Closed
1 of 2 tasks
emilk opened this issue Apr 27, 2023 · 6 comments · Fixed by #2138
Closed
1 of 2 tasks

2D primitives ordering/layering #1988

emilk opened this issue Apr 27, 2023 · 6 comments · Fixed by #2138
Assignees
Labels
enhancement New feature or request 🐍 Python API Python logging API 🔺 re_renderer affects re_renderer itself 📺 re_viewer affects re_viewer itself 🦀 Rust API Rust logging API

Comments

@emilk
Copy link
Member

emilk commented Apr 27, 2023

We don't currently define which order 2D shapes are painted. Once we support more primitives like filled rectangles, circles, text etc, it will be very important to be able to specify what is on top of what.

We also need good default, e.g. images should probably be furthest down whatever happens.
We should maybe default to painters-algorithm (whatever is logged first is painted furthest back), as that is what many users are used to from e.g. opencv.

Let's investigate nomenclature other libraries and tools use.

  • Rust
  • Python
@emilk emilk added enhancement New feature or request 🐍 Python API Python logging API 🔺 re_renderer affects re_renderer itself 🦀 Rust API Rust logging API 📺 re_viewer affects re_viewer itself labels Apr 27, 2023
@emilk emilk changed the title 2D primitives Z/layering 2D primitives ordering/layering May 3, 2023
@emilk
Copy link
Member Author

emilk commented May 3, 2023

Let's avoid confusion by not calling this "Z". A depth-image contains Z-values, but can also have a draw-order/layer which is completely unrelated.

@emilk
Copy link
Member Author

emilk commented May 3, 2023

We should consider using defaults, like https://matplotlib.org/3.1.1/gallery/misc/zorder_demo.html does:

eg:

rgb image = 0,
depth image = 100
segmentation image = 200
rects/circles = 300
lines = 400
points = 500

@emilk
Copy link
Member Author

emilk commented May 3, 2023

Proposal: DrawOrder(f64) component for every 2D primitive.

Max one DrawOrder per entity path? i.e. a mono-component.

@emilk
Copy link
Member Author

emilk commented May 3, 2023

We should also have a default DrawOrder for all the 3D stuff projected into 2D, so that you can specify:

  • Paint my image
  • Project 3D stuff on top of the image
  • Paint these rectangles on top of everything else

I don't think wee need to do this for the first version, but keep it in mind.

@emilk
Copy link
Member Author

emilk commented May 3, 2023

Implementation:

For 2D views

Simple way:

Paint 2D stuff first, using the DrawOrder as a Z.
Then clear the Z, and draw the 3D stuff on top.

Does not support showing 2D stuff on top of 3D stuff, but that's ok for now.

More complex way:

Paint 3D stuff to a texture.
Paint every 2D primitive as well as the above texture, respectiting its alpha.

The ID buffer complicates this.

For 2D planes in 3D views

Take the all the DrawOrders and sort on them, to map them into integers.

Take these integers as the ZOffset for each primitive. This will push them back the minimal amount to not produce visible distance between them, making them still appear flat.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request 🐍 Python API Python logging API 🔺 re_renderer affects re_renderer itself 📺 re_viewer affects re_viewer itself 🦀 Rust API Rust logging API
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants