FZJ-INM1-BDA / siibra-explorer

Apache License 2.0
21 stars 3 forks source link

Support for volume rendering #1417

Open PolarBean opened 9 months ago

PolarBean commented 9 months ago

This is a feature request for Siibra explorer to support Volumetric rendering with relevant information about that feature.

As of 2020 (see this commit https://github.com/google/neuroglancer/commit/a12552d03844fb6092cf300171d2f2077b3960e2) Neuroglancer has supported Volume Rendering. A guide can be found here on how to add this in the shader: https://github.com/google/neuroglancer/blob/master/src/neuroglancer/sliceview/image_layer_rendering.md#volume-rendering Essentially you set alpha to the same values as the data times some large value. here is a basic example:

void main () {
  float x = float(normalized());

  emitRGBA(vec4(x ,
               0,
              0,
               clamp(x*256.0,0.0,256.0)));
}

The reason for the multiplication is that is appears rgb values are between 0 and 1 whereas alpha values are between 0 and 256. The issue with increasing the alpha of only one value is this value effectively changes the opacity of the layer. Further visualisations will inevitably look better using a white background for the projection.

Here is an example of a dataset that has volume rendering enabled for some data https://tinyurl.com/2p9rfs8t You can see here that the 2D planes are overexposed however this can be fixed by dividing the opacity value by the constant which the alpha value has been multiplied by, in this case 256. https://tinyurl.com/yj9nt3ka

This view looks better however since every pixel has an individual opacity value it looks slightly different than the way it is rendered in siibra (here zero values are invisible but its a bit different from clamping since this achieved through gradually increasing opacity).

If siibra is updated to support this feature a choice would have to be made as to whether we just render volumes in the 2d view with per pixel opacities (which is fine IMO) or if the 2d view and 3d view are actually two seperate layers hidden from the user.

PolarBean commented 9 months ago

Oh the good news is the commit which added this feature was less than 2 months after the nehuba fork diverged :)

PolarBean commented 9 months ago

In case it is useful i created a fork at the relavant commit of neuroglancer: https://github.com/polarBean/neuroglancer/tree/volume-rendering