2024-10-13 22:18:37 -06:00
|
|
|
#version 450
|
2024-10-14 14:16:59 -06:00
|
|
|
#extension GL_EXT_buffer_reference : require
|
|
|
|
|
2024-10-20 21:59:28 -06:00
|
|
|
#include "ui_common.glsl"
|
2024-10-15 00:06:46 -06:00
|
|
|
|
2024-10-18 18:34:31 -06:00
|
|
|
layout(std430, push_constant) uniform PushConstant {
|
2024-10-20 21:59:28 -06:00
|
|
|
Context context;
|
|
|
|
Layer layer;
|
2024-10-18 18:34:31 -06:00
|
|
|
} pc;
|
2024-10-14 22:10:14 -06:00
|
|
|
|
2024-10-13 22:18:37 -06:00
|
|
|
layout(location = 0) out vec4 fragColor;
|
|
|
|
layout(location = 1) out vec2 fragUV;
|
2024-10-16 20:29:19 -06:00
|
|
|
layout(location = 2) out uint code;
|
2024-10-18 22:53:06 -06:00
|
|
|
layout(location = 3) out uint index;
|
|
|
|
layout(location = 4) out uint type;
|
2024-10-13 22:18:37 -06:00
|
|
|
|
2024-10-17 15:56:35 -06:00
|
|
|
const vec2 square[6] = {
|
|
|
|
vec2(0.0, 0.0),
|
|
|
|
vec2(1.0, 0.0),
|
|
|
|
vec2(0.0, 1.0),
|
|
|
|
vec2(1.0, 0.0),
|
|
|
|
vec2(1.0, 1.0),
|
|
|
|
vec2(0.0, 1.0),
|
|
|
|
};
|
|
|
|
|
2024-10-13 22:18:37 -06:00
|
|
|
void main() {
|
2024-10-18 22:53:06 -06:00
|
|
|
Drawable drawable = pc.layer.drawables.d[gl_InstanceIndex];
|
2024-10-20 21:59:28 -06:00
|
|
|
vec2 pos = square[gl_VertexIndex];
|
2024-10-18 22:53:06 -06:00
|
|
|
|
|
|
|
if(drawable.type == 0) {
|
|
|
|
// Rect
|
|
|
|
} else if(drawable.type == 1){
|
|
|
|
// Glyph
|
|
|
|
Font font = pc.context.fonts.f[pc.layer.font_index];
|
|
|
|
Symbol symbol = font.symbols.s[drawable.code];
|
|
|
|
|
2024-10-20 22:39:12 -06:00
|
|
|
fragUV = pos * vec2(symbol.width, symbol.height);
|
|
|
|
pos = pos * vec2(symbol.width, symbol.height) + vec2(symbol.left, -symbol.top);
|
2024-10-18 22:53:06 -06:00
|
|
|
}
|
|
|
|
|
2024-10-20 22:39:12 -06:00
|
|
|
gl_Position = vec4((pos * drawable.size + drawable.pos + pc.layer.container.pos) * pc.context.scale, 0.0, 1.0) - vec4(1.0, 1.0, 0.0, 0.0);
|
2024-10-20 21:59:28 -06:00
|
|
|
|
2024-10-18 22:53:06 -06:00
|
|
|
fragColor = drawable.color;
|
|
|
|
code = drawable.code;
|
|
|
|
type = drawable.type;
|
|
|
|
index = pc.layer.font_index;
|
2024-10-13 22:18:37 -06:00
|
|
|
}
|
|
|
|
|