diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-16 21:28:20 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-16 21:28:20 -0300 |
| commit | 6933f99ddb2d7103515d26838496309a807bba26 (patch) | |
| tree | 991c2fe7d4a57957222876e190fa4d16a0fb889c /examples/shaders/src/uniforms.zig | |
| parent | 82fca5c9f29124f37f6dcd08e73e6999ce44a69d (diff) | |
| download | sketchbook-6933f99ddb2d7103515d26838496309a807bba26.tar.gz sketchbook-6933f99ddb2d7103515d26838496309a807bba26.zip | |
Move standalone sketches into sketchbook examples
Diffstat (limited to 'examples/shaders/src/uniforms.zig')
| -rw-r--r-- | examples/shaders/src/uniforms.zig | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/examples/shaders/src/uniforms.zig b/examples/shaders/src/uniforms.zig new file mode 100644 index 0000000..5810e46 --- /dev/null +++ b/examples/shaders/src/uniforms.zig @@ -0,0 +1,21 @@ +//! What every fragment shader here reads: the one definition, imported by +//! the sketch, by the Zig shaders, and written out as GLSL for the others. +const builtin = @import("builtin"); + +/// GLSL's vec2. On the GPU a vector, which SPIR-V lays out as vec2 (an +/// array in a uniform block gets a 16-byte stride under std140); on the +/// CPU an array, since extern structs cannot hold vectors there. +pub const vec2 = if (builtin.cpu.arch.isSpirV()) @Vector(2, f32) else [2]f32; + +pub const Uniforms = extern struct { + /// Pixels. + resolution: vec2, + /// Pixels, y up as in GL. + mouse: vec2, + /// Seconds. + time: f32, + pad0: f32 = 0, + pad1: vec2 = .{ 0, 0 }, + + pub const glsl = .{ .uniform = .{ .set = 3, .instance = "u" } }; +}; |
