roleplay/client/shader_src/ui.frag

39 lines
1.2 KiB
GLSL

#version 450
#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-21 10:09:52 -06:00
layout(set = 2, binding = 0) uniform sampler samplers[];
layout(set = 3, binding = 0) uniform texture2D textures[];
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;
layout(location = 3) flat in uint index;
layout(location = 4) flat in uint type;
layout(location = 5) flat in vec2 container_offset;
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;
vec2 min = container_offset;
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;
}
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);
}
}