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

Fix for 3D Blending. #440

Merged

Conversation

ilan-gold
Copy link
Collaborator

@ilan-gold ilan-gold commented May 25, 2021

Background

Previously our blending didn't work because we were not using the right WebGL settings. It should work pretty well now.

To test this out (or the previous non-functioning way of doing things), you can add another VolumeLayer to the VolumeView, but offset a bit:

  getLayers({ props }) {
    const { loader } = props;
    const { id } = this;

    const layers = [
      new VolumeLayer(props, {
        id: `${loader.type}${getVivId(id)}`
      }),
      new VolumeLayer(props, {
        id: `${loader.type}${getVivId(id)}-2`,
        modelMatrix: new Matrix4().rotateZ(.5).translate([250, 250, 0])
      })
    ];

    return layers;
  }

There are other things that we can do like depth testing and so forth to get different blending effects (besides this one) but those would require a change along the lines of this - in short, we would need to render each channel in its own individual layer and then combine them (similar to how we do for multi-modal data) so that we can track the depth at which each channel renders, which we currently cannot do (you only get one gl_FragDepth per fragment shader pass). The downside of this alternative approach is that the additive rendering mode does not look as nice from my testing and it would mean that we could not use global colormaps (i.e one colormap for many channels). FWIW I really like ours at the moment - the difference is that the opacity is per channel in this other approach whereas now it is global to all channels so it ends up looking more like maximum intensity projection in the alternative approach. This other option is more broadly related to #304 (comment) and if we do go that route, I think we should do it for our 2D layers as well. One reason to do depth testing is that it would allow us to overlay polygons/scale axis - without that information, WebGL does not know what goes in front vs back.

Here is what the alternative option would make our additive rendering mode look like (very similar to MIP):
Screen Shot 2021-05-25 at 4 08 17 PM

Change List

  • Add correct blending parameters to the VolumeLayer

Checklist

  • Update JSdoc types if there is any API change.
  • Make sure Avivator works as expected with your change.

@ilan-gold ilan-gold requested a review from manzt May 25, 2021 20:09
@ilan-gold ilan-gold merged commit 4a262f8 into ilan-gold/use_3d_tab_avivator May 26, 2021
@ilan-gold ilan-gold deleted the ilan-gold/minimal_3d_mixing_fix branch May 26, 2021 15:24
ilan-gold added a commit that referenced this pull request May 26, 2021
* Use tabs for controller.

* WRong disabled cpondition for volume button

* Change non-3d rendering mode display.

* Small style tweaks.

* Fix checkbox.  Small styling issues.

* Rename

* Add disabled styling.

* Add spacing.

* Fix slicer styling.

* Set bounding cube intiially.

* Add warning about WebGL2

* Remind to refresh page.

