Skip to content

Camera: a camera's post effects draw over the cameras before it - #1834

Merged
obiot merged 4 commits into
masterfrom
camera-post-effect-composite
Nov 2, 2026
Merged

obiot merged 4 commits into
masterfrom
camera-post-effect-composite

Conversation

@obiot

@obiot obiot commented Nov 2, 2026

Copy link
Copy Markdown
Member

Description

A stage's cameras draw in order, each over the ones before it. That holds without post effects. With one, a camera's pass started like a frame: its target was cleared to the background colour, and the result was copied over the whole screen with blending off. So a second full-screen camera with bloom or a vignette wiped out everything the cameras before it drew.

The case that hit it: a Camera3d drawing a 3D particle background first, and the game's 2D camera, carrying bloom, over it. The background vanished as soon as the game camera had an effect.

Fix

  • Stage#draw marks every camera after the first (_postEffectOver, internal).
  • For those cameras, both GPU renderers clear the pass to transparent and blend the result over the frame. That is what they already do for a renderable's effects (clearRenderTarget + keepBlend, "normal" blend for the final blit).
  • The first camera is unchanged: its pass still starts the frame, so a vignette or bloom on a single-camera game behaves exactly as before.

Visible side effect: a minimap (or any later sub-rect camera) with post effects used to fill its rectangle with the background colour. Like a minimap without effects, it now shows the view behind wherever it draws nothing. The changelog says so and suggests a ColorLayer for a background. If you'd rather keep the old look for sub-rect cameras, it's a one-line condition (renderable.isDefault) in Stage#draw.

Also:

  • Changelog: a Fixed entry.
  • Skills: the camera skill's "Secondary cameras" section now covers draw order and how post effects apply per camera; symptom rows in the camera and effects skills.

Type of change

  • Bug fix
  • New feature
  • Documentation update
  • Performance improvement
  • Refactoring (no functional changes)

Checklist

  • I have read the Contributing Guide
  • My code follows the existing code style (pnpm lint passes): Biome and tsc clean, no new ESLint warnings
  • I have tested my changes locally (pnpm test passes): full engine suite, 378 files / 9424 tests pass
  • I have added tests that cover my changes (if applicable): tests/camera-post-effect-over.spec.js reads pixels on WebGL. The two over-another-camera cases fail without the fix (0,0,0 instead of red) and pass with it.
  • The build succeeds (pnpm build): left to CI

Not tested: the WebGPU branch. It mirrors the WebGL change line for line, but headless Chromium here has no GPU adapter, so it has not run.

Related issues

None.


Generated by Claude Code

A stage's cameras draw in order, each over the ones before it. With post
effects, a camera's pass started like a frame instead: its target was
cleared to the background colour and the result copied over the whole
screen, so a second full-screen camera with bloom or a vignette wiped out
everything the cameras before it drew (a 3D background camera under a 2D
game, for one).

Stage#draw now marks every camera after the first, and for those both GPU
renderers clear the pass to transparent and blend the result over the
frame, as they already do for a renderable's effects. The first camera is
unchanged: its pass still starts the frame.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JnzwA2BZwXkRJLpNxCXBNt
Copilot AI balanced review requested due to automatic review settings November 2, 2026 08:39

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

Both changelog entries kept.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JnzwA2BZwXkRJLpNxCXBNt
Copilot AI balanced review requested due to automatic review settings November 2, 2026 09:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

…background; shorter changelog entry

The first-camera test used a black background, the same whether the pass
started from the background colour or transparent, so treating every camera
as drawn over another passed it. It now inverts a red background.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JnzwA4xBNBw7cEZzG1bUru
Copilot AI balanced review requested due to automatic review settings November 2, 2026 23:30

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

…composite

# Conflicts:
#	packages/melonjs/CHANGELOG.md
Copilot AI balanced review requested due to automatic review settings November 2, 2026 23:38

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@obiot
obiot merged commit a41d6a3 into master Nov 2, 2026
6 checks passed
@obiot
obiot deleted the camera-post-effect-composite branch November 2, 2026 23:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants