The Seele UI system (`external/Seele/src/Engine/UI/` + `res/shaders/UIPass.slang` + `src/Engine/Graphics/RenderPass/UIPass.cpp`) renders **both** plain UI quads (backgrounds, buttons) and text glyphs through a **single** instanced pipeline:
Same pipeline state → same pipeline. Splitting into two shaders would create a **second pipeline + second draw call** for what is literally one `if`. By Vulkan/Metal best practice this is the right unification.
### 2. The real divergence is in the **vertex stage**, and it is already half-broken
-`uvOffset`/`uvSize` exist on `UIRender` for "per-glyph rect in atlas space" but are **never uploaded** — `UIPass.cpp` has no fields for them in `RenderElementStyle` and the shader uses full 0..1 UVs.
-`FontAsset` (Asset/FontAsset.cpp:113) creates **one tiny texture per glyph** (each ~10×20 px, R8_UNORM). So "the glyph quad's UV rect in atlas space" is fiction today — every glyph texture is the whole glyph, full-rect UVs are accidentally correct.
- **This is the actual bug hiding inside the shared shader:** per-glyph textures means thousands of texture objects, thousands of sampler bindings, and the `usedTextures` array grows with unique glyph count (capped at the 1024 descriptor binding count — a hard ceiling that a real font will hit).
### 3. Per-frame cost of the shared path (minor, but real)
- Every `UIRender` uploads a 64-byte struct (color, position, padding, `element` back-ref space) even though the shader only needs ~40 bytes. Fine at editor scale, wasteful at game scale.
-`uiDescriptorLayout->reset()` + full re-bind every frame, 1024 sampler slots.
## Verdict
**Keep the single shader and single instanced draw. Do NOT split into a UI shader and a text shader.** The branch is trivial, the pipelines are state-identical, and one draw call for the whole overlay is a genuine win.
**But do fix the data path that the "same shader" idea is masking:**
| Priority | Change | Why |
|---|---|---|
| 1 (correctness/scale) | **Glyph atlas (per font, not per glyph)**: bake FreeType bitmaps into one N×N R8 texture at `loadGlyphs`, store UV rect per glyph; add `uvOffset`/`uvSize` to `RenderElementStyle` and use them in the shader (the fields already exist on `UIRender` — just wire them through). Removes the 1024-texture ceiling and thousands of GPU objects. | The current design will break at real font sizes; it only "works" for a handful of glyphs. |
| 2 (cleanliness) | Drop the `isGlyph` flag and the "glyph-only" comment block from `UIRender` — after the atlas fix, a glyph quad is just "a quad with a texture and a UV rect". UI quads with textures (icons, background images) use the exact same path. One concept, one struct. | The flag documents an accident, not a design. |
| 3 (later, if it ever matters) | Split the **vertex** stage: background quads don't need UVs at all; but with 4-vertex instancing the savings are ~zero. Skip unless profiling says otherwise. | YAGNI. |
What would justify *separating* in the future (none true today): different blend modes per category, MSAA-specific text rendering (e.g. LCD subpixel), or text needing its own post-process (SDF scaling). None of these are in scope for the editor UI.
| `src/Engine/Asset/FontAsset.{h,cpp}` | Per-font atlas texture built once in `loadGlyphs`; `Glyph` stores `uvRect` instead of `OTexture2D`; `RenderGlyph` carries the rect. |
- [x] 1. Atlas: in `FontAsset::loadGlyphs`, pack glyph bitmaps (simple shelf/row packer is fine — font glyph count per size is bounded) into one R8 texture per `(font, size)`; replace `glyph.texture` with `glyph.uvRect` + a shared `fontSizes[size].atlas` texture.
- [x] 2. `RenderGlyph`/`UIRender`: carry the UV rect; drop `isGlyph` + dead comments.
- [ ] 4. Verify: existing editor inspector (uses the same pass) still renders text identically; a paragraph of text no longer adds per-glyph textures (check via debug texture listing or descriptor count).
2. Run editor: inspector text renders pixel-identically to before (glyph coverage unchanged — same R8 data, just relocated in an atlas).
3. Stress: put a long string (all of Unicode Basic Multilingual Plane) in a `Text` element — must not crash on descriptor exhaustion (the 1024 cap is gone; only 1 atlas binding per font-size).
4. Confirm single draw call for the UI pass still (no extra pipeline state).