DenrimRendererKit is a MoonRay-inspired Swift Package for high-quality Metal path tracing on Apple platforms. It is built for Denrim products, but the repository is kept useful as a standalone renderer: you can load scripted scenes, render material previews, benchmark backends, and use the Swift API directly from an app or tool.
The renderer and material system are shaped by MoonRay-style production rendering ideas: physically based layered materials, predictable scriptable scenes, useful diagnostics, and a path toward a polished Apple-native offline/preview renderer. DenrimRendererKit is not a MoonRay port or shader-compatible implementation; it uses MoonRay as a quality and material-design reference.
- Progressive Metal path tracer with flat BVH fallback and Metal ray tracing traversal on supported devices.
denrimCLI for rendering.denrimSceneScript files and built-in material previews.- SceneScript with script-relative assets, includes, mesh instances, render defaults, and readable grouped arguments.
- OBJ and PLY mesh loading with preserved normals and UVs.
- ImageIO texture loading with explicit sRGB/linear handling, checker/solid/generated textures, and tangent-space normal maps.
- Direct emissive-triangle lighting, HDRI environment sampling, and benchmark timing reports.
- Rough dielectric, metal, clearcoat, thin-film, sheen/fuzz, transmission, absorption, volume scattering, and random-walk subsurface controls.
- Built-in material preset catalog with generated preview thumbnails.
- Beauty, depth, normal, albedo, material ID, object ID, and motion-vector outputs.
- Unit, parser, backend parity, AOV, and render smoke tests.
The DiningRoom scene lives at Examples/SceneScripts/Quality/DiningRoom/dining-room.denrim. It carries render defaults in the script itself:
render output ../../../Renders/DiningRoom.png size hd spp 512 quality final backend automatic
Run it with:
swift run -c release denrim -- Examples/SceneScripts/Quality/DiningRoom/dining-room.denrimFor a quick smoke render, override the script defaults:
swift run denrim -- Examples/SceneScripts/Quality/DiningRoom/dining-room.denrim \
--output /tmp/denrim-dining-room.png \
--width 320 \
--height 180 \
--samples 1 \
--quality interactiveBuilt-in materials are exposed through BuiltInMaterialLibrary and SceneScript's material name preset preset-id form. The thumbnails below are generated with Examples/Tools/render-built-in-materials.sh.
Render a material preview directly:
swift run denrim -- material matte.clay --samples 64 --quality interactive
swift run denrim -- material liquid.milk --samples 1024 --quality finalRefresh the material gallery:
./Examples/Tools/render-built-in-materials.shimport DenrimRendererKit
let renderer = try DenrimRenderer()
let scene = RenderScene.cornellBox()
let session = try renderer.makeSession(
scene: scene,
settings: RenderSettings(width: 512, height: 512, maxBounces: 4)
)
try session.render(samples: 64, to: outputURL)Use built-in material presets from Swift:
let material = BuiltInMaterialLibrary.material(named: "metal.brushed-aluminum")
let previews = BuiltInMaterialLibrary.previewsLoad a scripted scene:
let sceneURL = URL(fileURLWithPath: "Examples/SceneScripts/Quality/DiningRoom/dining-room.denrim")
let scene = try SceneScript.parse(contentsOf: sceneURL)
let defaults = scene.renderDefaultsdenrim renders .denrim SceneScript files, resolves relative assets beside the script, writes PNG output, prints progress during normal renders, and prints benchmark timings at the end. Scripts can carry render defaults; explicit CLI flags override them.
swift run denrim -- Examples/SceneScripts/Quality/DiningRoom/dining-room.denrim
swift run denrim help render
swift run denrim help materialUseful render options:
swift run denrim -- Examples/SceneScripts/MaterialVariants/glossy-metal-reference.denrim \
--output /tmp/glossy.png \
--samples 64 \
--quality interactive \
--backend automaticUse --output-type depth|normal|albedo|material-id|object-id|motion-vector to export AOVs, --denoise apple-svgf or --denoise simple for denoiser comparisons, --backend flat-bvh|metal-ray-tracing for backend measurements, and --report-output report.json or --json for benchmark JSON. --json suppresses progress output so stdout stays parseable.
swift testPerformance benchmarks are intentionally separate from normal tests:
DENRIM_RUN_PERFORMANCE_TESTS=1 swift test --filter PerformanceBenchmarkTestsDenrimRendererKit is released under the Apache License 2.0.




























