From 6933f99ddb2d7103515d26838496309a807bba26 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Mon, 16 Nov 2026 21:28:20 -0300 Subject: Move standalone sketches into sketchbook examples --- examples/shaders/src/uniforms.zig | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 examples/shaders/src/uniforms.zig (limited to 'examples/shaders/src/uniforms.zig') 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" } }; +}; -- cgit v1.3