Fix projective rendering for image source quads - #7903
Closed
i4innovationnet wants to merge 1 commit into
Closed
Conversation
Use homogeneous texture coordinates for non-parallelogram image, canvas, and video source quads across Mercator, globe, and terrain. Preserve valid zero-constant transforms, fall back for singular or zero-crossing denominators, and add unit and render coverage. Fixes maplibre#7886.
9 tasks
Collaborator
|
See my comment here about closing this one and opening the previous one: |
Contributor
Author
|
Closed in favor of the reopened #7887, preserving the original review conversation as requested. The verified commit is unchanged. |
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.
Launch Checklist
CHANGELOG.mdunder the## mainsection.Summary
Fixes projective rendering for image source quads whose four coordinates do not form a parallelogram.
The raster shader now carries homogeneous texture coordinates for image, canvas, and video source quads and divides by the projective denominator in the fragment shader before sampling. Parallelogram quads and regular tiled raster sources keep affine behavior through an identity perspective transform.
ImageSourcecomputes the complete inverse-homography denominatorw = ax + by + c, rejects singular, non-finite, and zero-crossing transforms, and normalizes the homogeneous coefficients without assuming thatcis nonzero. This preserves valid convex trapezoids while failing closed for degenerate, concave, and self-intersecting coordinates.The texture correction remains separate from clip-space projection:
projectTileownsgl_Position.wfor Mercator, globe, and terrain paths, while this change performs the texture divide explicitly in the fragment shader.Related Issue
Fixes #7886.
Visuals
The before screenshot and original reproduction are in #7886.
Render fixtures cover the corrected non-parallelogram case, a valid trapezoid whose homogeneous denominator has no constant term, and the projection modes discussed during review:
test/integration/render/tests/image/projective/style.jsontest/integration/render/tests/image/projective-trapezoid/style.jsontest/integration/render/tests/projection/globe/image-projective/style.jsontest/integration/render/tests/terrain/image-projective/style.jsonThe projective fixtures use
projective-grid.pngand include semi-transparent vector outlines so the expected corner geometry remains visible.Reviewer Follow-Up
ImageSource; regular tiled raster sources explicitly pass identity coefficients.ImageSourcestate tests.local://image/0.pngafter reviewer consensus and regenerated its expected output.Number.EPSILON-scaled singularity checks.c = 0and rejected denominators that reach or cross zero inside a quad.mainand regenerated the combined bundle-size baseline.Validation
Local validation on Node
24.11.1, after merging currentmain:npm ci— 0 root-package vulnerabilitiesnpm run lint -- --max-warnings 0npm run lint-cssnpm run generate-typingsnpm run typechecknpm run generate-docsnpm run build-distnpm run test-unit-ci— 196 files, 2,895 tests passednpm run test-build-ci— 8 files, 699 tests passednpm run test-integration-ci— 4 files, 176 tests passednpm run test-render -- -t 'tests/(image/(projective|projective-trapezoid|default|raster-resampling)|projection/globe/image-projective|terrain/image-projective|canvas/default|video/default|raster-resampling/default)'— 9 affected render tests passedgit diff --checkThe prior Windows integration failure was a Puppeteer navigation timeout in an untouched query-test setup path. It did not reproduce locally; the full integration suite passed twice after the production build prerequisite.
Assisted-By: OpenAI Codex (GPT-5)