Something went wrong. Try again.
art software for the rest of us
drawing paint image sdl art
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748#version 450
layout(location = 0) in vec4 in_color;layout(location = 1) in vec4 in_borderColor;layout(location = 2) in vec2 in_local;layout(location = 3) in vec2 in_halfSize;layout(location = 4) in vec2 in_borderRound;layout(location = 5) in vec2 in_texcoord;layout(location = 6) flat in float in_mode;
layout(location = 0) out vec4 outColor;
layout(set = 2, binding = 0) uniform sampler2D sourceSampler;
float RoundedBoxSDF(vec2 p, vec2 halfSize, float radius) { vec2 q = abs(p) - halfSize + radius; return length(max(q, 0.0)) + min(max(q.x, q.y), 0.0) - radius;}
void main() { if (in_mode > 0.5) { vec4 source = texture(sourceSampler, in_texcoord); float alpha = source.a * in_color.a; outColor = vec4(source.rgb * in_color.rgb * alpha, alpha); return; }
float borderWidth = in_borderRound.x; float radius = in_borderRound.y; float dist = RoundedBoxSDF(in_local, in_halfSize, radius); float fillAlpha = 1.0 - smoothstep(-1.0, 1.0, dist); float borderAlpha = 0.0; if (borderWidth > 0.0) { float borderDist = abs(dist + borderWidth * 0.5) - borderWidth * 0.5; borderAlpha = 1.0 - smoothstep(-1.0, 1.0, borderDist); }
vec4 result; if (radius > 0.0 || borderWidth > 0.0) { vec4 fill = in_color * fillAlpha; result = mix(fill, in_borderColor, borderAlpha * in_borderColor.a); } else { result = in_color; }
outColor = result;}