Repository navigation
fix!: Scale the subtree to the pixel ratio in rasterizeSubtree - #4162
Merged
Merged
Conversation
`PostProcess.rasterizeSubtree` created an image of `pixelRatio * size` pixels but recorded the subtree at logical size, so the subtree only filled the top left corner of the image. Shaders sampling it with coordinates from 0 to 1 showed the subtree shrunk by the pixel ratio on high density screens. The recording canvas is now scaled by the pixel ratio, so the subtree fills the whole image. Shaders that worked around this by dividing the texture coordinates by the pixel ratio, like the crystal ball ground shader, must drop that workaround. Fixes #3766
spydon
reviewed
Oct 29, 2026
The flame package tests already cover the bug from #3766, so the examples don't need their own copy of the reporter's shader and image.
spydon
approved these changes
Oct 29, 2026
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
PostProcess.rasterizeSubtreecreated an image ofpixelRatio * sizepixels, but recorded the subtree at logical size. On any screen with a device pixel ratio above 1, the subtree only filled the top-left corner of the image, so a shader sampling it with coordinates from 0 to 1 showed the subtree shrunk by the pixel ratio. This is the scaled down and deformed output reported in #3766.rasterizeSubtreenow scales the recording canvas bypixelRatio, so the subtree fills the whole image at full resolution.Other changes:
pixelRatioandrasterizeSubtreedartdocs and the post processing docs now say that the image covers the whole subtree.flamecheck that drawing the rasterized subtree at the component size matches rendering the subtree directly.Without the fix, all of the new tests above pixel ratio 1 fail.
Checklist
docsand added dartdoc comments with///.examplesordocs.Breaking Change?
Migration instructions
The image returned by
PostProcess.rasterizeSubtreeis the same size as before, but the subtree now fills all of it instead of only its top-left corner.If your shader compensated for the old behavior, remove that workaround. For example, a shader that divided its texture coordinates by the pixel ratio should now sample with coordinates from 0 to 1 across the size of the post process:
Shaders that already sampled with coordinates from 0 to 1 need no changes. They now render correctly on screens with a device pixel ratio above 1.
Related Issues
Closes #3766