rerun-io / rerun

Visualize streams of multimodal data. Free, fast, easy to use, and simple to integrate. Built in Rust.
https://rerun.io/
Apache License 2.0
6.52k stars 330 forks source link

Draw order & (order independent) transparency #702

Open Wumpf opened 1 year ago

Wumpf commented 1 year ago

Current situation

Currently we do not support sorting within a Renderer, instead all renderer have a fixed order. This is primarily an issue for supporting transparency as transparent objects (with (premultiplied) alpha blending) need to be at least be ordered back to front. Note that additive blended objects are order independent but still need to be drawn after all opaque objects.

Steps needed

If (!!) we're keeping the current monolithic Render approach, we can split the way to fully supporting transparency in two steps:

Pro/Con of fine grained object sorting

Sorting rendering primitives by distance to camera is very common in general purpose rendering engines! However, regardless of the other implications of an order independent transparency algorithm, not sorting within Renderer actually has both advantages and disadvantages:

Drawbacks:

Advantages:

Order Independent transparency (OIT)

Employing an OIT technique is partially independent of the question of draw order: As noted above draw order has advantages even with OIT in place but is no longer required then. Furthermore, depending on our expected scenes draw order alone will not solve alpha blending ordering issues either because our batches are not fine grained enough (i.e. a single draw has several front/back faces in line of sight) or triangles are overlapping (happens often in our case - e.g. line penetrating transparent box).

As our visualizations become more complex it seems to be unavoidable to employ at least one (maybe several for different situations or quality tiers) OIT technique. As this removes the sorting requirement, our database->renderer path could profit from being freed of the sorting limitation which is why making a directional decision here early can inform other design aspects of the renderer!

OIT techniques to evaluate

(WIP, trying to do rough families so far and do some early discarding)

emilk commented 1 year ago

We should consider doing something simple/stupid as a first step, something that is not order-independent. Just draw transparent objects last, for instance, just to get some of the transparency story done.

Famok commented 2 months ago

@Wumpf was the opacity implemented? Because the none of the opacity sliders seem to do anything, neither does setting an alpha value in RGBA values seem to have any effect.

Wumpf commented 2 months ago

@Famok this ticket is about implementing transparency and its prerequisites in Rerun. We have some very limited support, for example the opacity slider on images which is only really used for layering images on top of each other. If there's a bug with that please do file an issue!