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 spherical markers depth buffer with scaling='visual' #2506

Merged
merged 2 commits into from Jul 5, 2023

Conversation

brisvag
Copy link
Collaborator

@brisvag brisvag commented Jun 30, 2023

When we introduced the new visual scaling for markers in #2359 (later tweaked in #2470), we forgot to do the same changes in the depth buffer calculation. This lead to a mismatch between depth size and actual size. See this example in napari where with high scaling we end up with sphere that "merge" when overlapping, rather than simply obscuring each other as they should:

balls_mering.mp4

This PR makes sure everything is calculated the same way. To avoid having many if/else and making it easier to maintain, I also moved the logic for choosing the scaling "mode" to outside the shader.

Copy link
Member

@djhoese djhoese left a comment

Choose a reason for hiding this comment

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

Ok so this is not only a fix (specifically in the if u_spherical == true part I'm guessing?) but also just a general cleanup of the code. Put another way, the main fix is that the correct transformation is applied to the spherical == true block in the shader, right?

self._scaling = value
self._scaling_int = scaling_int
self._scaling_mode = scaling_modes[value]
Copy link
Member

Choose a reason for hiding this comment

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

Is there any need for a separate _scaling_mode and _scaling now that an integer isn't based to the shader?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If we want to retain the ability to do:

marker.scaling = False
assert marker.scaling == False

Otherwise we'd get:

marker.scaling = False
assert marker.scaling == 'fixed'

I'd be ok with the latter, but I thought you wanted to retain the previous behaviour in #2470?

Copy link
Member

Choose a reason for hiding this comment

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

I think I was hoping for backwards compatibility with someone setting it to False/True. My comment here is to say that self._scaling and self._scaling_mode are now the same for users specifying the new flags. If someone is doing assert marker.scaling == X then I personally am OK with that failing now. But maybe I'm misremembering what I said before.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yeah for the new flags those are identical, but I agree it's nicer to just ditch the true/false otherwise.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated to only keep the new value.

@brisvag
Copy link
Collaborator Author

brisvag commented Jun 30, 2023

Put another way, the main fix is that the correct transformation is applied to the spherical == true block in the shader, right?

Yup! And also in the spherical part.

@brisvag
Copy link
Collaborator Author

brisvag commented Jul 5, 2023

Is this ready to go in @djhoese?

@djhoese djhoese merged commit c166eac into vispy:main Jul 5, 2023
15 checks passed
@brisvag brisvag mentioned this pull request Sep 8, 2023
brisvag added a commit to napari/napari that referenced this pull request Oct 4, 2023
# Description

Just a simple bump to our vispy dependency, now that 0.14 is out. This
comes with a few fixes and new features relevant for napari:

- Fix for wrong spherical marker depth:
vispy/vispy#2506
- Fix for wrong shading of surfaces with flipped normals:
vispy/vispy#2493
- picking filters for mesh and markers by @aganders, which can now be
used in napari to drastically speed up our get-status:
vispy/vispy#2500

---------

Co-authored-by: Grzegorz Bokota <bokota+github@gmail.com>
Co-authored-by: napari-bot <napari-bot@users.noreply.github.com>
Czaki added a commit to napari/napari that referenced this pull request Oct 17, 2023
Just a simple bump to our vispy dependency, now that 0.14 is out. This
comes with a few fixes and new features relevant for napari:

- Fix for wrong spherical marker depth:
vispy/vispy#2506
- Fix for wrong shading of surfaces with flipped normals:
vispy/vispy#2493
- picking filters for mesh and markers by @aganders, which can now be
used in napari to drastically speed up our get-status:
vispy/vispy#2500

---------

Co-authored-by: Grzegorz Bokota <bokota+github@gmail.com>
Co-authored-by: napari-bot <napari-bot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants