-
-
Notifications
You must be signed in to change notification settings - Fork 361
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
Add custom color mix functions for volume mapper fragment shader #3029
Conversation
When using independent components, and the first component was proportional, tColor.a was multiplied by pwfValue because of the line `tColor *= pwfValue;`. To avoid this kind of errors and make the code clearer, use a separte `vec3 tColor` and a `float alpha`.
Only one minor change to the logic: Enable complex lighting of dependent component rendering even when there is more than 1 component To disable it, set vtlLightComplexity to 0
The mixing of independent components is now done in function This function is very likely inlined by the compiler, it should not hurt performance Create the UseIndependentComponents preprocessor macro
Add an ADDITING preset
Move custom code computation to the volume property
Just need to add a preset for |
applyLighting(tColor0, normal0); | ||
applyLighting(tColor1, normal1); | ||
#endif | ||
vec3 mixedColor = mix(tColor0, tColor1, opacity1 / opacitySum); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I'm not understanding the big picture here.
How is this different from the current code where independent components are alpha-blended?
Secondly, this is not doing an additive blend, is it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we have alphas a0
and a1
, and colors c0
and c1
, then:
With alpha blending:
color = (c0 * a0 + (1 - a0) * c1 * a1 ) / alpha
alpha = a0 + (1 - a0) * a1
With additive mode:
color = (c0 * a0 + c1 * a1) / alpha
alpha = a0 + a1
Also how to create alpha blending with independent components in the current shader?
Do you suggest a different name instead or additive mode ?
This makes using user defined shader replacements possible The renderPass shader replacements are not implemented
Move the api specific code completely out of the VolumeProperty class
Add some documentation in the typescript header Make the GLSL code clearer
Makes the code a lot clearer and more flexible to be able to use it in colorMixPresets
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
🎉 This PR is included in version 29.9.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
The custom shader code is used to merge blend components
Presets can be used, I added an
ADDITING
preset that is useful when using medical images with labelsAlso added a test with 2 baselines