Zig framework for generating png images (single or multiple frames.)
- Perceptual uniform color space (JzAzBz)
- XKCD's 954 most common colors
- Disney BRDF
- 2D and 3D signed distance fields/functions
- Simplex Noise for 1D, 2D, 3D, 4D inputs
- Squirrel3 noise & randomization
- Filmic Color Grading and Lift/Gamma/Gain
- Supersampling anti-aliasing (SSAA)
- Implicit surfaces for spheres, ellipsoids, torus, elliptical torus, and plane
- Memory limits and measurement
- Fast low-res previews and slow high-res renders
zig build run
Or if you have entr installed:
./autopng.sh
to automatically rebuild and regenerate out/out.png each time the main.zig is saved.
pub fn main() !void {
try renderer.render(.{
.Shader = SimpleBlendShader,
.preview = true,
.memoryLimitMiB = 128,
.ssaa = 3,
.preview_ssaa = 1,
.preview_samples = 600000,
.frames = 1,
.path = "out/out.png",
.frameTemplate = "out/frame-{d:0>6}.png",
.res = Resolutions.Instagram.portrait,
});
}
const SimpleBlendShader = struct {
const Self = @This();
// Put per-frame state here.
time: f64,
pub fn init(allocator: *Allocator, config: renderer.ShaderConfig) !Self {
// Stuff to do once before rendering any pixels. Config includes the
// resolution of the frame, the frame number, and the current time.
return Self{
.time = config.time,
};
}
pub fn deinit(self: *const Self, allocator: *Allocator) void {
// Stuff to do after rendering all the pixels (and before the next frame.)
}
pub fn shade(self: *const Self, x: f64, y: f64) Jazbz {
// Decide on the color of the pixel at x,y.
return mix(
mix(colors.goldenYellow, colors.seaBlue, saturate(x)),
mix(colors.navyBlue, colors.bloodRed, saturate(x)),
saturate(y),
);
}
};