* Fix for 3D Blending. (#440)

* Minimal Fix for 3D Blending.

* Remove culling on layer

* Add comment.

* Prettier.
ilan-gold added a commit that referenced this pull request May 27, 2021
* 3D Viv Core (#409)

* Initial commit

* CHANGELOG.

* Address comments.

* Prettier.

* 3D Docs (#411)

* First pass at docs.

* Clean up.

* Add to docs.

* Spelling & brief docs.

* Change docs target

* Update docs/3D_RENDERING_BRIEF.md

Co-authored-by: Trevor Manz <trevor.j.manz@gmail.com>

Co-authored-by: Trevor Manz <trevor.j.manz@gmail.com>

* Fix 3D types/docs

* Remove header.

* Basic 3D Avivator (#412)

* Initial commit

* CHANGELOG.

* Address comments.

* Prettier.

* [WIP] Avivator first pass.

* Fix webpack config.

* Fix restricted syntax.

* 3D Non-Orthogonal Clipping Planes (#418)

* Initial commit

* CHANGELOG.

* Address comments.

* Prettier.

* [WIP] Avivator first pass.

* Add non-orthogonal clipping planes.

* Use `flat`

* Fix typo

* Fix numPlanes padding

* Fix plane equation.

* Use sign function instead of ceil

* Remove cast.

* Use Plane API

* Remove `numPlanes` argument.

* (For 3D) Avivator Refactor (#420)

* Initial commit

* CHANGELOG.

* Address comments.

* Prettier.

* [WIP] Avivator first pass.

* [WIP] State management, some updates to Avivator.

* [WIP] Adding more use of the global state.

* [WIP] More state replacement.

* Change color palette selector.

* Use imgae settings.

* Use viewer store.

* Clean up unnecessary Avivator props.

* Create self-contained buttons.

* Refactor main `useEffect` to use hooks.

* Fix snackbars.

* Refactor Viewer.

* Change names of buttons.

* Refactor Snackbars

* Remove unused vars.

* Refactor menu.

* Reset with new image.

* Fix linting error.

* Refactor props -> global state for dropzone components.

* Remove more unnecessary props.

* Colorpalette use global state.

* Refactor selections.

* Fix async selection bug.

* Fix viewState/initialViewState issue.

* Fix toggle.  Remove dead code.

* Small ids fix.

* Refactor channel stats.

* Use > instead of epsilon.

* Revert loader change.

* Fix import paths.

* Tweaks.

* Prettier.

* Fix state bug and lens display.

* Handle undefined loader in state.  Small entries suggestion.

* Reform state management.

* Small code compleixty change.

* Fix artifacts for additive.

* Small Features/Fixes for Viv Src (#422)

* Fixes for viv src

* Update src/layers/ImageLayer.js

Co-authored-by: Trevor Manz <trevor.j.manz@gmail.com>

* Prettier,

Co-authored-by: Trevor Manz <trevor.j.manz@gmail.com>

* New Avivator (#421)

* Initial commit

* CHANGELOG.

* Address comments.

* Prettier.

* [WIP] Avivator first pass.

* [WIP] State management, some updates to Avivator.

* [WIP] Adding more use of the global state.

* [WIP] More state replacement.

* Change color palette selector.

* Use imgae settings.

* Use viewer store.

* Clean up unnecessary Avivator props.

* Create self-contained buttons.

* Refactor main `useEffect` to use hooks.

* Fix snackbars.

* Refactor Viewer.

* Change names of buttons.

* Refactor Snackbars

* Remove unused vars.

* Refactor menu.

* Reset with new image.

* Fix linting error.

* Refactor props -> global state for dropzone components.

* Remove more unnecessary props.

* Colorpalette use global state.

* Refactor selections.

* Fix async selection bug.

* Fix viewState/initialViewState issue.

* Fix toggle.  Remove dead code.

* Small ids fix.

* Refactor channel stats.

* Use > instead of epsilon.

* Revert loader change.

* Fix import paths.

* Tweaks.

* Prettier.

* Styling.

* Slicers using polar coordinates.

* Merge branch 'ilan-gold/avivator_refactor' into ilan-gold/new_avivator

* Use epsilon value.

* Use better range of theta.

* onViewportLoad callbacks.

* Remove plane flip

* Move onViewportLoad to image settings.

* Set up isLoading callbacks.

* Fix AddChannel call backs.

* Allow options to be disabled as well.

* Simplify global selections

* AbortController for volume layer

* Only do keydown change selection

* Add delay to onViewportload prop for volumes

* Add slicer presets. Move slicer location.

* Fix Camera Axis.

* Debounce view state change.

* Fix coordinate system for volume.

* Change scaling of normal planes.

* Linting.

* Fix old merge issues

* Change coordinates of slicing

* Add isLoading for channel.

* Add isChannelLoading removal.

* Chane when channel is set to loading.

* Fix jsdocs. Small fix for volume button.

* Don't always use physical size scaling.

* Fix loader physical size inference.

* Make typescript happy.

* Small fix.

* Fix properties state bug.

* Fix rotation recentering.

* Use copy of clipping planes.

* Fixes for viv src

* Address comments.

* Slicing Reversion + New Demo Datasets (#430)

* Revert to orthogonal slicing.

* Add idr datasets

* Fix slicer styling.

* Small doc fixes.

* Add interpolation to 3D

* Add check for interpolation.

* prettier.

* Final Changes for Avivator (#434)

* Use tabs for controller.

* WRong disabled cpondition for volume button

* Change non-3d rendering mode display.

* Small style tweaks.

* Fix checkbox.  Small styling issues.

* Rename

* Add disabled styling.

* Add spacing.

* Fix slicer styling.

* Set bounding cube intiially.

* Add warning about WebGL2

* Remind to refresh page.

* Fix for 3D Blending. (#440)

* Minimal Fix for 3D Blending.

* Remove culling on layer

* Add comment.

* Prettier.

* Add progress indicator option + onUpdate callback. (#446)

Co-authored-by: Trevor Manz <trevor.j.manz@gmail.com>
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