Nailing the Nova 8 K Text Bug in Our WebGL Build

TL;DR
- Symptom: text longer than ~260 characters rendered garbage every few glyphs—but only on WebGL.
- Root cause: Nova’s fallback renderer packed vertices into a 1 D RGBA texture wider than WebGL’s 8 192-pixel limit.
- Fix: tiled the buffer into 8 192-pixel rows and made the shader use the same row width.
The Bug: Long Text Goes Glitch-City
QA noticed that any dialog exceeding about 260 chars ≈ 1 024 glyphs
shredded itself
on WebGL — characters would vanish or swap every ~20 glyphs.
The Editor looked fine… until we forced
SystemSettings.UseFallbackRendering = true
and the corruption showed up there
too.
// WebGL console
Texture has out of range width (got 12800 max supported 8192)
Root Cause: Oversized & Misaligned Fallback Buffers
Nova switches to a texture-buffer fallback when SSBOs aren’t available
(WebGL). One glyph vertex = 64 bytes = 4 float4 pixels. A modest
<TextBlock>
with 3224
vertices became a
12896 px × 1
texture—well above WebGL’s limit.
After we clamped the width to 8192 px, another artefact surfaced:
the shader still believed rows were 16 384 px wide, so edits wrote to
one row and the GPU read from another.
The Fix in Two Commits
1 — Tile the Buffer Texture
int maxEdge = 8192;
int width = Mathf.Min(numPixels, maxEdge);
int height = Mathf.CeilToInt((float)numPixels / width);
texture = new Texture2D(width, height, TextureFormat.RGBAFloat, false, true);
2 — Sync the Shader Constant
#if defined(NOVA_FALLBACK_RENDERING)
#if defined(UNITY_WEBGL) || defined(UNITY_EDITOR)
#define MAX_TEXTURE_DIMENSION 8192u
#else
#define MAX_TEXTURE_DIMENSION 16384u
#endif
#endif
We also patched SetData()
to honour
shaderBufferStartIndex * 4
for RGBA paths so runtime edits no longer
stomp earlier glyphs.
Results
✅ WebGL build: zero artefacts, zero crashes.
✅ Stand-alone desktop builds keep the 16 384-px SSBO path.
Editor is showing the strange behaviour still. But not a priority currently for a fix.