Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The long awaited blending refactoring release 😉
We write release notes on the Github release page. But this release could use some extra explanation, I'll write it here for review, and will copy it to the release.
Introduction
This release represents a lot of work on refactoring how PyGfx deals with transparency. We recommend reading https://docs.pygfx.org/latest/transparency.html to learn how PyGfx works now.
The most important changes related to transparency:
The
renderer.blend_modeis no more. Some modes like the 'ordered2' and 'weighted_plus' no longer exist. Instead, you can now setmaterial.alpha_modeon each object separately. Yes, you can mix different modes in the same scene.It does mean that as a user you'll have to be a bit more aware of whether your objects are transparent, and how to approach that. In short, the default
material.alpha_mode='auto'works fine for opaque and most semi-transparent objects, as well as for objects that have mixed opaque/transparent fragments. But if you know your object is opaque, usealpha_mode='solid', and if it's transparent, usealpha_mode='blend'. For more context check https://docs.pygfx.org/latest/transparency.html#a-quick-guide-to-select-alpha-modeWe also changed some things on how we approach anti-aliasing:
renderer.pixel_scaleandrenderer.pixel_filter.renderer.ppaa.material.aafor text lines and points is now off by default, to prevent blending artifacts. Though we recommend turning it on for text for higher quality glyphs.API changes
Objects and materials:
WorldObject.render_mask.Material.alpha_mode, default is 'auto'..alpha_config,.alpha_method(settingalpha_modealso sets these).Material.render_queue, default is None (auto).Material.depth_write, default is None (auto).Material.alpha_test.Material.alpha_compare, default is "<".material.color_is_transparentforLine,Mesh,Points,Text. Usematerial.color.a < 1instead.material.edge_color_is_transparentforPoints. Usematerial.edge_color.a < 1instead.material.outline_color_is_transparentforText. Usematerial.outline_color.a < 1instead.Renderer:
Renderer.blend_mode.renderer.sort_objectsis True by default.renderer.effect_passes.renderer.ppaa.renderer.pixel_scale.renderer.pixel_filteris now a string instead of an int.renderer.clear()to clear render targets.Commits
Changes related to transparency and anti-aliasing:
Changes to the engine:
EXT_texture_webpsupport by @panxinmiao in AddEXT_texture_webpsupport #1155KHR_draco_mesh_compressionby @panxinmiao in SupportKHR_draco_mesh_compression#1159Other changes: