google / neuroglancer

WebGL-based viewer for volumetric data
Apache License 2.0
1.07k stars 295 forks source link

feat: change the number of depth samples in volume rendering to a controllable UI parameter #495

Closed seankmartin closed 11 months ago

seankmartin commented 12 months ago

Goal

Change the number of depth samples from a fixed 64 to a user-controlled variable. Named "samples per ray".

Primary changes

  1. Create a UI controllable int, default 64, min 1, max 8096 that defines the samples per ray.
  2. On update of samples per ray we trigger a redraw and a recompute of the chunk priority, in case this change switches the desired data resolution level. The data resolution level is currently based on the depth of the view frustum divided by the number of samples.
  3. Pass the samples per ray into both the chunk worker and the shader to accommodate this.
  4. Control the samples per ray in Python.
google-cla[bot] commented 12 months ago

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

jbms commented 12 months ago

This definitely seems like a good option, but what do you think about using the existing "Resolution" control (that currently does nothing) but modifying it to display the different resolutions in units of "voxel size / view frustum depth"? That way this "Resolution" control would behave similarly to the other Resolution controls and would no longer be a "display only" control.

seankmartin commented 12 months ago

I really like that idea. My hope was that the implementation here would be a stepping stone to something more robust, and that is a good suggestion.

We'd essentially be changing up the logic from the resolution being determined by a user setting of the near and far planes and samples per ray, to the number of samples per ray being determined by a user setting of the near and far planes and resolution level. Am I understanding that right?

Edit: Maybe we want to still leave the number of samples modifiable so that one can over/under sample the actual data resolution if they want to.

jbms commented 12 months ago

To be clear, I was imagining that the actual user setting would still be number of samples, as you have it now, it would just be controlled using the (modified) "Resolution (3d)" control rather than a separate control. In order for that to make sense, the "Resolution (3d)" control would need to display the number of samples in log scale, and plot each resolution according to the number of samples that would be optimal for it, so that it displays in the correct position relative to the vertical bar that indicates the current "number of samples" selection.

seankmartin commented 11 months ago

Sure, I understand better now - I still like the idea!

I'll get to making that change in the coming days

jbms commented 11 months ago

Please resolve merge conflicts and then should be ready.

seankmartin commented 11 months ago

@jbms merge conflicts fixed!