39 lines
1.2 KiB
GLSL
39 lines
1.2 KiB
GLSL
|
#version 450
|
||
|
#extension GL_EXT_nonuniform_qualifier : require
|
||
|
#extension GL_EXT_buffer_reference : require
|
||
|
|
||
|
#include "ui_common.glsl"
|
||
|
|
||
|
layout(set = 0, binding = 0) uniform sampler font_samplers[];
|
||
|
layout(set = 1, binding = 0) uniform texture2DArray font_textures[];
|
||
|
|
||
|
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;
|
||
|
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() {
|
||
|
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));
|
||
|
} else if (type == 2) {
|
||
|
outColor = fragColor * texture(sampler2D(textures[index], samplers[index]), fragUV);
|
||
|
}
|
||
|
}
|
||
|
|