AssetBash Docs Sign in
Lunaris USD + path tracing in TouchDesigner

Path tracer

One camera ray per pixel per frame, traced with Vulkan ray queries inside a GLSL POP. Frames accumulate while nothing changes; the OptiX denoiser cleans what is left.

The network

InputOperatorCarries
0grid_raysOne point per pixel (Tex = pixel uv).
1stage_pop (Lunaris Stage POP, Output = Geometry)World-space triangles, 3 unshared corners each: P, N, T, Tex, Color, Mat, Emission, MatIdx, LightId. It is also the acceleration structure.
2lights_pop (Output = Lights)One point per UsdLux light: Lpos, Lrad, Lu, Lv, Ln, Lgain.
3mats_pop (Output = Materials)One point per material: MatA..MatG (see below).
4prog_pop (Output = Program)One point per MaterialX program instruction: Op, K (see MaterialX).

The four POPs load plugins/LunarisStagePop.dll. With 0 lights, materials or program instructions the POP still emits one neutral row, because a GLSL POP input with no points declares zero-size arrays and the shader fails to compile.

Material table

Constants travel per corner (Color, Mat, Emission). Textures and extra lobes travel per material, LUNARIS_MAT_FLOATS = 28 floats, seven vec4 rows:

RowContents
ATexture index of base colour, roughness, metallic, normal (−1 = none)
BEmission texture; roughness and metallic channels; flags (sRGB bits, opacity channel)
CNormal-map scale and bias; uv scale
Duv offset; opacity texture index + 1; opacity threshold (> 0 = cut-out)
ESpecular weight, specular colour (MaterialX; 1,1,1,1 for UsdPreviewSurface)
Fx: constant-coverage flag (MaterialX opacity < 1 is coverage, not glass)
GMaterialX program start and length (0 = none)

Shading

  • BSDF: Lambert diffuse + GGX specular (VNDF sampling), metal/dielectric mix. Ported from NVIDIA nvpro_core2 nvshaders (Apache-2.0).
  • Glass: rough dielectric after Walter et al. 2007, with tinted glass shadows.
  • Textures: a 2D texture array of mip atlases; level chosen by ray cones (Ray Tracing Gems ch. 20).
  • Opacity: cut-out (alpha test against the threshold) or coverage (the ray passes with probability 1 − opacity).

Lights and the dome

  • UsdLux distant (with angle), sphere, rect, disk, cylinder; ShapingAPI cones with softness and focus.
  • Light shapes are also triangles in the scene, so BSDF rays that hit them pick up their radiance (multiple importance sampling against direct light sampling). Camera and shadow rays pass through them.
  • Dome: an HDRI in the dome's frame, using Storm's lat-long convention, with importance sampling. A dome with no texture is a constant colour (uOpts.y = 2) found by BSDF rays only.

Accumulation and denoising

  • Each frame adds one sample to a running mean with reprojection (shaders/lunaris_accum.glsl). History is kept while a pixel shows the same surface (normal within ~25°, depth within 5%).
  • While the camera moves, history is capped at Samples While Moving (2); when it stops, at Max Samples (1024).
  • Partial coverage: the camera ray records the nearest surface it passed at random with coverage of at least 0.5, and that surface is used for the history test and the denoiser guides (11/19 fix: before it, half the frames discarded their history). Clearer surfaces leave the background as the pixel's identity.
  • OptiX denoiser (Temporal model) reads colour, albedo, normal and motion.

Camera

The tracer follows the Storm TOP's camera mode: the Look Dev TD camera, or a USD camera prim (Cameramode = Usdcamera, Camerapath; blank = the first camera), conformed like Storm's CameraUtilFit.