Skip to content

Per-sprite multi-pass post-effects with dedicated FBOs #1406

@obiot

Description

@obiot

Summary

Multi-pass post-effects on individual sprites/renderables (not cameras) require dedicated sprite-sized FBOs. Currently, per-sprite multi-pass uses the full-canvas FBO which causes the effect to cover the entire screen instead of just the sprite.

Problem

When a sprite has multiple postEffects, beginPostEffect binds the same full-canvas FBO used by cameras. The sprite renders at its world position inside this large FBO, but the blit quad covers the entire canvas. Effects that modify transparent areas (hologram scanlines, etc.) affect the whole screen.

Additionally, per-sprite FBO capture nests inside the camera's FBO capture, causing conflicts with the shared _currentEffectFBO.

Required Changes

  • Dedicated sprite-sized FBO pool (similar to PixiJS RenderTexturePool)
  • Determine sprite screen bounds before FBO capture
  • Set up projection that maps sprite bounds to FBO [0, w] × [0, h]
  • Blit result at sprite's screen position with alpha blending
  • Handle FBO nesting (sprite FBO inside camera FBO)

Current State

References

  • PixiJS FilterSystem with sourceFrame/destinationFrame and RenderTexturePool
  • beginPostEffect/endPostEffect in webgl_renderer.js
  • preDraw/postDraw in renderable.js

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