diff options
Diffstat (limited to 'source/shaders')
-rw-r--r-- | source/shaders/ui_text_shader.fs.glsl | 10 | ||||
-rw-r--r-- | source/shaders/ui_text_shader.vs.glsl | 13 |
2 files changed, 15 insertions, 8 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); }; diff --git a/source/shaders/ui_text_shader.vs.glsl b/source/shaders/ui_text_shader.vs.glsl index ecaefa4..363833e 100644 --- a/source/shaders/ui_text_shader.vs.glsl +++ b/source/shaders/ui_text_shader.vs.glsl @@ -1,12 +1,15 @@ #version 330 core -layout(location=0) in vec3 aPos; -layout(location=1) in vec2 aTex; +layout(location=0) in vec2 aPos; uniform mat4 Projection; - +uniform mat4 LetterTransforms[32]; out vec2 TexCoords; +flat out int Index; void main() { - gl_Position = Projection * vec4(aPos, 1.0); - TexCoords = aTex; + gl_Position = Projection * LetterTransforms[gl_InstanceID] * vec4(aPos, 0.0, 1.0); + vec2 tex = aPos; + TexCoords = tex; + TexCoords.y = 1.0 - TexCoords.y; + Index = gl_InstanceID; } |