Skip to content

Interpolate Canvas gradient stops in straight RGBA - #1889

Draft
bkaradzic-microsoft wants to merge 1 commit into
BabylonJS:masterfrom
bkaradzic-microsoft:pr/canvas-gradient-interpolation
Draft

bkaradzic-microsoft wants to merge 1 commit into
BabylonJS:masterfrom
bkaradzic-microsoft:pr/canvas-gradient-interpolation

Conversation

@bkaradzic-microsoft

@bkaradzic-microsoft bkaradzic-microsoft commented Sep 17, 2026 •

Copy link
Copy Markdown
Member

Draft: the stock Babylon.js upload-alpha dependency still blocks landing.

Interpolate Canvas gradient RGB and alpha independently, with exact CPU controls and linear/radial GPU controls over an opaque backdrop. Rebased onto 3428526f after #1913 merged, preserving its newer Canvas identity, lifetime, callback, and blur regressions.

Windows V8/D3D11 with stock Babylon.js 9.29.0: all 11 selected native Canvas/gradient cases pass. The unchanged GUI Gradient Linear with transparency scene still fails: 81,174 / 240,000 pixels (33.8225%), above its 2.5% allowance.

Stock updateDynamicTexture does not forward the requested alpha representation to getCanvasTexture. The standalone interpolation correction therefore remains dependent on the paired JavaScript upload change. No references, tolerances, exclusions, dependencies, or CI scripts are changed by this PR.

Copilot AI lite review requested due to automatic review settings September 17, 2026 20:38

Copilot AI 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.

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Pull request overview

Updates Canvas gradient interpolation to blend RGB and alpha channels independently in straight RGBA space, while retaining NanoVG premultiplication during compositing.

Changes:

  • Replaces premultiplied/unpremultiplied interpolation in linear and radial gradients with straight RGBA interpolation.
  • Adds CPU regression coverage for translucent, opaque, fully transparent, and coincident stops.
  • Adds GPU readback coverage for linear and radial translucent gradients over an opaque backdrop.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
Polyfills/Canvas/Source/Gradient.cpp Implements straight RGBA interpolation for gradient ramps and color sampling.
Apps/UnitTests/Source/Tests.Canvas.Readback.cpp Adds CPU and GPU regression tests for gradient interpolation behavior.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@bkaradzic-microsoft
bkaradzic-microsoft marked this pull request as draft September 17, 2026 21:42
@bkaradzic-microsoft
bkaradzic-microsoft force-pushed the pr/canvas-gradient-interpolation branch 2 times, most recently from 8b6e8f4 to 49ba5b1 Compare September 22, 2026 20:05
bkaradzic-microsoft added a commit to bkaradzic-microsoft/BabylonNative that referenced this pull request Sep 30, 2026
Review-Group: E7/H4
Source: PR BabylonJS#1889
Squashed final review changes, including regressions and review follow-ups.
Status: held for runtime type tags / Canvas upload-alpha coordination.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 60c2ec68-6de1-445d-9fc9-b699db737eae
@bkaradzic-microsoft
bkaradzic-microsoft force-pushed the pr/canvas-gradient-interpolation branch 2 times, most recently from b467d6a to a0f9880 Compare October 5, 2026 19:26
Interpolate RGB and alpha independently in linear and radial gradient
baking. NanoVG performs premultiplication when compositing the ramp.

Cover exact ramp bytes, radial interpolation, transparent and opaque
stops, coincident-stop behavior, and GPU compositing over an opaque
backdrop without relying on JavaScript upload-alpha changes.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 60c2ec68-6de1-445d-9fc9-b699db737eae
@bkaradzic-microsoft
bkaradzic-microsoft force-pushed the pr/canvas-gradient-interpolation branch from a0f9880 to 4fe3249 Compare October 7, 2026 05:04
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