Skip to main content

Python frontend for the sdfii Zig SDF engine

Project description

sdfii

A game engine built on signed distance functions.

Geometry is defined by composable SDF primitives. Physics is differentiable end-to-end. Audio uses TidalCycles-style pattern algebra. The runtime layer is reactive, based on the Syndicate model.

Concise, expressive, and intensely programmable. Bon appetit!

Quick start (Python)

pip install sdfii
import sdfii

# Build a scene from SDF primitives.
scene = sdfii.smooth_union(
    sdfii.sphere(radius=0.5),
    sdfii.box(0.8, 0.8, 0.8).translate(0.5, 0.5, 0),
    k=0.3,
)

# Compile and render in the terminal.
with sdfii.Engine() as engine:
    engine.compile(scene)
    engine.build_scene()
    sdfii.terminal_render(engine, width=120, height=40, dt=1 / 60)

Quick start (Zig)

const sdf = @import("sdf");

var builder = sdf.ExprBuilder.init(allocator);
const sphere = try builder.primitive(.sphere, &.{ .radius = 0.5 });
const box = try builder.primitive(.box, &.{ .size = .{ 1, 1, 1 } });
const scene = try builder.binary(.union_, sphere, box);
const program = try sdf.compile(allocator, scene);
const d = sdf.eval(program, .{ 0, 0.5, 0 });

Modules

Module What it does
sdf Expression trees, compilation to flat tapes, interval analysis
scene Incremental scene compilation with dirty detection
query Distance, gradient, contact, raycast, sweep queries
physics Differentiable compliant contact simulation
dataspace Reactive assertion store (Syndicate model)
ecs Sparse-set entity storage with reactive change tracking
world Batched mutation protocol over the ECS kernel
engine Frame orchestrator, C ABI surface
audio TidalCycles-style pattern algebra for audio synthesis
gamelib Animation, navigation, inverse design, WoS PDE solving
backend Compute backend selection and routing
raymarch CPU sphere tracer for terminal and headless rendering
gpu CUDA and Metal ray marching backends
testing Property-based testing with byte-stream shrinking
ffi Shared extern struct definitions for the C boundary
assets Authored SDF geometry catalog with change fingerprinting

Building

Requires Zig 0.14+.

cd native/sdfii
zig build
zig build test

GPU backends build separately: gpu/cuda/ (requires nvcc) and gpu/metal/ (macOS, requires Metal framework).

License

MIT. See LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sdfii-0.1.0-py3-none-manylinux_2_17_x86_64.whl (461.1 kB view details)

Uploaded Python 3manylinux: glibc 2.17+ x86-64

File details

Details for the file sdfii-0.1.0-py3-none-manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for sdfii-0.1.0-py3-none-manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 91ca8bf341cd5e43c9955ef8e7c52b5d3140009aaa52cb8f0cc6bcb8527ac7d7
MD5 3019c857a96dbc71e5a01bcbbfcf4b10
BLAKE2b-256 c971c668d508b12b85d492f9181276aed65420a8acce0546c28c85e252ef661e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page