Skip to content

Tweaks to adjust to new pygfx blending #838

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

Merged
merged 7 commits into from
Jul 17, 2025
Merged

Tweaks to adjust to new pygfx blending #838

merged 7 commits into from
Jul 17, 2025

Conversation

almarklein
Copy link
Collaborator

For upcoming pygfx/pygfx#1002

May not be complete, can leave open until the pygfx-pr is merged.

@@ -560,6 +560,11 @@ def _render(self, draw=True):
# draw the underlay planes
self.renderer.render(self._underlay_scene, self._underlay_camera, flush=False)

# With new pygfx' blending, the depth buffer is only cleared after each flush, we need a manual depth
# clear to erase the depth values set by the underlay.
Copy link
Member

Choose a reason for hiding this comment

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

what about the overlay?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good point, you may want to use a different depth range in the camera, so that the fragments all have a very small depth value, so they don't get behind stuff in the scene. Or simply disable depth-tests.

Copy link
Collaborator Author

@almarklein almarklein May 28, 2025

Choose a reason for hiding this comment

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

Or you can clear the depth buffer again, if you don't need it for post processing or things like that.

Copy link
Member

Choose a reason for hiding this comment

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

What are depth tests? Is there a performance difference between this or clearing again? What's your recommendation, I'm not too familiar with how the depth buffer works in this context, only how it's important for knowing what objects are above what in a 3D scene. Eventually the overlay scene will probably have axes when using an orthographic projection, along with legends etc.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The depth test makes sure that objects are not occluded by objects that are behind it (but are rendered later).

The depth buffer needs to be cleared before using it, otherwise the depth test makes no sense. Since there is an underlay pass and an overlay pass, we need extra manual clears.

I added a clear before the overlay pass. That's definitely the simplest solution. The only caveat is that if users want access to the depth buffer (of the scene) they can't because the depth buffer will represent the content of the overlay. If we ever want to change that, we can look into that later. There are more upcoming changes in pyfx that will likely make that easier.

Copy link
Member

Choose a reason for hiding this comment

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

The only caveat is that if users want access to the depth buffer (of the scene) they can't because the depth buffer will represent the content of the overlay. If we ever want to change that, we can look into that later. There are more upcoming changes in pyfx that will likely make that easier.

do you want to make a note of it in the pygfx issue if you don't have this planned already?

@kushalkolar
Copy link
Member

I think this should be merged soon after we decide how to deal with the depth buffer for the overlay pass?

@almarklein
Copy link
Collaborator Author

There are some more upcoming changes. I'll likely make some more changes this week.

@almarklein almarklein marked this pull request as ready for review July 3, 2025 13:31
@almarklein almarklein requested a review from clewis7 as a code owner July 3, 2025 13:31
@almarklein
Copy link
Collaborator Author

Let's merge this, so we keep main working. I'll just open a new PR if new stuff arises.

@kushalkolar
Copy link
Member

Failures are due to pygfx/wgpu-py#723

And I think due to AA being disabled for tests now? Some diffs below:

diff-rect_frac_layout-rgb

diff-line_cmap_more-rgb

@almarklein
Copy link
Collaborator Author

almarklein commented Jul 4, 2025

The image tests fail because the downsample filter is changed (to go from hirez to target rez). So indeed related to SSAA. See pygfx/pygfx#1121

@almarklein
Copy link
Collaborator Author

AA being disabled for tests now

The env var that disables PPAA is for a different kind of aa 😉, which has not been merged yet (at the time of writing): pygfx/pygfx#1117 That env var will make sure that the screenshots don't change when that PR is in effect.

Copy link

github-actions bot commented Jul 4, 2025

📚 Docs preview built and uploaded! https://www.fastplotlib.org/ver/pygfx-blending

@kushalkolar
Copy link
Member

The image tests fail because the downsample filter is changed (to go from hirez to target rez). So indeed related to SSAA. See pygfx/pygfx#1121

So if I update the ground truth screenshots good to go!?

@almarklein
Copy link
Collaborator Author

So if I update the ground truth screenshots good to go!?

I'm half wondering if I want to add a similar env var to override the pixel_ratio for screenshot tests, now that we have to update all screenshots ... I'm sorry it takes so long. Is this stopping other prs from progressing?

@kushalkolar
Copy link
Member

kushalkolar commented Jul 17, 2025

This is weird, seems like only the regenerated screenshots with imgui in the environment don't have AA, whereas the environments without imgui do:

EDIT: ok now I understand how github actions pushes generated screenshots artifacts. If an image hasn't been re-generated it still gets sent because it exists in the repo already. I should do separate dirs for imgui and non-imgui screenshots or filter what's upload to the artifact.

Copy link
Member

@kushalkolar kushalkolar left a comment

Choose a reason for hiding this comment

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

merging, now main requires pygfx@main too

@kushalkolar kushalkolar merged commit 11fed41 into main Jul 17, 2025
28 of 52 checks passed
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