Skip to content

Mesh/Sprite3d: blended (alpha) pass for soft-transparent 3D sprites #1516

Description

@obiot

Context

The 3D mesh pass is opaqueMeshBatcher.bind() does gl.disable(gl.BLEND). Sprite3d (#1513) handles transparency via an alpha cutout (alphaCutoff, default 0.5), which is correct and cheap for characters/foliage/signs (crisp silhouette, correct depth, no sorting).

But it can't do smooth alpha blending — soft particles, glows, fades, additive FX. Those need a blended, depth-sorted pass.

Proposal

Add an opt-in blended path for meshes/Sprite3d:

  • A blended draw mode (e.g. blend: true / a blend mode) that renders with BLEND enabled and depthMask(false) (depth-test on, depth-write off).
  • Back-to-front ordering for the blended set (the existing depth sort can drive this), drawn after the opaque pass.
  • Optional additive blend mode for glows.
  • Per-sprite opacity/alpha fade (currently impossible since alpha is ignored).

Considerations

  • Transparent ordering is inherently order-dependent; document the limitation (intersecting blended sprites won't resolve per-pixel).
  • Keep the opaque + cutout path the default (no perf regression for the common case).
  • WebGPU port shape should stay clean (the batcher already owns mesh-mode GL state).

Acceptance

  • A semi-transparent Sprite3d (e.g. spherical particle) blends smoothly instead of hard-cutting.
  • Per-sprite opacity fade works.
  • Renders after opaque, sorted back-to-front; opaque/cutout path unchanged.

Refs: "soft alpha blending" out-of-scope note from #1513; Working in 3D transparency caveat.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions