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(labelOutline): Add outlineOpacity to labelOutline #2093

Merged
merged 4 commits into from
Oct 13, 2022

Conversation

sedghi
Copy link
Contributor

@sedghi sedghi commented Oct 6, 2021

PR and Code Checklist

  • semantic-release commit messages
  • Run npm run reformat to have correctly formatted code

Context

This PR adds outline opacity for the labelOutline property of the volumeMapper

Changes

outlineOpacity with default value of 1.0 is added to the volumeMapper for labelOutline usage

Results

without outlineOpacity

with outlineOpacity = 0.9

However, I observed a non-linear relationship between opacity levels. For example, any opacity below 0.8 is nearly transparent, and the difference between 0.9 and 0.99 is considerable.

I think the behaviour is as a result of here when alpha is subtracted by a pow function (which makes it non-linear).

tColor.a = 1.0 - pow(1.0 - tColor.a, jitter);

Any thoughts on this?

Testing

  • This change adds or fixes unit tests
  • All tests complete without errors on the following environment:
    • vtk.js: latest master
    • OS: MacOS
    • Browser: Chrome 94.0.4606.71

@@ -465,7 +466,7 @@ vec4 getColorForValue(vec4 tValue, vec3 posIS, vec3 tstep)

// If I am on the border, I am displayed at full opacity
Copy link
Member

Choose a reason for hiding this comment

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

technically this comment is not 100% correct

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is this because it is not the final place opacity is calculated?

Copy link
Member

@finetjul finetjul Oct 12, 2021

Choose a reason for hiding this comment

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

Sorry, I only meant that this comment should be updated because it used to be true "full opacity", but with your change, it may not be "full opacity", it depends on outlineOpacity

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see, I will change it.
I was wondering if you have any feedback on the non-linear behaviour of the opacity?

Thanks

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Opacity of a volume is nonlinear. Specifically in volume rendering opacity is interpreted in terms of opacity per unit distance. When you need to take an interval of a volume (say 3mm of a ray) and convert that to opacity you use a power function to accumulate the opacity over the interval.

For example if your opacity is 0.5/mm and the interval is 3mm long then the opacity is 1.0 - pow(1.0 - 0.5, 3) or 0.875

You shouldn't use that pow function for your opacity. Mixing apples and oranges.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@martinken Thanks for your explanation. So based on my understanding there is no way to have the outlineThickness (in the above images) act linearly to the opacity. Correct me please if I'm wrong.

@floryst
Copy link
Collaborator

floryst commented Nov 15, 2021

What's the status on this PR? @martinken @sedghi

@sedghi
Copy link
Contributor Author

sedghi commented Oct 4, 2022

@floryst @martinken Hey guys, can we revisit this for merge? thanks!

@floryst
Copy link
Collaborator

floryst commented Oct 5, 2022

Does the opacity parameter have the final desired behavior? I presume it still acts nonlinearly as shown in your screenshots.

@sedghi
Copy link
Contributor Author

sedghi commented Oct 5, 2022

Yeah it is nonlinear in the current composite blend mode (as Ken mentioned), this PR only adds the API for setting the opacity, the blend mode implementation in the shader decides on how the opacity behave. In near future, I'll add another PR to add a new Blend mode maybe for Labelmap which don't go through the normal composite volume rendering route which applies the non linear formula and we just use that for the Labelmap

Update: the current opacity function for the labelmap is also non-linear so this PR is not adding any unexpected behaviour regarding labelmaps

@floryst
Copy link
Collaborator

floryst commented Oct 10, 2022

LGTM. @finetjul if you want to do a last check

@finetjul
Copy link
Member

LGTM

@floryst floryst merged commit 9bcbc64 into Kitware:master Oct 13, 2022
@github-actions
Copy link

🎉 This PR is included in version 25.9.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@github-actions github-actions bot added the released Automated label label Oct 13, 2022
@github-actions
Copy link

🎉 This PR is included in version 26.0.0-beta.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

@github-actions github-actions bot added the released on @beta Automated label label Nov 29, 2022
@sedghi
Copy link
Contributor Author

sedghi commented Nov 29, 2022

@floryst @finetjul You Github actions seem to be running twice?

@floryst
Copy link
Collaborator

floryst commented Nov 29, 2022

That's my bad. I ended up pushing a master->beta merge. It doesn't cause any actual issues, apart from email spam.

@sedghi
Copy link
Contributor Author

sedghi commented Nov 29, 2022

@floryst Oh no worries, just wanted to let you know

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

Successfully merging this pull request may close these issues.

None yet

4 participants