Skip to main content

Module ray_marching

Module ray_marching 

Source
Expand description

Ray marching and Signed Distance Field (SDF) rendering utilities.

Provides a CPU-side implementation of common ray marching primitives: SDFs for spheres, boxes, capsules, and tori; boolean CSG operators; smooth blending; ambient occlusion; soft shadows; and a simple renderer that produces depth and normal buffers.

Structs§

AmbientOcclusion
Ambient occlusion estimator using SDF step-based sampling.
BoxSdf
SDF for an axis-aligned box centred at the origin.
CapsuleSdf
SDF for a capsule (cylinder with hemispherical caps).
Ray
A ray defined by an origin point and a (normalized) direction vector.
RayMarchRenderer
A simple camera/renderer that generates rays and produces image buffers via ray marching.
RayMarchResult
Result of a single ray march step.
SoftShadow
Penumbra-aware soft shadow estimator.
SphereSdf
SDF for a sphere.
TorusSdf
SDF for a torus lying in the XZ plane, centred at the origin.

Traits§

Sdf
A Signed Distance Field: maps a 3-D point to the signed distance to the nearest surface (negative inside, positive outside).

Functions§

ray_march
Perform sphere-marching along ray against the provided SDF.
sdf_intersection
SDF intersection: take the maximum of two distances.
sdf_smooth_union
Polynomial smooth union of two SDF values with blend radius k.
sdf_subtraction
SDF subtraction: subtract shape B from shape A.
sdf_union
SDF union: take the minimum of two distances.
subsurface_scattering_approx
Approximate subsurface scattering transmittance.