Skip to content

Change footprint to always be in physical instead of logical space#4280

Merged
timon-schelling merged 5 commits into
masterfrom
fix-footprint-transform
Jul 15, 2026
Merged

Change footprint to always be in physical instead of logical space#4280
timon-schelling merged 5 commits into
masterfrom
fix-footprint-transform

Conversation

@timon-schelling

@timon-schelling timon-schelling commented Jun 24, 2026

Copy link
Copy Markdown
Member

The render node(s) pass along the logical instead of the physical scale as part of the footprint, leading to upstream nodes rendering at the wrong scale and producing textures of the wrong size.

wrong at 2.8x scale
image

correct at 2.8x scale
image

The first Commit is a minimal fix.
The second makes the create context node responsible for converting the render configs footprint to physical scale and then passing that along. Things that explicitly require logical scale like metadata and svg rendering convert back to logical.

Both approaches work, @TrueDoctor any opinions?
I'm slightly in favor of the second.

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request refactors the rendering pipeline to consistently manage physical and logical coordinate spaces. It scales the footprint transform by the render scale early in the pipeline and introduces logical transforms where needed across background rendering, caching, and pixel preview nodes. The reviewer suggests a further simplification in render_pixel_preview.rs to remove an unnecessary multiplication by physical_scale when applying the transform to the metadata, since the upstream metadata is already in logical space.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines +72 to +74
result
.metadata
.apply_transform(footprint.transform * DAffine2::from_translation(upstream_min) * DAffine2::from_scale(DVec2::splat(physical_scale)));
.apply_transform(logical_transform * DAffine2::from_translation(upstream_min) * DAffine2::from_scale(DVec2::splat(physical_scale)));

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.

medium

With upstream_render_params.scale set to 1.0, the upstream metadata is already in logical space, so we no longer need to multiply by physical_scale to undo the mismatch.

Suggested change
result
.metadata
.apply_transform(footprint.transform * DAffine2::from_translation(upstream_min) * DAffine2::from_scale(DVec2::splat(physical_scale)));
.apply_transform(logical_transform * DAffine2::from_translation(upstream_min) * DAffine2::from_scale(DVec2::splat(physical_scale)));
result
.metadata
.apply_transform(logical_transform * DAffine2::from_translation(upstream_min));

@cubic-dev-ai cubic-dev-ai Bot 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.

1 issue found across 4 files

Confidence score: 3/5

  • In node-graph/nodes/gstd/src/render_background.rs, inverting render_params.scale without a zero check can produce non-finite transform values when scale is 0, which can lead to invalid SVG output at runtime — add a guard/fallback for zero (or near-zero) scale before computing 1.0 / scale before merging.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="node-graph/nodes/gstd/src/render_background.rs">

<violation number="1" location="node-graph/nodes/gstd/src/render_background.rs:55">
P2: Unconditional `1.0 / render_params.scale` can create non-finite transforms when scale is 0. Guard scale before inversion to avoid invalid SVG transform output.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread node-graph/nodes/gstd/src/render_cache.rs Outdated
} => {
let mut render = SvgRender::new();

let logical_transform = glam::DAffine2::from_scale(glam::DVec2::splat(1.0 / render_params.scale)) * render_params.footprint.transform;

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.

P2: Unconditional 1.0 / render_params.scale can create non-finite transforms when scale is 0. Guard scale before inversion to avoid invalid SVG transform output.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At node-graph/nodes/gstd/src/render_background.rs, line 55:

<comment>Unconditional `1.0 / render_params.scale` can create non-finite transforms when scale is 0. Guard scale before inversion to avoid invalid SVG transform output.</comment>

<file context>
@@ -52,6 +52,8 @@ async fn render_background<'a: 'n>(
 		} => {
 			let mut render = SvgRender::new();
 
+			let logical_transform = glam::DAffine2::from_scale(glam::DVec2::splat(1.0 / render_params.scale)) * render_params.footprint.transform;
+
 			if render_params.viewport_zoom > 0. {
</file context>

@TrueDoctor

Copy link
Copy Markdown
Member

Why is there the Vello vs SVG asymmetry in the first commit? Would this lead to blurry results when embedding raster content using the svg rendering path?

@timon-schelling

Copy link
Copy Markdown
Member Author

Why is there the Vello vs SVG asymmetry in the first commit? Would this lead to blurry results when embedding raster content using the svg rendering path?

I think yes, I just accepted the current behavior for SVG but you are likely right that we should also change that.


let device_scale = render_params.scale;
let zoom = footprint.scale_magnitudes().x;
let zoom = footprint.scale_magnitudes().x / render_params.scale;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

could the scale be just removed here?

@timon-schelling timon-schelling changed the title Fix footprint transform Change footprint to always be in physical instead of logical space Jul 15, 2026
@timon-schelling
timon-schelling added this pull request to the merge queue Jul 15, 2026
Merged via the queue into master with commit a040362 Jul 15, 2026
11 checks passed
@timon-schelling
timon-schelling deleted the fix-footprint-transform branch July 15, 2026 13:38
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.

2 participants