Pix Phys
Introduction
A physics-driven Cellular Automata engine that integrates traditional CA rules with physical for realistic pixel-level material interactions. PCG for world generation with chunk-based management for large-scale (millions pixel) real-time simulation.
Platform:
Engine:
Duration:
Role:
PC
Custom Engine
2025.9 - Now
Sole Developer
Highlight Features
-
Hybrid CA + Newtonian physics model — every cell carries velocity and responds to forces
-
Behavior primitive system for pure CA cells — new materials composable without touching simulation code
-
Chemical reaction system supporting flammability, life decay, and material transformation
-
Per-cell sleep/wake optimization enabling large-scale real-time simulation
-
Lock-free multi-threaded chunk updates via checkerboard coloring
-
Procedural world generation at per-pixel granularity using Wang Tiles
-
Box2D rigid bodies generated and synchronized directly from cell data
-
Single draw call MRT rendering with GPU-side collision texture for particle interaction
-
Fully GPU-resident vfx particle lifecycle with no per-frame CPU readback
Motivation
Noita demonstrated that building an entire game world out of individually simulated pixels — each governed by its own rules — could produce remarkably vivid and emergent physical behavior.
This project pursues an independent implementation of that vision: a pixel-level simulation where each Cell combines Cellular Automata state transitions with continuous physical quantities such as velocity and acceleration. This design allows different materials to exhibit emergent CA characteristics at the macro level while expressing richer dynamic differences at the micro level — the piling of sand, the inertial flow of liquids, and the bouncing of moving solids all become more nuanced as a result.
Beyond the core cell simulation, the project also integrates a multi-threaded chunk system, a hybrid rigid body layer, a procedural map generation system, and a GPU-based VFX particle system — together forming a complete and independently developed simulation engine.
System Overview
Cell and Material System
Each Cell exists as a lightweight data structure carrying material type, continuous physical quantities (velocity, accumulated displacement), state flags (free-falling, frames without movement), and chemical attributes (life countdown, flame countdown). All material behavior is driven entirely by CellMatDef parameters, achieving a clean separation between data and logic — adding a new material requires no changes to any simulation code.

CA Physics: Hybrid Cellular Automata + Newtonian Model
The first version was pure CA — sand fell by rules, water spread by rules. It worked, but something always felt off. Pouring sand from a height, it settled into a pile without impact, without inertia, as if someone had gently placed it down.
The problem was clear: CA has no concept of velocity. It has no way of knowing whether a grain of sand fell from one cell above, or came crashing down from twenty.
Solving this meant introducing real physical quantities — velocity, acceleration, momentum. But running Newtonian integration directly in a grid world creates a new problem: fast-moving particles can travel several cells in a single frame, skipping every collision in between.
The solution was to merge both systems together.

Every frame, movement is split into two phases.
The first phase uses Bresenham's line algorithm to translate the frame's velocity integral into a discrete grid path, checking collisions cell by cell along the way. This ensures that fast-moving particles never tunnel through obstacles, and every collision is correctly resolved.

The second phase uses CA rules to handle any remaining movement budget. Falling, diagonal sliding, horizontal spreading — these short-range behaviors are more stable and feel more natural when driven by rules than by velocity integration.
The two phases have distinct responsibilities: Bresenham handles physical correctness, CA handles natural behavior.
One of the design goals for this system was that adding a new material should feel like filling out a data sheet, not writing new physics code. Every material is defined by a flat set of scalar parameters, each with a clear physical meaning and a normalized 0–1 range where possible.
The goal was never physical accuracy — it was believability and creative freedom. Rather than simulating real fluid dynamics or rigid body mechanics, the system fakes it: a handful of tunable numbers nudge particles into behaviors that feel right without needing to be right.
More flexible and diverse results are obtained with this approach:
Pure CA Behavior System
A set of behavior primitives for pure CA particles, fully decoupling CA logic from the physics simulation pipeline. New materials with distinct emergent behaviors can be composed by combining primitives and registered without touching any underlying simulation code, enabling rapid iteration and experimentation.
Multi-threaded Chunk Management
The world is divided into fixed-size Chunks, each maintaining a dirty flag to skip updates on stationary regions. A checkerboard coloring scheme groups Chunks such that same-color Chunks share no boundary interactions, allowing them to be safely updated concurrently across multiple threads without any locking.
Checkerboard Chunk Update Scheduling
The world is divided into fixed-size Chunks assigned to one of four groups in a checkerboard pattern. Each frame, the four groups are updated sequentially — but all chunks within the same group are processed concurrently across worker threads.
The key guarantee: a cell's maximum movement range covers its own chunk plus approximately half of each neighboring chunk. Since same-group chunks are never adjacent, this movement range can never reach another chunk belonging to the same group — eliminating write conflicts without any locking.
Cell and Chunk Activation
Chunk Activity Visualization —
Cell Sleep/Wake and chunk activation
Super Chunk dynamically activation
Procedural Map Generation: Three-Layer Pipeline
A three-layer generation pipeline (Region → SuperChunk → Chunk) constructs the map at per-pixel granularity from a world seed. Wang Tiles ensure visual continuity across region boundaries, while each pixel's material type is determined by a combination of noise functions and region rules. At runtime, SuperChunks are dynamically activated and deactivated based on player proximity rather than streamed in on demand.
Seed-driven layout variation using Herringbone-constrained map templates





Per-pixel cell population via template:
-
Bilinear interpolation
-
Noise overlay
-
Match cell type and sample texture from region definition based on interpolated + noise result
-
Stamp decorative stickers in designated areas driven by noise



Hybrid Rigid Body Integration
Starting from raw Cell data, a pipeline of Marching Squares contour extraction, Douglas-Peucker simplification, and CDT triangulation produces valid Box2D polygon shapes. Static rigid bodies are generated from static cells; dynamic rigid bodies rebuild their shapes when constituent cells change, and synchronize the Box2D transform back to the Cell grid every frame via a local-to-world coordinate mapping.
Generation Pipeline
Three-Stage Pipeline
Stage 1: Marching Squares (Contour extraction)
-
Scan chunk grid to detect solid/empty boundaries
-
Output: Raw polygon with many vertices
Stage 2: Douglas-Peucker (Simplification)
-
Recursively remove vertices below tolerance threshold
-
Reduce vertex count while preserving shape
Stage 3: Triangulation (Mesh generation)
-
Convert simplified polygon into triangle mesh
-
Required for Box2D physics engine integration
-
Methods: Ear Clipping/ Delaunay

Dynamic rigid bodies generation
Asynchronous Terrain Physics Rebuild System
Terrain static rigidbody dynamically update.
Designed an asynchronous terrain physics rebuild system: offloaded expensive per-chunk computations — connected component detection, outline extraction, and CDT triangulation — to worker threads, keeping the main thread exclusively responsible for Box2D API calls. Combined with an object pool for rigid body reuse, this eliminates frame spikes caused by frequent terrain rebuilds.
Cell Rendering Pipeline & MRT Post-Processing
Each frame, the CPU collects active Cell data in parallel across Chunks and writes it into a StructuredBuffer, which the GPU reads directly to populate vertex data. A single Draw Call outputs simultaneously to three render targets: base color, bloom mask, and a collision texture. In the collision texture, each physical type is encoded as a distinct color, allowing the GPU particle system to perform per-particle collision detection and material interaction queries entirely within the shader.

Bloom Texture

Base Color Texture

Collision Texture for VFX sytem

After Post Processing (Bloom and Tonemapping)

