summaryrefslogtreecommitdiff
path: root/src/vector/shaders
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-10-30 21:34:41 -0300
committerGabriel Schneider <[email protected]>2026-11-12 13:22:02 -0300
commit2348776791e9dd17afeb12a06ba42a4a71917bcf (patch)
tree780c4b12b76c8b97a28408dd40944d65f159fdc7 /src/vector/shaders
parent590ba7b9b579b97e34b51ab7e3460ebc85713343 (diff)
downloadsketchbook-2348776791e9dd17afeb12a06ba42a4a71917bcf.tar.gz
sketchbook-2348776791e9dd17afeb12a06ba42a4a71917bcf.zip
sketchbook: a drawing layer on top, host fixes for replay and migration
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.vert15
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);
+}