[fix] [sdf] Sdf text alpha double multiplication#2
Merged
Conversation
5 tasks
chiefcll
added a commit
that referenced
this pull request
May 11, 2026
Three changes covering the hot update path for x/y changes on simple nodes (no rotation/scale/mount): 1. CoreNode.update Global block: when both the node is simple and the parent's global is translate-only, the resulting global is also translate-only and collapses to two adds on tx/ty — bypassing the 6-field Matrix3d.copy + 2 mul-add translate. Tracked with a per-node _globalIsTranslate flag that propagates down the tree. RTT chains conservatively opt out. 2. updateLocalTransform simple path: localTransform is guaranteed to be identity-shape (ta=1, tb=0, tc=0, td=1), so only tx/ty need to change between frames. _localIsTranslate tracks whether the matrix is still in identity-shape so a non-simple -> simple transition correctly restores it. 3. updateBoundingRect: fix `||` -> `&&` on the axis-aligned-fast-path check. With `||`, a matrix with one zero shear component and the other non-zero (e.g. tb=0, tc=-0.5) wrongly took the diagonal fast path and produced incorrect bounds. Now matches calculateRenderCoords semantics. Adds setTranslate() helper to Matrix3d for the in-place tx/ty + mutation flag write used by both #1 and #2. Adds 12 unit tests covering simple-path reuse, non-simple -> simple transitions, translate-only propagation through grandchildren, fast-path opt-out when parent has rotation, and the bounding-rect axis check. Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
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.
The text color was being premultiplied by alpha twice:
v_color.rgb * opacityThis resulted in a double moltiplication of alpha channel, leading to wrong transparency results.
Solution: Removed the CPU-side premultiplication in
addSdfQuads(). The color is now packed as straight (non-premultiplied) RGBA into the vertex attribute, and the SDF fragment shader remains the single point where premultiplied alpha blending is applied.