diff options
Diffstat (limited to 'src/vector/shaders')
| -rw-r--r-- | src/vector/shaders/paint.frag (renamed from src/vector/shaders/cover.frag) | 14 | ||||
| -rw-r--r-- | src/vector/shaders/paint.vert | 15 |
2 files changed, 24 insertions, 5 deletions
diff --git a/src/vector/shaders/cover.frag b/src/vector/shaders/paint.frag index a57a916..97eb551 100644 --- a/src/vector/shaders/cover.frag +++ b/src/vector/shaders/paint.frag @@ -1,11 +1,16 @@ #version 450 #extension GL_GOOGLE_include_directive : require -// Paints the covered pixels. Mirrors vector/Paint.zig: `param` gives the -// gradient parameter, `stop_color` the color at it. The uniform block is -// generated from vector/layouts.zig. +// Paints a fill: its solid color, or its gradient times its alpha. A draw +// holds many fills, so each vertex says which (paint.vert). Mirrors +// vector/Paint.zig: `param` gives the gradient parameter, `stop_color` the +// color at it. The Paint struct is generated from vector/layouts.zig. +layout(location = 0) flat in vec4 fill_color; +layout(location = 1) flat in int fill_gradient; layout(location = 0) out vec4 out_color; #include "Paint.glsl" +layout(set = 2, binding = 0, std430) readonly buffer Paints { Paint paints[]; }; +#define paint paints[fill_gradient] float offset_at(int i) { return paint.offsets[i / 4][i % 4]; @@ -60,6 +65,5 @@ vec4 stop_color(float t) { } void main() { - vec4 c = paint.row0.w < 0.5 ? paint.color : stop_color(param(gl_FragCoord.xy)); - out_color = c * paint.extra.y; + out_color = fill_gradient < 0 ? fill_color : stop_color(param(gl_FragCoord.xy)) * fill_color; } diff --git a/src/vector/shaders/paint.vert b/src/vector/shaders/paint.vert new file mode 100644 index 0000000..89c2c82 --- /dev/null +++ b/src/vector/shaders/paint.vert @@ -0,0 +1,15 @@ +#version 450 +#extension GL_GOOGLE_include_directive : require +// Painted triangles: device pixels (y down) to normalized device +// coordinates (y up), as in path.vert, with the fill's paint passed on. +#include "Painted.glsl" +#include "Viewport.glsl" + +layout(location = 0) flat out vec4 fill_color; +layout(location = 1) flat out int fill_gradient; + +void main() { + gl_Position = vec4(position.x / viewport.size.x * 2.0 - 1.0, 1.0 - position.y / viewport.size.y * 2.0, 0.0, 1.0); + fill_color = color; + fill_gradient = int(gradient); +} |
