Open seankmartin opened 6 days ago
I put together this example showing how the shader can be additionally modified to make zero values (which in the fib25 dataset always indicate out-of-bounds) transparent, which in combination with this PR leads to a nicer visual effect:
It may be reasonable to just enable this behavior all the time, rather than add an option for it. I can't really think of a situation where displaying the out-of-bounds background is useful.
As a caveat, though, I will say that in general I find it not to be particularly useful to display the cross sections in the 3d views in actual usage --- mostly I have found the cross section display in the 3d view to be useful for screenshots, videos, and for demonstrating oblique slicing. Others that actually rely on cross section display in the 3d view for interactive use may have a better idea as to whether this change would be undesirable in some cases.
Thanks Jeremy for the context and the example! I can't confidently say that the ability to view the out-of-bound background is not useful. Though I agree that I don't have concrete examples of where it is particularly useful.
If we feel hesitant to remove the ability to view the out-of-bound background, then maybe the default could become that it is hidden. And there's a setting to turn on the ability to view the out-of-bound background - so the reverse of the flag in this PR currently.
Summary
This PR introduces a new global setting to optionally hide the background of 3D cross-sections in Neuroglancer. When activated, this setting allows users to view 3D slice projections without the background color, offering a less obstructed view of the data while still keeping the slice views in 3D on. Open to thoughts and suggestions on the functionality and implementation!
Default (background visible):
New Option (background hidden):
Motivation
When displaying slice views in 3D, the background of 2D cross-sections can sometimes appear prominently, especially when the user is zoomed out. This view can be useful but may also limit visibility of the 3D content itself. This feature provides the flexibility to hide the background in 3D, to improve visibility without turning off the section rendering completely. 2D cross-section views remain unaffected.
User interaction
In neuroglancer, this setting is available in the same panel where users toggle 3D view sections. It can also be enabled or disabled with the global "t" keybind (representing "Transparent"), selected to avoid overlap with existing shortcuts. Very open to suggestions on the keybind.
Implementation
The primary change is to the
SliceViewRenderHelper
class, and specifically the constructor and shader. The shader becomes a context and parameter dependent shader instead of a fixed shader. This allows the shader to change based on whether the user controlled setting is toggled on or off (the parameter to the memoized shader getter), and whether the render helper is for a cross-section view or projection view (the context).When the hide setting is on, and the rendering is for a projection view, if the alpha of the sampled cross-section texture is 0 in the fragment shader, instead of picking up the background color, the fragment is discarded.
Oblique slicing example
For clarity, here is an example with oblique slicing and a red projection background to illustrate the effects of this new setting.