Skip to content

Conversation

@almarklein
Copy link
Member

@almarklein almarklein commented Sep 3, 2025

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_mode is no more. Some modes like the 'ordered2' and 'weighted_plus' no longer exist. Instead, you can now set material.alpha_mode on 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, use alpha_mode='solid', and if it's transparent, use alpha_mode='blend'. For more context check https://docs.pygfx.org/latest/transparency.html#a-quick-guide-to-select-alpha-mode

We also changed some things on how we approach anti-aliasing:

  • The SSAA (super-sample anti-aliasing) that we already applied now uses an improved filter (the Mitchell filter). The same improved filter is also used for upsampling. Also see the new renderer.pixel_scale and renderer.pixel_filter.
  • We added support for PPAA (post-processing anti-aliasing) to improve the smoothness of the rendered result. It's enabled by default. See the new renderer.ppaa.
  • The material.aa for 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.
  • See https://docs.pygfx.org/latest/aa.html for details.

API changes

Objects and materials:

  • Removed WorldObject.render_mask.
  • Added Material.alpha_mode, default is 'auto'.
  • Adeded .alpha_config, .alpha_method (setting alpha_mode also sets these).
  • Added Material.render_queue, default is None (auto).
  • Added Material.depth_write, default is None (auto).
  • Added `Material.depth_compare, default is "<".
  • Added Material.alpha_test.
  • Added Material.alpha_compare, default is "<".
  • Removed material.color_is_transparent for Line, Mesh, Points, Text. Use material.color.a < 1 instead.
  • Removed material.edge_color_is_transparent for Points. Use material.edge_color.a < 1 instead.
  • Removed material.outline_color_is_transparent for Text. Use material.outline_color.a < 1 instead.

Renderer:

  • Removed Renderer.blend_mode.
  • The renderer.sort_objects is True by default.
  • The renderer's sorting logic is completely overhauled.
  • Added renderer.effect_passes.
  • Added renderer.ppaa.
  • Added renderer.pixel_scale.
  • The renderer.pixel_filter is now a string instead of an int.
  • Added renderer.clear() to clear render targets.

Commits

Changes related to transparency and anti-aliasing:

Changes to the engine:

Other changes:

@Korijn
Copy link
Collaborator

Korijn commented Sep 3, 2025

🤘 epic!

@hmaarrfk
Copy link
Contributor

hmaarrfk commented Sep 3, 2025

Very exciting!

@almarklein almarklein marked this pull request as ready for review September 5, 2025 10:23
@almarklein almarklein merged commit e032c64 into main Sep 5, 2025
13 checks passed
@almarklein almarklein deleted the bump branch September 5, 2025 10:25
@almarklein
Copy link
Member Author

🚀

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.

4 participants