forked from napari/napari
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update normal calculation for labels isosurface rendering (napari#7431)
# References and relevant issues From discussion on image.sc forum: https://forum.image.sc/t/napari-labels-layers-borders-displays-with-weird-shading/105499/1 # Description This modifies the 3D isosurface shader for the Labels layer in a few ways. The goal is to improve appearance of the 3D rendered labels. Specifically it should be improved at the boundaries of the volume (for both `fast` and `smooth` gradient modes) and for 1px thin labels (for `smooth` gradient mode). Changes include: * A new uniform to toggle what happens when sampling _outside_ the volume: * clamping to the edge (default, current behavior) * returning the background value * Update code to prevent dark surfaces in very thin (1px) labels * Add check for adjacent background pixels to the `smooth` gradient function * Update the gradient calculation to include an estimate of the local gradient instead of setting a default lambert term The configurable clamping behavior has the effect of giving labels "dark" (almost hollow-looking) or "filled" faces at the borders of the label volume. Currently this is controlled by a property on the `Volume` visual, but toggling is not exposed in the UI. I think at least @jni is requesting to be able to toggle this in the UI. In the animation below this is what the floating magicgui widget is toggling. I'm happy to wire that up in this PR if there's agreement, but I could use input on a name. We also need to choose a default. ![labels-edges-pr](https://github.com/user-attachments/assets/728505be-d212-417b-a29e-7228761ffed3) I did a quick benchmark test on my machine and did not see significant performance hit. I will try to do a longer test as well. Finally, I need to look a bit into what the "background value" is. Right now it's hard-coded in the shader, but it sounds like perhaps the `Labels` layer may be able to have a non-zero background. I want to make sure to support that or at least not cause a regression.
- Loading branch information
Showing
1 changed file
with
168 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters