2024-10-13 22:18:37 -06:00
|
|
|
#version 450
|
2024-10-20 21:59:28 -06:00
|
|
|
#extension GL_EXT_nonuniform_qualifier : require
|
|
|
|
#extension GL_EXT_buffer_reference : require
|
|
|
|
|
|
|
|
#include "ui_common.glsl"
|
|
|
|
|
2024-10-18 16:31:28 -06:00
|
|
|
layout(set = 0, binding = 0) uniform sampler font_samplers[];
|
|
|
|
layout(set = 1, binding = 0) uniform texture2DArray font_textures[];
|
2024-10-13 22:18:37 -06:00
|
|
|
|
2024-10-21 10:09:52 -06:00
|
|
|
layout(set = 2, binding = 0) uniform sampler samplers[];
|
|
|
|
layout(set = 3, binding = 0) uniform texture2D textures[];
|
|
|
|
|
2024-10-13 22:18:37 -06:00
|
|
|
layout(location = 0) in vec4 fragColor;
|
|
|
|
layout(location = 1) in vec2 fragUV;
|
2024-10-16 20:29:19 -06:00
|
|
|
layout(location = 2) flat in uint code;
|
2024-10-18 22:53:06 -06:00
|
|
|
layout(location = 3) flat in uint index;
|
|
|
|
layout(location = 4) flat in uint type;
|
2024-10-22 17:48:37 -06:00
|
|
|
layout(location = 5) flat in vec2 container_offset;
|
2024-10-13 22:18:37 -06:00
|
|
|
|
|
|
|
layout(location = 0) out vec4 outColor;
|
|
|
|
|
|
|
|
void main() {
|
2024-10-24 20:49:59 -06:00
|
|
|
vec2 pos = (gl_FragCoord.xy - vec2(0.5, 0.5))/pc.layer.container.context.scale;
|
2024-10-22 17:48:37 -06:00
|
|
|
vec2 min = container_offset;
|
2024-10-20 21:59:28 -06:00
|
|
|
vec2 max = min + pc.layer.container.size;
|
|
|
|
if(pos.x < min.x || pos.y < min.y
|
|
|
|
|| pos.x > max.x || pos.y > max.y) {
|
|
|
|
discard;
|
|
|
|
}
|
2024-10-18 22:53:06 -06:00
|
|
|
if(type == 0) {
|
|
|
|
outColor = fragColor;
|
|
|
|
} else if(type == 1) {
|
|
|
|
outColor = fragColor * texture(sampler2DArray(font_textures[index], font_samplers[index]), vec3(fragUV, code));
|
2024-10-21 10:09:52 -06:00
|
|
|
} else if (type == 2) {
|
|
|
|
outColor = fragColor * texture(sampler2D(textures[index], samplers[index]), fragUV);
|
2024-10-18 22:53:06 -06:00
|
|
|
}
|
2024-10-13 22:18:37 -06:00
|
|
|
}
|
|
|
|
|