diff options
author | talha <talha@talhaamir.xyz> | 2024-06-30 22:31:36 +0500 |
---|---|---|
committer | talha <talha@talhaamir.xyz> | 2024-06-30 22:31:36 +0500 |
commit | 5ebf4c228b9d26c2b1b32073487413eea6a4c4f2 (patch) | |
tree | 0d6a6566f180072954fb3d458a9f552bfbeabeb5 /source/shaders/ui_text_shader.fs.glsl | |
parent | 8824908b696278f34891d95c15e519710ea0d18d (diff) |
Super simple version of optimized text rendering done
Diffstat (limited to 'source/shaders/ui_text_shader.fs.glsl')
-rw-r--r-- | source/shaders/ui_text_shader.fs.glsl | 10 |
1 files changed, 7 insertions, 3 deletions
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); }; |