Chat Analysis — Godot NVPathtracer Discussion

  • Notes extracted from the actual Godot Contributors NVPathtracer chat discussion.
  • Parent: PathTracer Learning

Key Contributors and Context

  • This was a technical discussion among Godot engine contributors
  • Topic: integrating NVIDIA’s path tracer (NVPathtracer) into Godot 4
  • Challenges discussed: engine integration, performance, API design

Technical Insights from the Chat

  • TLAS rebuild strategy
    • Contributors debated full rebuild vs incremental update every frame
    • Full rebuild: simpler, always correct BVH quality
    • Incremental update: faster but BVH quality degrades over time
    • Decision: full rebuild for correctness, optimize later
  • Material system design
    • How to pass PBR material data (albedo, roughness, metallic, textures) to RT shaders
    • Solution: per-instance data buffer indexed by gl_InstanceCustomIndexEXT
    • Each instance stores: vertex buffer address, index buffer address, material index
    • Material buffer stores: albedo, roughness, metallic, texture indices
  • Denoising approach
    • Initial: simple temporal accumulation (free, no extra cost)
    • Target: DLSS 3.5 Ray Reconstruction for final quality
    • Intermediate: OIDN for platforms without DLSS
  • Skinned mesh handling
    • Skinned meshes need BLAS rebuild every frame
    • Use ALLOW_UPDATE flag for incremental BLAS update
    • Separate “dynamic” and “static” BLAS pools
  • Async compute for BLAS builds

Architecture Decisions

  • Engine fork vs GDExtension
    • NVPathtracer is an engine fork — modifies core rendering code
    • GDExtension cannot access RenderingDevice internals
    • Future goal: expose RT hooks via GDExtension API
  • Integration point
    • Override _render_scene() in RendererSceneRenderRD
    • Skip rasterization entirely for path-traced frames
    • Keep shadow maps for hybrid rendering (raster + RT)
  • Buffer management
    • Reuse Godot’s existing depth/normal/motion buffers
    • Add new accumulation buffer and albedo buffer for denoiser
    • Use RenderSceneBuffersRD to manage lifetime

Open Questions from the Chat

  • How to handle transparent objects (glass, water)?
    • RT handles refraction naturally — just trace through
    • Need to disable alpha blending for RT objects
  • LOD (Level of Detail) with RT?
    • RT doesn’t use rasterization LOD system
    • Need separate LOD selection for BLAS geometry
  • Emissive materials as light sources?
    • NEE needs to know which instances are emissive
    • Build a light list from emissive instances for NEE sampling

Lessons Learned

  • Start simple: temporal accumulation before DLSS
  • Get correctness first: full TLAS rebuild before optimization
  • Test with Cornell box: known ground truth for validation
  • Profile early: GPU timing for each pass (BLAS, TLAS, RT, denoise)