mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-01 15:45:38 +00:00
591c89ab0a
They're a pain to support. Encode the single integer value we have as a float instead. Signed-off-by: Elias Naur <mail@eliasnaur.com>
54 lines
1.1 KiB
GLSL
54 lines
1.1 KiB
GLSL
#version 310 es
|
|
|
|
// SPDX-License-Identifier: Unlicense OR MIT
|
|
|
|
precision highp float;
|
|
|
|
layout(binding = 0) uniform Block {
|
|
vec4 transform;
|
|
vec2 pathOffset;
|
|
};
|
|
|
|
layout(location=0) in float corner;
|
|
layout(location=1) in float maxy;
|
|
layout(location=2) in vec2 from;
|
|
layout(location=3) in vec2 ctrl;
|
|
layout(location=4) in vec2 to;
|
|
|
|
layout(location=0) out vec2 vFrom;
|
|
layout(location=1) out vec2 vCtrl;
|
|
layout(location=2) out vec2 vTo;
|
|
|
|
void main() {
|
|
// Add a one pixel overlap so curve quads cover their
|
|
// entire curves. Could use conservative rasterization
|
|
// if available.
|
|
vec2 from = from + pathOffset;
|
|
vec2 ctrl = ctrl + pathOffset;
|
|
vec2 to = to + pathOffset;
|
|
float maxy = maxy + pathOffset.y;
|
|
vec2 pos;
|
|
float c = corner;
|
|
if (c >= 0.5) {
|
|
c -= 0.5;
|
|
// North.
|
|
pos.y = maxy + 1.0;
|
|
} else {
|
|
// South.
|
|
pos.y = min(min(from.y, ctrl.y), to.y) - 1.0;
|
|
}
|
|
if (c >= 0.25) {
|
|
// East.
|
|
pos.x = max(max(from.x, ctrl.x), to.x)+1.0;
|
|
} else {
|
|
// West.
|
|
pos.x = min(min(from.x, ctrl.x), to.x)-1.0;
|
|
}
|
|
vFrom = from-pos;
|
|
vCtrl = ctrl-pos;
|
|
vTo = to-pos;
|
|
pos = pos*transform.xy + transform.zw;
|
|
gl_Position = vec4(pos, 1, 1);
|
|
}
|
|
|