Sorry, something went wrong.
|
Thanks! Will check this in detail later today, but I wanted to mention this: #754 We want to make alpha a separate graphic feature and thus an entirely independent Graphic property (in general we're trying to make the constructor as symmetric as possible with the settable properties, just like pygfx) . This would probably be a good time to do that? |
Sorry, something went wrong.
|
We want to make alpha a separate graphic feature and thus an entirely independent Graphic property Good to know this was already on the agenda! Yeah I think it makes sense both from an API perspective, but also technically; changing a color is fine, but changing an alpha value might affect how you want to blend things. |
Sorry, something went wrong.
|
Then they can set it to 0.999 to fix it. This seems a bit awkward. I foresee users would complain about having to do this.
From your list of options, this seems most straight forward.
After thinking about this for a while, I guess what I would expect from a 2D plotting library as a user:
I'm not sure if fastplotlib also does 3D plotting, but in that case I would expect it to behave as pygfx does naturally. By the way, I appreciate you calling for my thoughts, so I'm sharing them here, but I really have not been keeping up with fastplotlib's development for a while, so take it with a grain of salt. |
Sorry, something went wrong.
From your list of options, this seems most straight forward. I'm leaning towards this as well. After thinking about this for a while, I guess what I would expect from a 2D plotting library as a user:
When using an orthographic projection graphics are stacked in z. I'm not sure if fastplotlib also does 3D plotting, but in that case I would expect it to behave as pygfx does naturally. Everything is 3D just like pygfx, perspective camera for everything. We just don't have a high level API for meshes yet, I've rarely used meshes myself so I hope someone else would be able to contributre a high level API for that. Or maybe meshes are so specific that the pygfx level of abstraction is the best for it, I don't know yet. |
Sorry, something went wrong.
|
When using an orthographic projection graphics are stacked in z. Do you mean that the objects are offset in their ob.local.z? Is it possible to clearly identify whether the current graphic is in a 2D or 3D scene? If that is the case we could indeed default to blend. Or maybe meshes are so specific Haha!. Some Pygfx users consider meshes the "normal object" and think all the non-meshes are special 😉 |
Sorry, something went wrong.
|
When using an orthographic projection graphics are stacked in z. And what determines the stacking order? Insertion order? |
Sorry, something went wrong.
|
When using an orthographic projection graphics are stacked in z. Do you mean that the objects are offset in their ob.local.z? Yup! When using an orthographic projection graphics are stacked in z. And what determines the stacking order? Insertion order? Yup. Though the z can be set when added, or later at any time. Is it possible to clearly identify whether the current graphic is in a 2D or 3D scene? If that is the case we could indeed default to blend. If camera.fov == 0 You can switch between them and it's something I do all the time when looking at low dimensional projections with lines and scatters. |
Sorry, something went wrong.
|
Tests pass again! (or am I missing something?) |
Sorry, something went wrong.
|
oh lol, all tests are skipped 😆 |
Sorry, something went wrong.
|
📚 Docs preview built and uploaded! https://www.fastplotlib.org/ver/alpha |
Sorry, something went wrong.
|
How are you feeling about this refactor @almarklein, now that you can experience the revamped transparency system as a user? |
Sorry, something went wrong.
|
How are you feeling about this refactor @almarklein, now that you can experience the revamped transparency system as a user? I'm feeling pretty good about it in general. I felt rather disappointed that we cannot abstract the whole transparency thing away from the user. But after having done quite a bit of research on the topic I'm confident that even with the more advanced methods (which would consume more memory and/or be slower) it'd still not be fool proof. That's what it is. So the only way to go is to shove the problem on the user 😄 , but as gentle as possible, and providing multiple different options to deal with it. I think we've now now done that pretty well, providing pretty powerful options, but also easy-to-use shorthands with alpha_mode. As for this PR in Fastplotlib, I think it helps a lot if we can determine/assume the scene to be 2D, so we can just use 'blend'. If no object writes depth, Pygfx will not create the depth buffer, so it'd be a bit lighter too. |
Sorry, something went wrong.
|
if we can determine/assume the scene to be 2D, so we can just use 'blend'. If no object writes depth, Pygfx will not create the depth buffer, so it'd be a bit lighter too 3D is used often, easiest way to check is if camera.fov > 0 This will also need some refactoring of the graphic features, will add more thoughts soon |
Sorry, something went wrong.
|
I implemented a GraphicsFeature for alpha and alpha_mode. This indeed helps to make the code cleaner (less duplication). However, setting the alpha / alpga_mode in figure[0, 0].add_scatter(.. , alpha=0.07) does not work. While it does work for visible which is also a graphics feature. Any idea why? I may have missed some init step or something. |
Sorry, something went wrong.
|
However, setting the alpha / alpga_mode in figure[0, 0].add_scatter(.. , alpha=0.07) does not work. While it does work for visible which is also a graphics feature. Any idea why? I may have missed some init step or something. Fixed; these were set in _set_world_object() |
Sorry, something went wrong.
|
Also updated screenshots. Two examples have a diff above the threshold: image_widget_single_video and image_widget_videos. I tried copying the screenshots from the screenshots CI build, but the screenshots are the same (git status is empty). Any ideas? |
Sorry, something went wrong.
|
Also updated screenshots. Two examples have a diff above the threshold: image_widget_single_video and image_widget_videos. I tried copying the screenshots from the screenshots CI build, but the screenshots are the same (git status is empty). Any ideas? ImageWidget screenshots aren't being generated, that regeneration action is failing: https://github.com/fastplotlib/fastplotlib/actions/runs/18008358652/job/51234040316?pr=873 Must be because newer wgpu uses newer imgui, so I'm going to try and put the fastplotlib imgui option to just point to "wgpu[imgui]", will see if that works. |
Sorry, something went wrong.
|
updated to latest imgui, uses the new texture registering method, uses a merged font so regular text and font awesome icons can be used together without push/pop font. @almarklein I think one last thing is to set the render order so that axes lines and points are on top when camera.fov == 0, but not on top of any overlays: This is examples/gridplot/gridplot.py If it doesn't cause a performance hit you could put a check for camera.fov in Axes.update: if self._plot_area.camera.fov == 0:
# set render order for ruler line, points, text
else:
...
A better way might be if it's possible to add an event handler when camera.fov changes? |
Sorry, something went wrong.
|
All tests against pygfx@main are passing so I will merge, can do the axes thing in another PR, #903 The tests that are failing are all against the latest release of pygfx, which does not work with the latest imgui so it's fine to skip. |
Sorry, something went wrong.
Context
Previously, Pygfx automatically distinguished between opaque and transparent fragments on a per-fragment level. With the new blending in Pygfx (current main), this distinction will have to be made per object. This means that somewhere a decision will have to be made whether an object is opaque or transparent.
The PyGfx material.alpha_mode is the easy way to control this behavior. The two values that make the most sense for Fastplotlib are:
This PR uses 'blend' for all WorldObjects. We can use material.render_queue to control the order of axes, grids, legends etc, with respect to other objects. This means that they do not write to the depth buffer.
Using 'auto' would also work, but self-intersecting objects like noisy lines or scattered points would be prone to show artifacts in semi-transparent regions (e.g. the aa edge).
If we add support for 3D objects (e.g. meshes) these should probably use `alpha_mode='auto' or 'opaque'.
Places where users can introduce transparency
(Let me know if I missed one!)
Ideas (at the start of this PR)
Some ideas, some compatible, some mutually exclusive:
cc @Korijn because this is is a topic that touches both fpl and pygfx