Rendering & Simulation

Understanding the Pipeline

A complete technical breakdown of global illumination, physically-based materials, rigid body dynamics, and the Genesis rendering engine.

Contents

  1. Global Illumination & Path Tracing
  2. Physically-Based Materials
  3. Reflection: BRDF & Fresnel
  4. Refraction: Snell's Law
  5. Camera: DOF & Bokeh
  6. OIDN Denoising
  7. Rigid Body Simulation
  8. The Complete Pipeline
  9. Forge: Cinematography Engine
  10. World Model Integration

Section 1

Global Illumination & Path Tracing

Global illumination (GI) simulates how light bounces between surfaces, creating soft shadows, color bleeding, and realistic ambient lighting. Unlike rasterization (which only computes direct lighting), GI accounts for all light paths.

Global illumination example

The Rendering Equation

All physically-based rendering solves the same equation, formulated by James Kajiya in 1986:

Lo(x, ωo) = Le(x, ωo) + ∫Ω fr(x, ωi, ωo) Li(x, ωi) (ωi · n) dωi

In words: outgoing light = emitted light + integral of (BRDF × incoming light × cosine) over hemisphere.

Path Tracing

Genesis uses Monte Carlo path tracing to solve this integral stochastically:

// Simplified path tracing
for sample in 1..SPP:
    ray = camera.generate_ray(pixel)
    color = trace_path(ray, depth=12)
    
def trace_path(ray, depth):
    hit = scene.intersect(ray)
    if hit.material.is_emissive:
        return hit.emission
    
    wi = hit.material.sample(wo, normal)
    Li = trace_path(Ray(hit.point, wi), depth - 1)
    return brdf * Li * cos(theta) / pdf

SPP (Samples Per Pixel)

128 random paths traced per pixel, then averaged. More samples = less noise.

Bounce Depth

Each path bounces up to 12 times. More bounces capture indirect lighting.

Russian Roulette

After 4 bounces, paths are randomly terminated based on throughput. Unbiased.


Section 2

Physically-Based Materials

Every surface has a material defining how light interacts with it. Modern renderers use PBR—materials based on real physics, not arbitrary parameters.

Material Type Key Parameters Used For
Metal Conductor color, roughness Gold sphere, obsidian floor
Glass Dielectric color, IOR Crystal dominoes, diamond orb
Default Diffuse/Glossy color, roughness Corridor walls
Emission Light source emissive RGB Neon bars, ceiling lights
Low roughness
Mixed materials

Section 3

Reflection: BRDF & Fresnel

The BRDF describes what fraction of incoming light reflects in each outgoing direction. For metals, most light reflects; for dielectrics, the Fresnel equations determine reflection vs. transmission.

Fresnel Equations

All materials reflect more light at grazing angles:

F(θ) = F0 + (1 - F0)(1 - cos θ)5
Fresnel in Action

Look at the obsidian floor. Near the camera (grazing angle), it's almost a perfect mirror. Directly below the lights (normal incidence), it's darker. That gradient is Fresnel.


Section 4

Refraction: Snell's Law

When light crosses a boundary (air → glass), it bends according to Snell's Law:

n1 sin(θ1) = n2 sin(θ2)
MaterialIORVisual Effect
Ice1.31Subtle distortion
Glass / Quartz1.54–1.55Moderate bending
Ruby1.77Strong bending
Diamond2.417Extreme brilliance
Refraction in dominoes

Section 5

Camera: DOF & Bokeh

Genesis simulates a thin-lens camera. Objects at the wrong distance appear blurry—just like a real camera.

Aperture (f-stop)

Lower f-stop = larger aperture = shallower DOF. The film uses f/2.0 for cinematic bokeh.

Focus Distance

Objects at this distance are sharp. The rack focus shot animates this from 1m to 9m.

Circle of Confusion

Out-of-focus points blur into discs. Diameter: d ∝ aperture × |z - focus| / z

Bokeh visible

Section 6

OIDN Denoising

Even at 128 SPP, Monte Carlo noise is visible. We use Intel Open Image Denoise (OIDN)—a neural network trained to remove path tracing noise while preserving detail.

# HDR denoising pipeline
rgb_float = camera.render()        # float32 [0, ∞)
rgb_float = clip(rgb_float, 0, 1)
rgb_clean = denoiser.denoise(rgb_float)  # OIDN Metal
rgb_uint8 = (rgb_clean * 255).astype(uint8)

Section 7

Rigid Body Simulation

The domino cascade isn't animated by hand—it's simulated. Genesis solves Newton's equations of motion at 60 Hz.

F = ma       τ = Iα
# Collision response
for (A, B) in find_collisions():
    v_rel = A.velocity - B.velocity
    impulse = -(1 + restitution) * dot(v_rel, normal) / 
              (1/A.mass + 1/B.mass)
    
    A.velocity += impulse * normal / A.mass
    B.velocity -= impulse * normal / B.mass
Physics simulation

Section 8

The Complete Pipeline

Click each stage to explore. Watch the data flow.

🎬

SCENE SETUP

INITIALIZATION · ONE-TIME
Define geometryBox, Sphere, Plane
Assign materialsMetal, Glass, Emission
Configure camerathinlens · f/2.0 · 35° FOV
Set physics optionsdt=1/60 · substeps=4

PHYSICS LOOP

60 HZ · PER-FRAME
Integrate velocities → positionsNewton's Laws
Detect collisionsSAT · GJK
Solve constraintsimpulse response
Generate collision audiomodal synthesis
🔮

RENDER LOOP

24 FPS · PATH TRACING
Update camera poseCinematographer
Path trace scene128 SPP · 12 bounces
Denoise HDR frameOIDN Metal
Tonemap & save PNGfloat32 → uint8
Record physics audioVBAP spatial
🎞️

POST-PROCESS

ASSEMBLY · FINAL OUTPUT
Assemble frames → videoFFmpeg · H.264
Mix spatial audioVBAP · AAC
Color grade & finalizeCRF 18
📽️
OUTPUT READY
1920×1080 · MP4 · 24fps · Spatial Audio

Section 9

Forge: The Cinematography Engine

Forge is Kagami's construction colony—the engine that abstracts camera movements into composable, named shot types.

from kairos.core.services.forge.modules.genesis.cinematography import (
    Cinematographer, Shot, Sequence,
)

sequence = Sequence(
    name="The Symmetry of Collapse",
    shots=[
        Cinematographer.create_one_point_perspective_shot(...),
        Cinematographer.create_rack_focus_shot(...),
        Cinematographer.create_dolly_zoom_shot(...),
        Cinematographer.create_steadicam_follow_shot(...),
        Cinematographer.create_arc_shot(...),
    ]
)
Shot TypeCamera MotionPsychological Effect
One-Point PerspectiveSlow dolly forwardInevitability, dread
Rack FocusStatic, focus shiftsRevelation, connection
Dolly ZoomDolly back + zoom inVertigo, realization
SteadicamSmooth pathImmersion, presence
Arc ShotOrbit around subjectPower, contemplation

Section 10

World Model Integration

How does this connect to Kagami's world model? Genesis provides the substrate for imagination—the world model can predict "what happens if I push this domino?" and Genesis makes that prediction visible.

The Loop Closes

The world model predicts. Genesis renders the prediction. The encoder compresses the render. The world model updates. This is the imagination loop—dreaming in physics, learning from synthetic experience.