diff options
| author | Gabriel Schneider <[email protected]> | 2026-10-30 21:34:41 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-12 13:22:02 -0300 |
| commit | 2348776791e9dd17afeb12a06ba42a4a71917bcf (patch) | |
| tree | 780c4b12b76c8b97a28408dd40944d65f159fdc7 /src/vector/layouts.zig | |
| parent | 590ba7b9b579b97e34b51ab7e3460ebc85713343 (diff) | |
| download | sketchbook-2348776791e9dd17afeb12a06ba42a4a71917bcf.tar.gz sketchbook-2348776791e9dd17afeb12a06ba42a4a71917bcf.zip | |
sketchbook: a drawing layer on top, host fixes for replay and migration
Diffstat (limited to 'src/vector/layouts.zig')
| -rw-r--r-- | src/vector/layouts.zig | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/src/vector/layouts.zig b/src/vector/layouts.zig index 097e682..5d17568 100644 --- a/src/vector/layouts.zig +++ b/src/vector/layouts.zig @@ -4,13 +4,26 @@ pub const max_stops = 32; -/// A path point in device pixels. +/// A path point in device pixels, for stencil fans. pub const Vertex = extern struct { position: [2]f32, pub const glsl = .vertex; }; +/// A point of a painted triangle (a cover quad, or a convex fill's fan), +/// carrying its fill's paint, so fills of any paint share one draw. +pub const Painted = extern struct { + position: [2]f32, + /// Solid paints: the premultiplied color times the fill's alpha. + /// Gradients: the alpha, in all four. + color: [4]f32, + /// The gradient's index in the pass's `Paint` buffer; -1 for solid. + gradient: f32, + + pub const glsl = .vertex; +}; + pub const Viewport = extern struct { size: [2]f32, pad: [2]f32 = .{ 0, 0 }, @@ -18,7 +31,8 @@ pub const Viewport = extern struct { pub const glsl = .{ .uniform = .{ .set = 1, .instance = "viewport" } }; }; -/// A resolved `Paint`, as `cover.frag` reads it. +/// A resolved gradient `Paint`, as `paint.frag` reads it from a storage +/// buffer (all members are vec4s, so std430 lays it out as std140 would). pub const Paint = extern struct { /// Premultiplied solid color. color: [4]f32, @@ -29,12 +43,12 @@ pub const Paint = extern struct { row1: [4]f32, /// p0 then p1. points: [4]f32, - /// Radius, alpha, stop count. + /// Radius, alpha (unused: the vertices carry it), stop count. extra: [4]f32, /// Stop offsets, four per element. offsets: [max_stops / 4][4]f32, /// Straight stop colors. colors: [max_stops][4]f32, - pub const glsl = .{ .uniform = .{ .set = 3, .instance = "paint" } }; + pub const glsl = .plain; }; |
