roleplay/client/shader/string.comp

30 lines
1.1 KiB
Plaintext

#version 450
#extension GL_EXT_buffer_reference : require
#include "ui_common.glsl"
layout(local_size_x = 1) in;
void main() {
uint gID = gl_GlobalInvocationID.x;
String string = pc.layer.strings.s[gID];
Font font = pc.layer.container.context.fonts.f[string.font];
uint buffer_pos = atomicAdd(pc.layer.draw.instance_count, string.len);
vec2 pen = vec2(0.0, 0.0);
for(uint i = 0; i < string.len; i++) {
uint code = (pc.layer.codes.c[(string.offset + i)/4] >> ((string.offset + i) % 4)*8) & 0xFF;
Symbol symbol = font.symbols.s[code];
pc.layer.drawables.d[buffer_pos + i].pos = string.pos + pen;
pen += string.size*symbol.advance;
pc.layer.drawables.d[buffer_pos + i].size = vec2(string.size, string.size);
pc.layer.drawables.d[buffer_pos + i].color[0] = string.color;
pc.layer.drawables.d[buffer_pos + i].color[1] = string.color;
pc.layer.drawables.d[buffer_pos + i].color[2] = string.color;
pc.layer.drawables.d[buffer_pos + i].color[3] = string.color;
pc.layer.drawables.d[buffer_pos + i].var = code + (string.font << 16);
pc.layer.drawables.d[buffer_pos + i].type = 1;
}
}