Repository navigation
fix: Find CameraComponent.postProcess in findPostProcessFromContext - #4221
Merged
Merged
Conversation
`findPostProcessFromContext` returned `null` for every component in the world and in the viewfinder when the post process was set as `CameraComponent.postProcess`. Multi-pass effects where components draw differently in each pass couldn't work with the camera's post process. For example, a selection highlight that renders a mask of the selected unit and then the scene outlined every component instead. The lookup fell back to the camera's render context, but render contexts are only passed from a component to its children, and the camera renders the world and the viewfinder directly, so that context never reached them. Now the fallback checks the post processes of the cameras that are rendering, through `CameraComponent.currentCameras`, from the innermost to the outermost. A `PostProcessComponent` ancestor still takes precedence. This also adds a repro example, `camera_context_repro.dart`.
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the camera post-process lookup change.
No open issues 🎉
What changed in this PR
Fixes #4200 by allowing components rendered through CameraComponent.postProcess to find the active post process, enabling multi-pass effects to identify their current rendering pass.
Changes:
- Replaces the camera render-context fallback with an innermost-to-outermost lookup through active cameras, preserving ancestor post-process precedence.
- Documents lookup behavior and adds regression tests for world, viewfinder, nested-camera, and shared-world rendering.
| File | Description |
|---|---|
packages/flame/test/post_process/post_process_context_test.dart |
Adds regression coverage for camera post-process discovery and isolation. |
packages/flame/lib/src/post_process/post_process_component.dart |
Updates and documents the active-camera fallback lookup. |
Review effort: Balanced
ufrshubham
enabled auto-merge (squash)
November 16, 2026 19:00
LordixDemon
added a commit
to LordixDemon/flame
that referenced
this pull request
Nov 17, 2026
Brings in the upstream fix for findPostProcessFromContext (flame-engine#4221), the package skills (flame-engine#4223) and documentation link fixes (flame-engine#4234, flame-engine#4235). The only conflict was in post_process_component.dart: the fork's own lookup through CameraComponent.currentCamera is replaced by upstream's walk over CameraComponent.currentCameras, and the camera import that the upstream version no longer needs is dropped. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
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
findPostProcessFromContextreturnednullfor every component rendered underCameraComponent.postProcess. Its fallback looked for aCameraRenderContextamong the render contexts of the component's ancestors, but render contexts are only passed on throughrenderChild, and the camera renders its world, viewfinder and viewport by calling theirrenderTreedirectly. That lookup could never succeed, so a multi-pass post process set on the camera had no way to tell its components which pass they were being rendered in, like the selection highlight in #4200.The lookup now goes through
CameraComponent.currentCamerasinstead, from the innermost camera outwards, and returns the first post process of the requested type that is currently rendering, the same wayCullWhenOffscreenfinds the camera that renders it. APostProcessComponentancestor still takes precedence. Components in the viewport or the backdrop still getnull, since they aren't rendered through the post process, and so do the components of the same world rendered by another camera without a post process.camera_context_bug_selection_fixed.mp4
Checklist
docsand added dartdoc comments with///.examplesordocs.Breaking Change?
Related Issues
Closes #4200