Skip to content

fix(node): floor the seeded render size to match three's PassNode - #89

Merged
DennisSmolek merged 1 commit into
mainfrom
fix/node-render-size-floor
Oct 12, 2026
Merged

DennisSmolek merged 1 commit into
mainfrom
fix/node-render-size-floor

Conversation

@DennisSmolek

Copy link
Copy Markdown
Member

Fixes #88.

UpscalerNode._configureUpscaler() rounded the seeded render size (drawingBufferSize / ratio). three's PassNode renders at Math.floor(size * (1 / ratio)). When the quotient's fraction was ≥ .5 (about half of all canvas sizes), the first configure reported a size one texel larger than the real input. Example: 1252×936 at Quality gave 835×624, but three renders 834×624. updateBefore re-synced later, but consumers that validate renderWidth/renderHeight on the first frame saw the mismatch.

Change

  • New internal helper getPassRenderResolution (src/math/resolution.ts; not exported from the package) uses three's own arithmetic. For the preset ratios it gives the same result as getRenderResolution at every size up to 8192, which a test pins. For custom ratios it follows three, e.g. 39 * (1 / 1.3) → 29 vs 39 / 1.3 → 30.
  • The node seeds _input from that helper, and _configureUpscaler floors instead of rounding.
  • TemporalGuidesNode keeps Math.round. It only receives real (integer) texture sizes.

Verification

  • New unit tests: the issue's repro case (1252×936 @ 1.5 → 834×624), the custom-ratio divergence, and agreement with getRenderResolution at the preset ratios.
  • Lint on the changed files and the build pass locally. No shader or pass changes.

Ship as a patch release (fix: → auto resolves to a patch).

🤖 Generated with Claude Code

UpscalerNode's first configure rounded drawingBufferSize / ratio, while
three's PassNode renders at Math.floor(size * (1 / ratio)). Whenever the
quotient's fraction was >= .5 (about half of all canvas sizes) the upscaler
reported a render size one texel larger than its real input until
updateBefore re-synced, so consumers validating renderWidth/renderHeight
saw a mismatch on the first frame.

Seed with getPassRenderResolution (three's multiply-by-reciprocal, which
also matches for custom ratios where it diverges from floor(size / ratio))
and floor in _configureUpscaler.

Fixes #88

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@DennisSmolek
DennisSmolek merged commit cb463d3 into main Oct 12, 2026
2 checks passed
@DennisSmolek
DennisSmolek deleted the fix/node-render-size-floor branch October 12, 2026 09:07
bpodwinski added a commit to bpodwinski/upscaler that referenced this pull request Oct 12, 2026
Resolve import conflicts in UpscalerNode.ts and resolution.test.ts: keep the
branch's .js import specifiers and add upstream's getPassRenderResolution (pmndrs#89).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

UpscalerNode rounds the initial render size up; mismatches three's PassNode (floor) on fractional sizes

1 participant