Skip to content

Post-effect FBO should capture lights and ambient overlays #1398

@obiot

Description

@obiot

Summary

Currently, camera post-effects only capture the scene content (world container). The stage's lighting passes — ambient light overlay and Light2d rendering — happen after camera.draw() returns in Stage.draw() (see src/state/stage.ts:149-175), so post-effects like vignette or scanlines don't affect the lighting output.

The expected behavior is that post-effects wrap the entire per-camera render including all passes.

Current flow (per camera in Stage.draw)

camera.draw(renderer, world)
  → beginPostEffect(this)   // FBO bound
  → render scene into FBO
  → endPostEffect(this)     // FBO unbound, blit with shader
// lights render AFTER the FBO is already composited to screen
ambientLight overlay
Light2d rendering

Expected flow (per camera)

camera.draw(renderer, world)
  → beginPostEffect(this)   // FBO bound
  → render scene into FBO
  → render ambient light     // also into FBO
  → render Light2d           // also into FBO
  → endPostEffect(this)     // FBO unbound, blit with shader

Proposed Solution

Move the light rendering from Stage.draw() into Camera2d.draw(). Lights logically belong to the camera's view — each camera should render its own lights as part of its draw pass, which would naturally be captured by the FBO without restructuring the stage/camera relationship.

This would involve:

  • Moving ambient light overlay rendering from Stage.draw() into Camera2d.draw() (or drawFX)
  • Moving Light2d iteration from Stage.draw() into Camera2d.draw()
  • The camera would need access to the stage's lights and ambientLight (passed as parameters or referenced from the stage)
  • The clipRect skip for FBO rendering already works inside Camera2d.draw()

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions