From 5ebf4c228b9d26c2b1b32073487413eea6a4c4f2 Mon Sep 17 00:00:00 2001 From: talha Date: Sun, 30 Jun 2024 22:31:36 +0500 Subject: Super simple version of optimized text rendering done --- source/shaders/ui_text_shader.fs.glsl | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'source/shaders/ui_text_shader.fs.glsl') diff --git a/source/shaders/ui_text_shader.fs.glsl b/source/shaders/ui_text_shader.fs.glsl index d8bdcfb..bca9f7a 100644 --- a/source/shaders/ui_text_shader.fs.glsl +++ b/source/shaders/ui_text_shader.fs.glsl @@ -1,12 +1,16 @@ #version 330 core in vec2 TexCoords; -uniform sampler2D Texture; +flat in int Index; +uniform sampler2DArray TextureAtlas; +uniform int TextureMap[32]; uniform vec3 TextColor; out vec4 FragColor; void main() { - vec4 sampled = vec4(1.0, 1.0, 1.0, texture(Texture, TexCoords)); - FragColor = sampled * vec4(TextColor, 1.0); + int TextureId = TextureMap[Index]; + vec3 TextureIndexCoords = vec3(TexCoords.xy, TextureId); + vec4 sampled = vec4(1.0, 1.0, 1.0, texture(TextureAtlas, TextureIndexCoords).r); + FragColor = sampled * vec4(TextColor, 1); }; -- cgit v1.2.3