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

Feat: option to hide cross section background in 3D slice views #45

Open
wants to merge 17 commits into
base: master
Choose a base branch
from

Conversation

seankmartin
Copy link

@seankmartin seankmartin commented Nov 1, 2024

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):

image

New Option (background hidden):

image

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.

image

@seankmartin seankmartin requested a review from aranega November 1, 2024 10:37
Copy link
Member

@aranega aranega left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All looks good to me :) !

Copy link
Member

@aranega aranega left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All looks good to me :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants