Investigate WebGL2 upgrade path for Goldberg Polyhedron Paint #2
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The Goldberg Polyhedron Paint experiment currently targets WebGL1 (OpenGL ES 2.0). This issue tracks an investigation into what WebGL2 (OpenGL ES 3.0) would unlock and whether an upgrade is worthwhile.
What WebGL2 adds
Rendering quality / efficiency
int, enabling per-face data lookups in a texture rather than duplicating attributes per vertexgl.UNSIGNED_INTindex buffers — removes the 65535 vertex limit per draw callgl.HALF_FLOATtextures — cheaper storage for HDR framebuffersEXT_color_buffer_floatis core)Shading
textureLod/ explicit LOD in shaders — useful for environment map sampling in PBRtexture2DArray— could store multiple noise/material layers efficientlyin/outinstead ofattribute/varying,flatinterpolation (useful for per-face solid color without geometry duplication), proper integer typesPerformance
gl.drawArraysInstanced) — if many identical sub-objects ever appeargl.uniform*callsgl.PIXEL_PACK_BUFFERfor async GPU→CPU readback — face picking currently stalls the pipelineTexture formats
RED,RGinternal formats — the PBR buffer (roughness + metallic) currently usesvec2in a full RGBA texture; a properRGtexture would halve the bandwidthSpecific wins for this project
flatinterpolation — the biggest immediate win. Currently every face duplicates position/colour/PBR/noise data for all its triangulated vertices. Withflatand an integer face-ID attribute the GPU can do the per-face lookup once, saving significant buffer memory at higher subdivision depths.PIXEL_PACK_BUFFERwould let the readback happen without a GPU stall on every mouse move.enableVertexAttribArray/vertexAttribPointerboilerplate collapses to a single bind.Browser support
WebGL2 has been baseline since ~2022 (Chrome 56+, Firefox 51+, Safari 15+). There is no meaningful reason to stay on WebGL1 for a non-embedded target.
Suggested next step
Audit the current shader and buffer setup, then migrate incrementally: VAO first (zero functional change, cleaner code), then
flatface-ID to cut buffer duplication, then async picking.