Fix WebGL2 hybrid overlay placement vs WGSL shaders#267
Conversation
- Stack overlay canvas directly on the WebGPU canvas via a shared wrapper instead of centering it independently in the flex container. - Use u_rows for circular arc step count (was hardcoded 64) to match WGSL numRows-driven ring spacing in v0.42/v0.45b/v0.46. - Mirror patternv0.40 horizontal header-row channelIndex math in the overlay vertex shader and divide grid height by dataChannels when padTopChannel is active, matching gridRect layout in the WGSL shaders. Co-authored-by: Noah Cohn <noahc42@gmail.com>
|
Warning Review limit reached
More reviews will be available in 27 minutes and 27 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (5)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
Headless Colab screenshots showed WebGPU unavailable (expected) and highlighted that the WebGL frosted-cap overlay can drift from the WGSL cell grid. This PR aligns overlay geometry with the WGSL shaders in three areas.
Findings from Colab / headless captures
?renderer=webgpu): canvas stays blank in headless Chrome — overlay cannot be visually verified there, but console/packing paths are clean.?renderer=webgl2): falls back to HTML in headless Puppeteer (no WebGL2 context), so shader captures are the DOM grid — not the GPU overlay stack.useWebGLOverlay): the real misalignment bug lives here when both layers render.Root causes fixed
top/left 50% + translate), while the WebGPU canvas was centered as a flex child. Sub-pixel drift between the two centering strategies caused visible cap offset.totalSteps = 64.0; WGSL shaders useuniforms.numRowsfor arc spacing (v0.42, v0.45b, v0.46, etc.).patternv0.40.wgslremaps channel 0 as a header/pad row and dividesgridRect.hbydataChannels(not padded channel count). The overlay used rawtrackIndex * cellHwithcellH = gridH / numChannels, shifting data rows down one line.Changes
components/PatternDisplay.tsx— wrap WebGPU + overlay canvases in a sharedrelativecontainer; overlay usesinset-0on that wrapper.hooks/webGLShaders.ts— circulartotalStepsfromu_rows; horizontal Y uses WGSLchannelIndexremapping.utils/geometryConstants.ts—calculateHorizontalCellSize(..., hasHeaderRow)+horizontalLayoutHasHeader()helper.hooks/useWebGLOverlay.ts+WebGL2PatternRenderer.ts— pass header-row flag; circular instance count usesrows.Verification
npm run typecheck✅npm run build✅Manual follow-up
In a WebGPU-capable browser, load a hybrid shader (
patternv0.46.wgsl,patternv0.45b.wgsl, orpatternv0.40.wgsl) and confirm frosted caps sit on the WGSL cell centers while seeking rows 0/16/32.