ALICE-SDF
English | 日本語
A.L.I.C.E. - Adaptive Lightweight Implicit Compression Engine
"Don't send polygons. Send the law of shapes."
Overview
ALICE-SDF is a 3D/spatial data specialist that transmits mathematical descriptions of shapes (Signed Distance Functions) instead of polygon meshes. This enables:
- 10-1000x compression compared to traditional mesh formats
- Infinite resolution - shapes are mathematically perfect at any scale
- CSG operations - boolean operations on shapes without mesh overhead
- Real-time raymarching - GPU-accelerated rendering
- PBR materials - metallic-roughness workflow compatible with UE5/UE6/Unity/Godot
- Keyframe animation - parametric deformation with timeline tracks
- Asset pipeline - OBJ import/export, glTF 2.0 (.glb) export, FBX, USD, Alembic, Nanite, STL, PLY, 3MF, ABM export
- 5-layer mesh persistence - ABM binary format, LOD chain persistence, chunked mesh cache with FIFO eviction, Unity/UE5/UE6 native export
- Manifold mesh guarantee - validation, repair, and quality metrics
- Adaptive Marching Cubes - octree-based mesh generation, detail where it matters
- Dual Contouring - QEF-based mesh generation that preserves sharp edges and corners
- V-HACD convex decomposition - automatic convex hull decomposition for physics
- Attribute-preserving decimation - QEM with UV/tangent/material boundary protection
- Advanced simplifier options - per-vertex lock mask (
lock_vertices) for LOD seam preservation, absolute/relative error thresholds (error_absolute) - Decimation-based LOD - progressive LOD chain from high-res base mesh
- meshopt-compatible codec - binary-compatible index / vertex buffer compression (indexcodec v1 + vertexcodec v0/v1), verified against reference vectors produced by the zeux/meshoptimizer C++ library
- glTF
EXT_meshopt_compression-io::meshopt_gltfmodule +GltfConfig::meshopt_compressoption; POSITION / NORMAL / TEXCOORD_0 / JOINTS_0 / WEIGHTS_0 / indices all compressible with per-attribute channel estimation (u8 / u16 / u32 XOR + 8-rotation heuristic) - Vertex filters - Octahedral (normal / tangent, 50-75% smaller with <1% angular error), Quaternion (rotation, largest-component + cyclic swizzle), Exponential (float mantissa + shared exponent)
- Triangle stripifier - Evans-Skiena-Varshney greedy strip algorithm with 8-triangle lookahead (~48% index reduction on closed meshes), supports primitive-restart or degenerate-triangle joining
- Nanite-style meshlet clusters - V2 adjacency +
cone_weightgrow withNormalCone(basic +cone_apex) for VulkanVK_EXT_mesh_shader/ DirectX 12 mesh shader culling - 73 primitives, 24 operations, 7 transforms, 24 modifiers (128 total) - industry-leading shape vocabulary
- Chamfer & Stairs blends - hard-edge bevels and stepped/terraced CSG transitions
- Interval Arithmetic - conservative AABB evaluation for spatial pruning and Lipschitz bound tracking
- Relaxed Sphere Tracing - over-relaxation with Lipschitz-adaptive step sizing
- Neural SDF - pure-Rust MLP that approximates an SDF tree ~10-100x faster for complex scenes
- SDF-to-SDF Collision - grid-based contact detection with interval arithmetic AABB pruning
- CSG Tree Optimization - identity transform/modifier removal, nested transform merging, smooth→standard demotion
- Analytic Gradient - single-pass gradient via chain rules and Jacobian propagation (9 analytic + 44 numerical-fallback primitives)
- Automatic Differentiation - Dual Number forward-mode AD, Hessian estimation, mean curvature computation
- 2D SDF module - pure 2D SDF primitives (circle, rect, bezier, font glyph) with bilinear sampling
- CSG Tree Diff/Patch - structural diff between SDF trees for undo/redo and network sync
- Parametric Constraint Solver - Gauss-Newton optimization for geometric constraints (fixed, distance, sum, ratio)
- Distance Field Heatmap - cross-section slicing with 4 color maps (coolwarm, binary, viridis, magma)
- Shell / Offset Surface - variable-thickness shell modifier with inner/outer offset control
- Volume & Surface Area - Monte Carlo estimation with deterministic PRNG and standard error
- ALICE-Font Bridge - font glyph → 2D/3D SDF conversion, text layout, 3D extrusion (
--features font, not available on the crates.io v1.7.7 release — see Installation note, restoration planned for v1.8.0) - Auto Tight AABB - interval arithmetic + binary search to find minimal bounding box containing the SDF surface
- 7 evaluation modes - interpreted, compiled VM, SIMD 8-wide, BVH, SoA batch, JIT, GPU
- 3 shader targets - GLSL, WGSL, HLSL transpilation
- Engine integrations - Unity, Unreal Engine 5 / 6, VRChat, Godot, WebAssembly
Text-to-3D Pipeline (Server)
ALICE-SDF includes a FastAPI server that converts natural language text into real 3D geometry via LLM-generated SDF trees.
User: "A medieval castle" → LLM (Claude/Gemini) → SDF JSON → ALICE-SDF → GLB/OBJ
text ~5-50s 20 nodes <55ms mesh
Architecture
┌─────────────┐ ┌──────────────┐ ┌───────────────┐ ┌──────────┐
│ FastAPI │ │ LLM Service │ │ SDF Service │ │ Output │
│ Server │────▶│ Claude API │────▶│ from_json() │────▶│ GLB │
│ │ │ Gemini API │ │ compile() │ │ OBJ │
│ POST /gen │ │ System │ │ to_mesh() │ │ JSON │
│ WS /ws/gen │ │ Prompt │ │ export_glb() │ │ Viewer │
│ GET /viewer │ └──────────────┘ └───────────────┘ └──────────┘
└─────────────┘
API Endpoints
| Method | Path | Description |
|---|---|---|
POST |
/api/generate |
Text → 3D mesh (GLB/OBJ/JSON) |
POST |
/api/validate |
Validate SDF JSON structure |
POST |
/api/mesh |
SDF JSON → mesh (GLB/OBJ) |
GET |
/api/examples |
List few-shot example scenes |
GET |
/api/viewer |
Three.js GLB viewer (browser) |
GET |
/api/health |
Server health check |
WS |
/ws/generate |
Streaming generation with progressive preview |
Generated Scene Gallery
Scenes generated by Gemini 2.5 Flash from natural language prompts:
| Prompt | Nodes | Vertices | Triangles | LLM Time |
|---|---|---|---|---|
| "A medieval castle with towers" | 18 | 2,105 | 4,248 | 49.4s |
| "A robot standing on a platform" | 18 | 750 | 1,184 | 17.5s |
| "An underwater coral reef scene" | 15 | 2,666 | 5,166 | 63.3s |
| "A simple mushroom on grass" | 9 | 8,237 | 16,224 | 6.6s |
| "火山地帯に宇宙船" (Volcanic terrain with spaceship) | 22 | 10,466 | 20,618 | 20.5s |
Hand-crafted few-shot examples (used in LLM system prompt):
| Scene | Description | Nodes | Vertices | Triangles |
|---|---|---|---|---|
sphere_on_ground |
Sphere on a flat ground (Union + Plane) | 4 | 1,270 | 2,448 |
snowman |
3-sphere snowman (SmoothUnion) | 8 | 422 | 840 |
castle_tower |
Tower with battlements (PolarRepeat) | 11 | 1,030 | 2,244 |
alien_mushroom_forest |
Mushroom grid (RepeatFinite + Torus stems) | 9 | 4,167 | 7,854 |
twisted_pillar |
Twisted box + floating hollow sphere (Twist + Onion) | 7 | 510 | 968 |
mechanical_gear |
Gear with teeth and axle hole (PolarRepeat + Subtraction) | 9 | 465 | 912 |
Scene JSON files are stored in server/examples/scenes/.
Quick Start (Server)
# 1. Build Python bindings
&&
# 2. Install server dependencies
# 3. Set API keys
# for Claude
# for Gemini
# 4. Start server
# 5. Generate 3D from text
# 6. Open browser viewer
LLM Providers
| Provider | Model | Speed | Best For |
|---|---|---|---|
| Claude | Haiku 4.5 | ~2-5s | Simple scenes, fast iteration |
| Claude | Sonnet 4.5 | ~5-15s | Complex scenes, high accuracy |
| Gemini | 2.5 Flash | ~5-50s | Complex scenes (thinking model) |
| Gemini | 2.5 Pro | ~10-60s | Maximum quality |
Performance Budget
| Step | Time | Notes |
|---|---|---|
| LLM inference | 2-60s | Depends on model and complexity |
| JSON parse | <1ms | serde_json |
| SDF compile | ~1ms | SdfNode → CompiledSdf |
| Mesh generation (res=64) | ~45ms | Parallel Marching Cubes |
| GLB export | ~5ms | |
| Total (excluding LLM) | <55ms | Real-time capable |
Robustness Features
- JSON repair: Automatic brace/bracket completion for truncated LLM output
- Structure validation: Pre-validates Boolean ops (a/b) and transforms (child) before Rust serde
- Retry with feedback: Up to 2 retries with error message fed back to LLM
- Rate limit handling: Automatic wait-and-retry on 429 errors
- Complexity constraints: System prompt limits scenes to 15-20 nodes, nesting depth ≤6
Server Directory Structure
server/
├── main.py # FastAPI app, REST + WebSocket endpoints
├── config.py # API keys, model config (env vars)
├── models.py # Pydantic request/response models
├── services/
│ ├── llm_service.py # Claude/Gemini API with retry logic
│ └── sdf_service.py # alice_sdf wrapper (parse, mesh, export)
├── prompts/
│ ├── system_prompt.py # 36-node-type SDF grammar for LLM
│ └── examples.py # 6 few-shot examples
├── examples/
│ └── scenes/ # Pre-built scene JSON files
│ ├── sphere_on_ground.json
│ ├── snowman.json
│ ├── castle_tower.json
│ ├── alien_mushroom_forest.json
│ ├── twisted_pillar.json
│ └── mechanical_gear.json
├── static/
│ └── viewer.html # Three.js GLB viewer
├── tests/
│ ├── test_api.py # 7 API endpoint tests
│ ├── test_llm_service.py # 17 JSON extraction/validation tests
│ └── test_sdf_service.py # 13 SDF pipeline tests
└── requirements.txt
Running Tests
ALICE-View (Real-time 3D Viewer)
ALICE-View is a native GPU raymarching viewer built with wgpu. It renders SDF trees directly on the GPU via WGSL transpilation — no mesh conversion needed.
SDF JSON → ALICE-SDF (WGSL transpile) → wgpu GPU Raymarching → Real-time 3D
~1ms 60 FPS
Features
- GPU Raymarching — SdfNode tree transpiled to WGSL shader, evaluated per-pixel on GPU
- Drag & Drop — Drop
.json/.asdf/.asdf.jsonfiles onto the window - File Dialog — File > Open (Ctrl+O) with format filters
- Camera Controls — Mouse orbit, scroll zoom, WASD movement
- Live SDF Panel — Node count, raymarching parameters (max steps, epsilon, AO)
Supported Formats
| Extension | Format | Description |
|---|---|---|
.json |
SDF JSON | Text-to-3D pipeline output, few-shot examples |
.asdf.json |
ALICE SDF JSON | Native ALICE-SDF JSON format |
.asdf |
ALICE SDF Binary | Compact binary with CRC32 |
.alice / .alz |
ALICE Legacy | Procedural content (Perlin, Fractal) |
Quick Start
# Open a specific file
# Or launch empty and drag & drop files onto the window
Keyboard Shortcuts
| Key | Action |
|---|---|
W/A/S/D |
Camera movement |
Mouse drag |
Orbit camera |
Scroll |
Zoom in/out |
Ctrl+O |
Open file dialog |
Q |
Quit |
Viewing Text-to-3D Results
Generated scene JSON files from the Text-to-3D pipeline can be viewed directly:
# View a generated scene
# Or drag any of these onto the window:
# server/examples/scenes/castle_tower.json
# server/examples/scenes/mechanical_gear.json
# server/examples/scenes/alien_mushroom_forest.json
Core Concepts
SDF (Signed Distance Function)
An SDF returns the shortest distance from any point to the surface:
- Negative = inside the shape
- Zero = on the surface
- Positive = outside the shape
SdfNode Tree Structure
SdfNode
|-- Primitive (73): Sphere, Box3D, Cylinder, Torus, Plane, Capsule, Cone, Ellipsoid,
| RoundedCone, Pyramid, Octahedron, HexPrism, Link, Triangle, Bezier,
| RoundedBox, CappedCone, CappedTorus, InfiniteCylinder, RoundedCylinder,
| TriangularPrism, CutSphere, CutHollowSphere, DeathStar, SolidAngle,
| Rhombus, Horseshoe, Vesica, InfiniteCone, Heart, Gyroid,
| Tube, Barrel, Diamond, ChamferedCube, SchwarzP, Superellipsoid, RoundedX,
| Pie, Trapezoid, Parallelogram, Tunnel, UnevenCapsule, Egg,
| ArcShape, Moon, CrossShape, BlobbyCross, ParabolaSegment,
| RegularPolygon, StarPolygon, Stairs, Helix,
| Tetrahedron, Dodecahedron, Icosahedron, ← Platonic solids (GDF)
| TruncatedOctahedron, TruncatedIcosahedron, ← Archimedean solids
| BoxFrame, ← IQ wireframe box
| DiamondSurface, Neovius, Lidinoid, IWP, FRD, ← TPMS surfaces
| FischerKochS, PMY, ← TPMS surfaces
| Circle2D, Rect2D, Segment2D, Polygon2D, ← 2D primitives (extruded)
| RoundedRect2D, Annular2D, ← 2D primitives (extruded)
| Terrain ← procedural biome terrain (FBM + Voronoi erosion)
|-- Operation (24): Union, Intersection, Subtraction,
| SmoothUnion, SmoothIntersection, SmoothSubtraction,
| ChamferUnion, ChamferIntersection, ChamferSubtraction,
| StairsUnion, StairsIntersection, StairsSubtraction,
| ExpSmoothUnion, ExpSmoothIntersection, ExpSmoothSubtraction, ← IQ exponential smooth
| XOR, Morph, ← Boolean / Interpolation
| ColumnsUnion, ColumnsIntersection, ColumnsSubtraction, ← hg_sdf columns
| Pipe, Engrave, Groove, Tongue ← hg_sdf advanced
|-- Transform (7): Translate, Rotate, Scale, ScaleNonUniform,
| ProjectiveTransform, ← perspective projection with inv_matrix
| LatticeDeform, ← Free-Form Deformation (FFD) grid
| SdfSkinning ← bone-weight skeletal deformation
|-- Modifier (24): Twist, Bend, RepeatInfinite, RepeatFinite, Noise, Round, Onion, Elongate,
| Mirror, Revolution, Extrude, Taper, Displacement, SineDisplacement, PolarRepeat, SweepBezier,
| Shear, ← 3-axis shear deformation
| OctantMirror, ← 48-fold symmetry
| IcosahedralSymmetry, ← 120-fold icosahedral symmetry
| IFS, ← Iterated Function System fractals
| HeightmapDisplacement, ← heightmap-driven surface displacement
| SurfaceRoughness, ← FBM noise roughness
| Animated, ← timeline-driven parameter animation
| WithMaterial ← PBR material assignment
Installation
Note (v1.7.7, crates.io landing 2026-09-12) — 5 bridge features are currently removed from
[features]:codec/physics/asp/sdf-cache/font. Theirsrc/*_bridge.rsmodules remain#[cfg(feature = "...")]-gated so they simply do not compile on crates.io 1.7.7. Users who need the bridges keep usingpath/gitdeps against the sibling repos (ALICE-Codec/ALICE-Physics/libasp/alice-cache/alice-font). Scheduled restoration in v1.8.0 once the transitive dep chain publishes to crates.io. See CHANGELOG.md[v1.7.7] - 2026-09-12entry for details, including the RUSTSEC-2025-0020 (pyo3) and RUSTSEC-2025-0141 (bincode) security fixes and the pyo30.23 → 0.29/ bincode1.3 → 2.0bumps.
Rust
Python
Claude Code / Codex Skill
The skills/implicit-cad/ directory bundles ALICE-SDF as an installable agent skill for Claude Code / Codex. It exposes SDF authoring, GLSL/WGSL/HLSL transpile, and mesh export (GLB/OBJ/STL/PLY/3MF) as thin CLI wrappers around this crate. See skills/implicit-cad/SKILL.md. Companion alice-lol-sdf skill (in the ALICE-LOL repo) provides the DSL front-end with LLM constrained-decoding support.
Usage
Choose Your Path
Pick the path that matches your role. All paths share the same SdfNode intermediate representation, so you can mix them (e.g. build in LOL, transpile to GLSL, evaluate in Python).
| You are… | Path | Best for | Section |
|---|---|---|---|
| Rust dev, want it declarative | ALICE-LOL DSL | Scene composition, GPU shader transpile, compile-time law checks | ↓ |
| Rust dev, need low-level control | Rust direct SdfNode | Custom modifier nodes, hand-tuned code paths | ↓ |
| Python / data-science user | Python bindings | NumPy batch evaluation, mesh export, notebook workflows | ↓ |
| Unity / UE5 / Godot integrator | C-ABI FFI | Native plugin, real-time evaluation from game engine | docs/UNREAL_ENGINE.md / docs/GODOT_GUIDE.md |
| Web / WebGPU developer | WASM build | Browser-side SDF evaluation + WGSL shader compile | docs/WASM_GUIDE.md |
| Mobile (iOS / Android) | XCFramework / AAR | On-device evaluation in Swift / Kotlin | Mobile section |
| 3D artist / VFX | Cookbook recipes | Copy-paste procedural forms, displacement, tiling | docs/VFX_COOKBOOK.md |
| First time here | 30-second sample below ↓ | Sanity check the install | ↓ |
Hello, First SDF (30 seconds)
The smallest useful sample — construct, evaluate, mesh, done:
use *;
let sphere = sphere;
let d = eval;
assert!; // point 0.5 away from center → distance -0.5 (inside)
let mesh = sdf_to_mesh;
println!;
Once this runs, jump to the path that matches your role above.
With ALICE-LOL DSL (Recommended)
The easiest way to create SDF scenes is ALICE-LOL — a lol! proc_macro that lets you write SDF trees declaratively instead of constructing them by hand.
# Cargo.toml
[]
= { = "../ALICE-SDF" }
= { = "../ALICE-LOL/alice-lol" }
Before (manual SdfNode construction):
use *;
let scene = SmoothUnion ;
After (LOL DSL):
use ;
let scene = lol! ;
Same SdfNode tree, fraction of the code. All 76 constructs (27 primitives, 23 CSG ops, 4 transforms, 19 modifiers, 2 time controls, 3 law constraints) work as function calls.
Transpile to GPU shaders:
let glsl = to_glsl; // GLSL
let wgsl = to_wgsl; // WGSL (WebGPU)
let hlsl = to_hlsl; // HLSL (DirectX)
CPU evaluation:
let dist = eval;
Mesh export from a LOL scene:
use lol;
use *;
let scene = lol! ;
let mesh = sdf_to_mesh;
write_obj?;
write_glb?;
Inject Rust variables at runtime:
let radius = 1.5_f32;
let height = compute_height;
let scene = lol! ;
Validate shape constraints at compile time:
use ;
let laws = new
.add // shapes must not intersect
.add; // wall thickness >= 0.1
let report = laws.check;
For full LOL documentation, see ALICE-LOL README.
Rust (Direct SdfNode Construction)
For fine-grained control or when you need access to advanced node types not yet covered by the LOL DSL, you can construct SdfNode trees directly:
use *;
// Create a sphere with radius 1
let sphere = sphere;
// Subtract a box from it
let result = sphere.subtract;
// Evaluate distance at a point
let distance = eval;
// Convert to mesh
let mesh = sdf_to_mesh;
Python
# Create primitives
=
=
# CSG operations (method syntax)
=
# Operator overloads (Pythonic syntax)
=
=
= | # a.union(b)
= & # a.intersection(b)
= - # a.subtract(b)
# Transform
=
# Evaluate at points (NumPy array)
=
=
# Compiled evaluation (2-5x faster for repeated use)
=
= # compiled batch
, = # compiled mesh
# Convert to mesh
, =
# Export to multiple formats
# UV unwrap → (positions[N,3], uvs[N,2], indices[M])
, , =
Sine Displacement (v1.7.3, isotropic + anisotropic)
SineDisplacement adds a sin-wave perturbation to any child SDF. As of v1.7.3 it accepts a per-axis Vec3 frequency, so you can drive fine XYZ-independent patterns (scales, wood grain, cloth drape) from a single node.
Two ergonomic constructors:
| Method | Frequency type | Use for |
|---|---|---|
.sine_displacement(amplitude, freq: f32) |
isotropic (Vec3::splat) |
uniform ripples / roughness / cellular scales |
.sine_displacement_aniso(amplitude, freq: Vec3) |
per-axis | wood grain, cloth drape, fish scales, wave-fronts along one axis |
use *;
use Vec3;
// Isotropic: sphere with fine cellular perturbation.
let scales = sphere.sine_displacement;
// Anisotropic: long thin scales (high freq on X, low on Y and Z).
let fish_scales = sphere.sine_displacement_aniso;
// Anisotropic: wood grain (rings dense along Y, sparse elsewhere).
let wood = box3d
.sine_displacement_aniso;
Both variants transpile to GLSL / WGSL / HLSL through the standard pipeline (to_glsl / to_wgsl / to_hlsl). The transpiler emits per-axis sin(freq.x * p.x) * sin(freq.y * p.y) * sin(freq.z * p.z), matching the CPU modifier_sine_displacement reference. Interval-arithmetic bounds and diff (derivative) support are already wired, so displaced SDFs remain safe for raymarching and gradient-based sampling.
Common Recipes
Copy-paste patterns that come up over and over. All examples assume use alice_sdf::prelude::*;.
1. Rounded box (chamfer)
let rounded = box3d.round;
2. Smooth blob (union with soft blend)
let blob = sphere
.smooth_union;
// signature: smooth_union(self, other: Self, k: f32) — k is the blend radius
3. Hollow shell (onion)
let shell = sphere.onion; // 5cm thick wall
4. Infinite tiling (repeat_infinite)
let tiles = box3d.repeat_infinite;
// finite variant: .repeat_finite([count_x, count_y, count_z], spacing)
5. Twist along Y
let twisted = box3d.twist; // 1.5 rad/unit around Y
6. Displacement (sine + noise)
let rough = sphere.sine_displacement;
7. CSG chain (subtract holes from a plate)
let plate = box3d;
let hole = cylinder;
let drilled = plate
.subtract
.subtract
.subtract;
8. GPU transpile (WebGPU / Metal / DX12)
use ;
let scene = lol! ;
let wgsl_source = to_wgsl; // paste into a WGSL shader
For VFX-focused patterns (fluid simulation, mandelbulb, magic effects, ribbon FX, plasma balls, portals, force fields) see docs/VFX_COOKBOOK.md.
For general recipe collection (procedural terrain, camera-relative modifiers, bounding-volume tricks, LOD strategy) see docs/COOKBOOK.md.
Where to go next
| I want to… | See |
|---|---|
Understand every SdfNode variant |
docs/API_REFERENCE.md |
| Set up a fresh project | docs/QUICKSTART.md |
| Deep dive into the compiler / evaluator internals | docs/ARCHITECTURE.md |
| Wire it into Unity / Unreal / Godot | docs/UNREAL_ENGINE.md · docs/GODOT_GUIDE.md |
| Use it from Python | docs/PYTHON_GUIDE.md |
| Ship it in a browser | docs/WASM_GUIDE.md |
| Build 3D-print-ready parts | See ALICE-Bamboo (LOL → SDF → 3MF pipeline) |
For deep technical sections (Material / Animation / Architecture / Mesh / Platonic Solids / Interval Arithmetic / Neural SDF / Collision / Analytic Gradient / Dual Contouring / CSG Tree Optimization / Auto Tight AABB / Texture Fitting / Raymarching / FFI bindings / Feature Flags / Physics Bridge / 3D Print Pipeline / Performance / Benchmarking / Unity / VRChat / Unreal / Godot / Cross-Crate Bridges / Asset Delivery Network / Nanite hybrid pipeline) see docs/USAGE.md.
License
Open Core Model - Free for creators, licensed for infrastructure.
| Component | License | Use Case |
|---|---|---|
| Core Engine (Rust) | MIT License | Hack away! |
| Unity Integration | ALICE Community License | Free for Indie & Game Dev |
| Enterprise / Cloud Infra | Commercial License | Contact for pricing |
Free Use (No License Required)
- Personal projects
- Indie game development (any revenue)
- AAA game studios (shipped games)
- Educational & research
- Open source projects
Commercial License Required
- Metaverse platforms (10,000+ MAU)
- Cloud streaming services (SaaS/PaaS)
- Infrastructure providers
- Competing products
See LICENSE (MIT) and LICENSE-COMMUNITY for details.
Content you create (.asdf files, worlds, games) is 100% yours. No royalties.
LLM × 3D Creation Pipeline (SDF + LOL + View + Physics)
Four ALICE projects combine to form an end-to-end text-to-3D workflow — from natural language to physically simulated 3D scenes:
User: "A snowman with a top hat"
│
▼
┌──────────────────┐ LOL DSL or JSON ┌───────────────────┐ WGSL / GLB ┌──────────────┐
│ LLM │ ────────────────▶ │ ALICE-SDF │ ────────────▶ │ ALICE-View │
│ (Claude/Gemini) │ │ parse → compile │ │ GPU Preview │
│ │ │ → mesh / shader │ │ 60 FPS │
└──────────────────┘ └────────┬──────────┘ └──────────────┘
│
│ SdfField trait
│ (feature = "physics")
▼
┌───────────────────┐
│ ALICE-Physics │
│ Fix128 XPBD │
│ SDF CCD / Forces │
│ Destruction / Fluid│
└───────────────────┘
| Component | Role |
|---|---|
| ALICE-LOL | LLM-friendly DSL — fewer tokens, lower hallucination rate than raw JSON. runtime_parser::parse_lol() converts LLM text output into SdfNode at runtime |
| ALICE-SDF | Core engine — SIMD/BVH/JIT evaluation, mesh generation (Marching Cubes / Dual Contouring), GLSL/WGSL/HLSL transpilation, GLB/OBJ/STL export |
| ALICE-View | Real-time GPU raymarching viewer — drag & drop JSON/ASDF files, instant visual feedback |
| ALICE-Physics | Deterministic 128-bit fixed-point physics — SDF shapes become collision geometry via SdfField trait. SDF CCD, force fields, destruction, cloth, fluid simulation |
LLM-generated shapes are not just visual — they are physics-ready. The CompiledSdfField wrapper exposes the SDF as an O(1) collision query surface, enabling rigid body, destruction, and fluid interactions without convex decomposition.
v1.7.7 note — The
physicsfeature is not available on the crates.io 1.7.7 release. Until v1.8.0, use apath/gitdep against this repo withalice-sdf = { git = "https://github.com/ext-sakamoro/ALICE-SDF", features = ["physics"] }. See Installation.
Quick Start
# 1. Start the Text-to-3D server (generates LOL/JSON via LLM)
# 2. POST a prompt — server returns SDF JSON
# 3. View the result in real-time
Programmatic (Rust)
use parse_lol;
use *;
use CompiledSdfField;
// LLM output (text) → SdfNode
let lol_text = r#"smooth_union(0.3, sphere(1.0), translate(0.0, 1.5, 0.0, sphere(0.7)))"#;
let scene = parse_lol.unwrap;
// GPU shader for rendering
let wgsl = to_wgsl;
// Export mesh
let mesh = sdf_to_mesh;
// Physics-ready collision shape (no convex decomposition needed)
let field = new;
// field.distance(x, y, z) → f32 (1 eval)
// field.distance_and_normal(x, y, z) → (f32, Vec3) (4 evals, tetrahedral)
Why LOL over JSON?
| Metric | JSON (SdfNode) | LOL DSL |
|---|---|---|
| Tokens per shape | ~120 | ~30 |
| LLM error rate | higher (bracket nesting) | lower (function-call style) |
| Runtime parsing | serde_json |
runtime_parser::parse_lol() |
| Compile-time macro | — | lol! { ... } |
For complex scenes, LOL typically uses 3-4x fewer tokens, which reduces both LLM cost and hallucination.
Mobile (iOS / Android)
ALICE-SDF ships a UniFFI-based mobile SDK so the Rust core can be called directly from Swift (iOS) and Kotlin (Android).
Supported targets
| Platform | Architectures | Distribution |
|---|---|---|
| iOS | aarch64-apple-ios (device), aarch64-apple-ios-sim, x86_64-apple-ios |
AliceSDF.xcframework (static lib + Swift bindings) |
| Android | arm64-v8a, armeabi-v7a, x86_64, x86 |
libuniffi_alice_sdf.so + Kotlin bindings |
Verified on real devices (2026-06-06)
| Platform | Hardware | Result |
|---|---|---|
| iOS | iPhone 17 Pro Simulator (iOS 26.0, Xcode 26.2) | ✅ Demo app boots, renders 2D SDF slice (screenshot) |
| Android | Pixel 6 emulator (Android 14 / API 34, arm64-v8a) | ✅ Demo app boots, renders 2D SDF slice (screenshot) |
Both platforms produced identical numerical output (sphere d = 0.2806, smooth_union(k=0.3) = 0.2056) — proving binary parity of the Rust core across Apple Silicon and Android ARM.
Quick start (Swift)
import AliceSDF
let d = sdfSphere(
point: Vec3(x: 1, y: 0, z: 0),
center: Vec3(x: 0, y: 0, z: 0),
radius: 1.0
)
// d ≈ 0 (point on sphere surface)
let blended = opSmoothUnion(a: 0.5, b: 0.6, k: 0.1)
// blended < 0.5 (smooth union pulls below min)
Quick start (Kotlin)
import uniffi.alice_sdf.*
val d = sdfSphere(
point = Vec3(1f, 0f, 0f),
center = Vec3(0f, 0f, 0f),
radius = 1.0f
)
// d ≈ 0
val blended = opSmoothUnion(a = 0.5f, b = 0.6f, k = 0.1f)
Build the SDK
# iOS XCFramework (device + simulator)
&&
# Android .so + Kotlin bindings (4 ABI)
&&
Sample apps and the full integration guide live in mobile/.
Web (WebAssembly), VFX (OpenVDB), Bevy Engine
wasm feature — WebAssembly bindings
Browser-side SDF evaluation + slice rendering via wasm-bindgen.
JavaScript usage:
import init from './alice_sdf.js';
await ;
const d = ; // ≈ 0
const rgba = ; // Uint8Array for canvas
openvdb feature — OpenVDB Float Grid I/O
Bake SDF trees into voxel grids for DCC tools (Houdini, Maya, Nuke, Blender).
use ;
use *;
let node = sphere;
let bytes = bake_to_vdb.unwrap;
write.unwrap;
Backed by vdb-rs 0.6 (pure Rust). Currently writes a compact custom container (ALICEVDB1); full OpenVDB binary parity is planned as vdb-rs exposes its write API.
alice-sdf-bevy — Bevy 0.18 plugin
Drop-in plugin that turns SdfShape components into renderable Mesh3d assets automatically.
use *;
use ;
See bindings/bevy/alice-sdf-bevy/examples/sphere_demo.rs for a full 3-shape demo with camera + light.
3D Gaussian Splatting (.splat)
Convert SDF surfaces into Inria 3DGS-compatible .splat files (32 bytes/splat: position + scale + RGBA + compressed quaternion). Drop-and-drop into any WebGL viewer (gsplat.tech / SuperSplat / antimatter15/splat).
use ;
use *;
let node = sphere;
let cfg = SplatConfig ;
let splats = sdf_to_splats;
save_splat.unwrap;
Blender Add-on (bindings/blender/)
Blender 4.0+ add-on. Imports .asdf directly and adds an "ALICE-SDF" N-panel with sphere/box/torus generators. Requires the alice_sdf Python module (built via cargo build --release --features python).
Install: zip the alice_sdf_blender/ folder and load via Edit > Preferences > Add-ons > Install....
Houdini Python Plugin (bindings/houdini/)
SideFX Houdini 20+ Python module + Python SOP code for .asdf loading and primitive generation. Auto-installer detects $HSITE / $HOUDINI_USER_PREF_DIR.
=
MagicaVoxel .vox IO
Voxelize an SDF tree and save as a MagicaVoxel-compatible .vox file (v150 RIFF) — ideal for indie / voxel art pipelines.
use ;
use *;
let node = sphere;
let cfg = VoxConfig ;
save_vox.unwrap;
@alice-sdf/threejs — Three.js / React Three Fiber wrapper
TypeScript npm package built on the wasm feature. Exposes AliceSDF class, Three.js DataTexture helper, optional <AliceSDFSlicePlane> for @react-three/fiber, and WebXR raymarching helpers.
import { AliceSDF } from "@alice-sdf/threejs";
const sdf = await AliceSDF.load("/alice_sdf.js");
const tex = await sdf.createSliceTexture(512, 512, [0, 0, 0], 1.0, 2.5);
scene.add(new THREE.Mesh(new THREE.PlaneGeometry(2, 2), new THREE.MeshBasicMaterial({ map: tex })));
Maya Python Plugin (bindings/maya/)
Autodesk Maya 2024+ Python module — adds "ALICE-SDF" top-level menu, builds polygon meshes through MFnMesh.
Nuke Python Plugin (bindings/nuke/)
Foundry Nuke 15 / 16+ Python module — exports .asdf to volume binary and 2D RGBA slices for compositing pipelines.
Cinema 4D Python Plugin (bindings/cinema4d/)
Maxon Cinema 4D 2024 / 2025 / 2026+ Python module — generates PolygonObject from SDF primitives and imports .asdf directly into the C4D scene.
# C4D units: cm
CAD Interchange — STEP / IGES (FEM-style mesh export)
ALICE-SDF can tessellate any SDF tree (Marching Cubes) and emit either:
- STEP AP203 (ISO 10303-21 ASCII) —
CARTESIAN_POINT+POLY_LOOP+FACE_OUTER_BOUNDtriangles. Note: this is a mesh-style representation, not a fullADVANCED_FACE/MANIFOLD_SOLID_BREPBREP. Tools that accept faceted STEP (FreeCAD, some Rhino plugins, mesh-aware CAD viewers) can open it; tools that strictly requireMANIFOLD_SOLID_BREPmay reject it. Full BREP wrapping is planned (seedocs/PUBLISH.md). - IGES (Entity 134 Node + Entity 136 Finite Element) — FEM mesh entities. Intended for FEM solvers and viewers that understand these entity types. Standard CAD modeling tools usually expect Entity 144 (Trimmed Surface), which is not yet emitted.
Both files round-trip in the unit tests but real-world CAD interoperability is best verified per-tool.
use ;
use ;
use *;
let node = sphere;
export_step.unwrap;
export_iges.unwrap;
alice-sdf-openxr — Native VR / AR Helpers (bindings/openxr/)
A small Rust crate on top of the openxr bindings that turns ALICE-SDF distance queries into VR-friendly helpers. Works with Meta Quest standalone (Android APK), PC VR (SteamVR / Oculus PC), Microsoft Mixed Reality, and Apple Vision Pro via its OpenXR backend.
use ;
use Vec3;
// inside an XRFrame callback
let head_pose: XrPose = openxr_pose.into;
let hit_dist = raymarch_sphere;
if hit_dist > 0.0
AliceSDFVisionOS — Apple Vision Pro SwiftPM Package (mobile/swift-package-visionos/)
A visionOS / RealityKit-flavoured Swift Package that wraps the same AliceSDF.xcframework used by the iOS / iPadOS / macOS targets and adds factory helpers for ModelEntity.
import SwiftUI
import RealityKit
import AliceSDFVisionOS
struct ImmersiveView: View {
var body: some View {
RealityView { content in
let sphere = AliceSDFRealityKit.makeSphereEntity(radius: 0.1)
sphere.position = SIMD3(0, 1.5, -1.0)
content.add(sphere)
}
}
}
REST API Server (server/)
An axum + tokio HTTP server that exposes ALICE-SDF primitive evaluation and operations over JSON — intended as the backend for cloud-served SDF UIs (e.g. alicelaw.net/sdf-metaverse).
&&
# → ALICE-SDF server listening on http://0.0.0.0:8787
POST /eval
Content-Type: application/json
{ "shape": "sphere", "point": [1, 0, 0], "params": { "radius": 1.0, "center": [0, 0, 0] } }
Response: { "distance": 0.0 }
Related Projects
| Project | Description | Link |
|---|---|---|
| ALICE-View | Real-time GPU raymarching viewer for SDF files (wgpu + WGSL) | GitHub |
| Open Source SDF Assets | 991 free CC0 3D assets in .asdf.json format, converted via ALICE-SDF | GitHub |
| ALICE-LOL | Law-Oriented Language — lol! proc_macro DSL for declarative SDF scene authoring (76 constructs, GLSL/WGSL/HLSL transpile, law constraints, spatial pruning) |
GitHub |
| ALICE Ecosystem | 52-component edge-to-cloud data pipeline | GitHub |
| AI Modeler SaaS | Browser-based 3D modeling powered by ALICE-SDF | GitHub |
| ALICE SDF Metaverse | Live browser demo — WebGL2 raymarching world with JS-side CCD physics, runs ALICE-SDF concepts in the browser | Demo |
| alicelaw.net | Personal site source — Cloudflare Pages + Pages Functions QR router (/0x01-/0xFF), hosts the SDF Metaverse demo |
GitHub |
Copyright (c) 2025-2026 Moroya Sakamoto — https://alicelaw.net/