Add uUseTexture==2 (RGBA modulate) branch to ui_text.frag so dat sprites can be drawn through the existing 2D batcher without touching the font path. TextRenderer gains _spriteBufs (per-GL-handle List<float>), DrawSprite(), and a Flush block that issues one draw call per distinct texture with uUseTexture=2. Also adds DepthMask(false) in the state-save block (restored to true after) to prevent the transparent-quad pass from writing depth and corrupting the 3D scene if the UI is flushed mid-frame. TextureCache gains GetOrUpload(surfaceId, out width, out height) — caches pixel dimensions alongside the GL handle so UI 9-slice geometry can compute slice UVs from the source image size without a second decode. UiRenderContext gains a DrawSprite forwarder that applies the current 2D translate stack, matching the DrawRect / DrawRectOutline pattern. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
21 lines
584 B
GLSL
21 lines
584 B
GLSL
#version 430 core
|
|
in vec2 vUv;
|
|
in vec4 vColor;
|
|
out vec4 FragColor;
|
|
|
|
uniform sampler2D uTex;
|
|
uniform int uUseTexture;
|
|
|
|
void main() {
|
|
if (uUseTexture == 1) {
|
|
// Font atlas is a single-channel R8 texture; red = coverage alpha.
|
|
float coverage = texture(uTex, vUv).r;
|
|
FragColor = vec4(vColor.rgb, vColor.a * coverage);
|
|
} else if (uUseTexture == 2) {
|
|
// RGBA dat sprite (decoded to RGBA8); modulate by tint/alpha.
|
|
FragColor = texture(uTex, vUv) * vColor;
|
|
} else {
|
|
FragColor = vColor;
|
|
}
|
|
if (FragColor.a < 0.005) discard;
|
|
}
|