#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 glyph; 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; vec4 hsv_to_rgb(vec4 hsv) { float C = hsv[1] * hsv[2]; float H = hsv[0]*6; float X = C * (1 - abs(mod(H, 2) - 1)); vec4 temp; if(0 <= H && H <= 1) { temp = vec4(C, X, 0, 0); } else if(1 <= H && H <= 2) { temp = vec4(X, C, 0, 0); } else if(2 <= H && H <= 3) { temp = vec4(0, C, X, 0); } else if(3 <= H && H <= 4) { temp = vec4(0, X, C, 0); } else if(4 <= H && H <= 5) { temp = vec4(X, 0, C, 0); } else if(5 <= H && H <= 6) { temp = vec4(C, 0, X, 0); } float m = hsv[2] - C; return vec4(temp[0] + m, temp[1] + m, temp[2] + m, hsv[3]); } 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, glyph)); } else if (type == 2) { outColor = fragColor * texture(sampler2D(textures[index], samplers[index]), fragUV); } else if (type == 3) { outColor = hsv_to_rgb(fragColor); } }