Optimize text rendering for long strings
This commit is contained in:
parent
678414f014
commit
3b78739efd
3 changed files with 71 additions and 56 deletions
|
|
@ -1,12 +1,18 @@
|
|||
#version 330 core
|
||||
in vec2 texuv;
|
||||
|
||||
out vec4 color;
|
||||
|
||||
uniform sampler2D text;
|
||||
in VS_OUT {
|
||||
vec2 texuv;
|
||||
flat int index;
|
||||
} fs_in;
|
||||
|
||||
uniform sampler2DArray text;
|
||||
uniform int letter_map[400];
|
||||
uniform vec3 text_color;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 sampled = vec4(1.0, 1.0, 1.0, texture(text, texuv).r);
|
||||
{
|
||||
vec4 sampled = vec4(1.0, 1.0, 1.0, texture(text, vec3(fs_in.texuv.xy, letter_map[fs_in.index])).r);
|
||||
color = vec4(text_color, 1.0) * sampled;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,13 +1,17 @@
|
|||
#version 330 core
|
||||
layout (location = 0) in vec2 vertex; // <vec2 pos>
|
||||
out vec2 texuv;
|
||||
|
||||
uniform mat4 transform;
|
||||
out VS_OUT {
|
||||
vec2 texuv;
|
||||
flat int index;
|
||||
} vs_out;
|
||||
|
||||
uniform mat4 transforms[400];
|
||||
uniform mat4 projection;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = projection * transform * vec4(vertex.xy, 0.0, 1.0);
|
||||
texuv = vertex.xy;
|
||||
texuv.y=1.0f-texuv.y;
|
||||
gl_Position = projection * transforms[gl_InstanceID] * vec4(vertex.xy, 0.0, 1.0);
|
||||
vs_out.index = gl_InstanceID;
|
||||
vs_out.texuv = vec2(vertex.x, 1.0f - vertex.y);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue