Skip to content

Specification — Rendering Backends

Charter section: §11 Rendering Backends Status: Legacy implemented, Core/Compare stubbed Key source files: RenderBackends/LegacyBackend.cs, RenderBackends/CoreBackend.cs (stub), RenderBackends/CompareBackend.cs (stub)


1) Purpose

Rendering backends own the output production chain — the path from completed ray segment chains through intersection, shading, and film write. The backend abstraction allows multiple output strategies to coexist.


2) Backend Dispatch (Implemented)

public enum BackendMode { Legacy = 0, Core = 1, Compare = 2 }

GrinFilmCamera.RenderFrameBackend dispatches based on the BackendMode inspector property.


3) LegacyBackend (Implemented)

The only output-producing backend. Contains the full render pipeline:

LegacyBackend.RenderFrame()
  → GrinFilmCamera.RenderStep()
      Pass-1 (parallel):  Integration → RaySeg[] per pixel
      Pass-2 (sequential): Segment envelope → GeometryTLAS prune →
                           Godot narrowphase → SoftGate → Shade → Film write

Key characteristics: - Integration and intersection are fused in a single RenderStep - Pass-2 uses Godot DirectSpaceState (main thread only) - Film buffer is written sequentially per pixel - SoftGate subdivision for uncertain misses - Progressive row-band updates


4) CoreBackend (Stubbed)

Target: pure RendererCore pipeline using BLAS intersection. No Godot physics dependency. Would enable fully parallel Pass-2.

Currently a placeholder that prints a summary and returns without rendering.


5) CompareBackend (Stubbed)

Target: run both Legacy and Core backends and diff the results for validation.

Currently prints summary only.


6) Backend Contract

All backends receive: - SceneSnapshot (read-only for frame) - CurvatureBoundGrid - Camera parameters - Film buffer reference - Budget/config

All backends must: - Produce film pixel updates - Report telemetry compatible with PerfScope / PerfStats - Respect budget guards and cancellation


7) Film Buffer

The film is a byte[] or Color[] array sized to camera resolution. Backends write into it per-pixel or per-tile. GrinFilmCamera uploads the film to a Godot ImageTexture after each RenderStep.


8) Planned Evolution

  1. CoreBackend implementation (requires BLAS):
  2. All-parallel tile tasks
  3. Internal triangle intersection
  4. No Godot API calls during rendering
  5. Replaces LegacyBackend as default

  6. CompareBackend activation (requires CoreBackend):

  7. Per-pixel diff between Legacy and Core outputs
  8. Regression detection for BLAS migration
  9. Tolerance-based pass/fail reporting

  10. GPU backend (Phase 3):

  11. Compute shader BVH traversal
  12. Shared BLAS/TLAS structures between CPU and GPU paths
  13. Hybrid CPU integration + GPU intersection possible