Skip to main content

Module blend

Module blend 

Source
Expand description

Blend modes for compositing nodes.

Two architectural buckets, mirroring PixiJS v8:

  • Standard modes are GPU-native — implemented via wgpu::BlendState per pipeline. A single render pass writes the final pixel; no intermediate texture is needed. Cheap.
  • Advanced modes can’t be expressed as a GPU blend equation because they need to read the backdrop and apply non-linear math (e.g. overlay = base < 0.5 ? 2·base·blend : …). Implemented as compositing filters via crate::render::Renderer::apply_advanced_blend: render the foreground into one render-texture, sample both backdrop and foreground in a fragment shader, write to a third render-texture. One offscreen pass per advanced-blended node.

Setting container.blend_mode = BlendMode::Overlay on a node and then rendering through render_stage doesn’t automatically trigger the offscreen path — render_stage falls back to the standard pipeline for advanced modes and tracing-warns once. The manual Renderer::apply_advanced_blend API is the way to get correct advanced-blend results today; automatic dispatch is queued for a follow-up chunk.

Enums§

BlendMode
Blend mode for compositing a renderable onto its target.