In native applications, implementing blend modes is straightforward — the GPU can read any previously rendered pixel directly to compute the blend result.
In WebGL, the framebuffer (the current rendering target) is write-only by default. Reading from it requires copying it to a readable texture, which is slow.
For elements using non-Normal blend modes, FlashFX uses one of two strategies:
Strategy A — Shader Compositing (preferred): The already-rendered background is copied to an offscreen texture before drawing the blend mode element. The element's shader reads from this texture and computes the blend in the same draw call.
Strategy B — Isolated Pass: The element is rendered to an offscreen buffer, then composited onto the background using a blend mode shader. Used for complex blend modes or groups with blend modes.
| Blend Mode | Implementation | Relative Cost |
|---|---|---|
| Normal | Native compositing | Baseline (1x) |
| Multiply, Screen, Overlay | Shader compositing | ~1.5x |
| Soft Light, Hard Light | Shader compositing | ~2x |
| Color Dodge, Burn | Shader compositing (requires per-channel computation) | ~2.5x |
| Difference, Exclusion | Shader compositing | ~2x |
| Hue, Saturation, Color, Luminosity | Shader compositing (requires HSL conversion) | ~3x |
| Any mode on group | Isolated pass | ~4x+ depending on group complexity |
These costs multiply with canvas resolution. A blend mode on a 4K canvas costs 4x more than the same blend mode on a 1080p canvas.
FlashFX warns when:
Beyond these thresholds, rendering performance degrades significantly on mid-range hardware.