Repository navigation
Camera: a camera's post effects draw over the cameras before it - #1834
Merged
Merged
Conversation
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
Both changelog entries kept. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JnzwA2BZwXkRJLpNxCXBNt
…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
…composite # Conflicts: # packages/melonjs/CHANGELOG.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
Camera3ddrawing 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#drawmarks every camera after the first (_postEffectOver, internal).clearRenderTarget+keepBlend,"normal"blend for the final blit).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
ColorLayerfor a background. If you'd rather keep the old look for sub-rect cameras, it's a one-line condition (renderable.isDefault) inStage#draw.Also:
Fixedentry.Type of change
Checklist
pnpm lintpasses): Biome andtscclean, no new ESLint warningspnpm testpasses): full engine suite, 378 files / 9424 tests passtests/camera-post-effect-over.spec.jsreads pixels on WebGL. The two over-another-camera cases fail without the fix (0,0,0instead of red) and pass with it.pnpm build): left to CINot 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