1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
const std = @import("std");
const sketchbook = @import("sketchbook");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const sb = sketchbook.init(b, .{ .target = target, .optimize = optimize });
// The simulation, the synthesiser and the sky, as SPIR-V for the native
// host and WGSL for the web; their uniforms are src/layouts.zig's structs.
const layouts = b.createModule(.{ .root_source_file = b.path("src/layouts.zig") });
const shaders = sb.addShaders(.{
.layouts = .{ .module = layouts, .types = &.{ "SimParams", "LookParams", "SynthParams", "SkyView", "Fade" } },
.sources = &.{
b.path("shaders/sim.comp"),
b.path("shaders/lookahead.comp"),
b.path("shaders/rechord.comp"),
b.path("shaders/synth.comp"),
b.path("shaders/advance.comp"),
b.path("shaders/fullscreen.vert"),
b.path("shaders/fade.frag"),
b.path("shaders/sprite.vert"),
b.path("shaders/sprite.frag"),
b.path("shaders/trail.vert"),
b.path("shaders/trail.frag"),
b.path("shaders/link.vert"),
b.path("shaders/link.frag"),
},
});
const app = sb.app(.{
.name = "spheres",
.root_source_file = b.path("src/main.zig"),
.imports = &.{
.{ .name = "layouts", .module = layouts },
.{ .name = "shaders", .module = shaders.module },
.{ .name = "scope", .module = sb.modules.scope },
},
});
_ = app.addSteps(.{
// Installable, and it opens offline (icons from web/icon.svg).
// ReleaseSmall: a third the size of ReleaseSafe's wasm, and Zig
// 0.17's LLVM spins for many minutes optimising this sketch for speed.
.web = .{ .optimize = .ReleaseSmall, .pwa = .{
.description = "The three-body problem on the GPU, heard: each body a voice in FM, PM, AM, ring or additive synthesis.",
.background = "#05070d",
.theme = "#05070d",
.icons = &.{
.{ .source = b.path("web/icon-192.png"), .size = 192 },
.{ .source = b.path("web/icon-512.png"), .size = 512 },
},
} },
.scripts = &.{b.path("test/play.script")},
});
}
|