Commit 652256b
committed
atlas: pixelStorei(UNPACK_FLIP_Y_WEBGL) before texImage2D — the missing line
Diffed our minified bundle against memepool's working one and read both
shaders end-to-end. The math, the slot encoding, the vertex layout, the
texture parameters, the network path — all identical. The one substantive
difference: memepool calls pixelStorei(UNPACK_FLIP_Y_WEBGL, true) before
each canvas-to-texture upload. We didn't.
Without that flag, canvas pixel (x, 0) [the top row, where we drew the
image] lands at texture UV y=0 [the bottom of the texture]. The shader's
`spriteY = atlasSize - spriteY - pxSize` flip then samples the bottom
half of the texture — which is empty — and texture2D returns transparent.
The composite line `base.rgb = tex.rgb * tex.a + vColor.rgb * (1 - tex.a)`
collapses to vColor with tex.a=0, so every textured square rendered as
flat colour, indistinguishable from "no image loaded".
Verified end-to-end via playwright + WebGL FBO readback: the canvas had
the image bytes, the GPU texture had them at the same coords, but the
shader's flipped UV was sampling the empty bottom half. With UNPACK_FLIP_Y_WEBGL=true,
the upload pre-flips so the shader's flip lands on the right region.
Toggling the flag back to false right after the upload to avoid leaking
the state to anything else in the page that might do its own texImage2D.1 parent 0c6c322 commit 652256b
1 file changed
Lines changed: 8 additions & 0 deletions
Lines changed: 8 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
175 | 175 | | |
176 | 176 | | |
177 | 177 | | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
178 | 185 | | |
| 186 | + | |
179 | 187 | | |
180 | 188 | | |
181 | 189 | | |
| |||
0 commit comments