65 lines
1.9 KiB
GLSL
65 lines
1.9 KiB
GLSL
#version 450
|
|
#extension GL_EXT_buffer_reference : require
|
|
|
|
#include "ui_common.glsl"
|
|
|
|
layout(location = 0) out vec4 fragColor;
|
|
layout(location = 1) out vec2 fragUV;
|
|
layout(location = 2) out flat uint var1;
|
|
layout(location = 3) out flat uint var2;
|
|
layout(location = 4) out flat uint type;
|
|
layout(location = 5) out flat vec2 container_offset;
|
|
|
|
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),
|
|
};
|
|
|
|
void main() {
|
|
Drawable drawable = pc.layer.drawables.d[gl_InstanceIndex];
|
|
vec2 pos = square[gl_VertexIndex];
|
|
|
|
// Top Left
|
|
if(pc.layer.container.anchor == 0) {
|
|
container_offset = pc.layer.container.offset;
|
|
}
|
|
|
|
// Top Right
|
|
if(pc.layer.container.anchor == 1) {
|
|
container_offset = pc.layer.container.offset + vec2(pc.layer.container.context.extent.x - pc.layer.container.size.x, 0);
|
|
}
|
|
|
|
// Bottom Left
|
|
if(pc.layer.container.anchor == 2) {
|
|
container_offset = pc.layer.container.offset + vec2(0, pc.layer.container.context.extent.y - pc.layer.container.size.y);
|
|
}
|
|
|
|
// Bottom Right
|
|
if(pc.layer.container.anchor == 3) {
|
|
container_offset = pc.layer.container.offset + vec2(pc.layer.container.context.extent.x - pc.layer.container.size.x, pc.layer.container.context.extent.y - pc.layer.container.size.y);
|
|
}
|
|
|
|
if(drawable.type == 1){
|
|
// Glyph
|
|
Font font = pc.layer.container.context.fonts.f[drawable.var2];
|
|
Symbol symbol = font.symbols.s[drawable.var1];
|
|
|
|
fragUV = pos * vec2(symbol.width, symbol.height);
|
|
pos = pos * vec2(symbol.width, symbol.height) + vec2(symbol.left, -symbol.top);
|
|
} else {
|
|
fragUV = pos;
|
|
}
|
|
|
|
gl_Position = vec4((pos * drawable.size + drawable.pos + container_offset) * pc.layer.container.context.screen * 2, 0.0, 1.0) - vec4(1.0, 1.0, 0.0, 0.0);
|
|
|
|
fragColor = drawable.color;
|
|
type = drawable.type;
|
|
var1 = drawable.var1;
|
|
var2 = drawable.var2;
|
|
}
|
|
|