RuntimeCSG

RuntimeCSG

Non-destructive CSG brush modeling for Unity. Build geometry with boolean operations in real-time.

RuntimeCSG editor demo - real-time face hover and selection

Real-time face hover, operation-colored wireframes, and click-to-select in the Unity editor.

3Boolean Ops
5Primitives
143Unit Tests
2021.3+Unity

Three Operations, Infinite Shapes

Combine simple brushes into complex geometry with real-time boolean operations.

Union

A + B

Merge brushes together. Add geometry to build up your scene.

Subtract

A − B

Carve and cut. Remove geometry to create holes, doorways, windows.

Intersect

A ∩ B

Keep only the overlap. Create complex shapes from simple primitives.

Built for the Unity Editor

Scene overlay toolbar, keyboard shortcuts, and visual feedback so you never leave the viewport.

  • Mode toggle between Add and Subtract
  • One-key brush creation (Shift+B/W/C/S)
  • Per-brush wireframe overlays with operation coloring
  • Face drag handles for direct manipulation
  • Inspector buttons for shape and operation changes
RuntimeCSG editor with wireframe overlays and toolbar

Features

Per-Brush CSG Engine

Chisel-style algorithm processes each brush independently. Fragments are split and evaluated against the full boolean chain.

Chunk System

World-space grid chunking with dirty tracking. Only affected chunks rebuild. Time-sliced across frames for smooth performance.

Runtime Ready

Not editor-only. Generate and modify CSG geometry at runtime for procedural levels and player-built worlds.

Double Precision Math

Plane math uses doubles internally. No precision collapse at world-scale distances. Float only at mesh output.

Coplanar Handling

Later-brush-wins tiebreaker prevents z-fighting. No duplicate surfaces or flickering between overlapping faces.

Auto Colliders

Each chunk generates a MeshCollider automatically. Physics-ready geometry with zero extra setup.

Undo Support

Full Unity Undo integration. Every brush add, shape change, and face drag is undoable.

UPM Package

Install from git URL via Package Manager. Clean runtime/editor assembly split. No dependencies.

MIT Licensed

Fully open source. Use in commercial projects, modify, redistribute. No attribution required.

Brush Primitives

Start with built-in shapes. Combine them to build anything.

Box Wedge Cylinder Arch Sphere

How It Works

Chisel-style per-brush CSG in four steps.

Split

Each brush's polygons are split against planes of all overlapping brushes, creating convex fragments.

Categorize

Each fragment is classified as inside, outside, or coplanar relative to every other brush.

Evaluate

The boolean chain is evaluated for both sides of each fragment to determine visibility.

Build Mesh

Visible fragments are clipped to chunk bounds and built into Unity meshes with colliders.

Quick Start

CSG at runtime in a few lines.

// Create a model, add brushes, rebuild var model = new GameObject("Level").AddComponent<CSGModel>(); var floor = CreateBrush(model, BrushFactory.Box(new Vector3(10, 0.1f, 10))); var wall = CreateBrush(model, BrushFactory.Box(new Vector3(0.1f, 3, 10))); var door = CreateBrush(model, BrushFactory.Box(new Vector3(0.5f, 2, 1))); door.Operation = CSGOperation.Subtractive; model.RebuildAll();

Editor Shortcuts

TabToggle Add / Subtract mode
Shift+BAdd box brush
Shift+WAdd wedge brush
Shift+CAdd cylinder brush
Shift+SAdd sphere brush

Install

Git URL

https://github.com/TrentSterling/runtimecsg.git

Window > Package Manager > + > Add package from git URL

manifest.json

"com.runtimecsg.core":
"https://github.com/TrentSterling/runtimecsg.git"

Add to your Packages/manifest.json and Unity will import automatically.