Skip to content

WebGPU: Add AO map and lightmap baking - #937

Draft
gkjohnson wants to merge 1 commit into
mainfrom
webgpu/aomap
Draft

gkjohnson wants to merge 1 commit into
mainfrom
webgpu/aomap

Conversation

@gkjohnson

@gkjohnson gkjohnson commented Nov 5, 2026 •

Copy link
Copy Markdown
Owner

Adds AO map and lightmap baking to the WebGPU path tracer, with a demo for each.

Strategies

  • UV space camera: UVMapCamera rasterizes the atlas' triangle ids once, then each pixel's ray starts at its texel's surface. Samples are jittered within the texel and retried inside the triangle, as Cycles does.
  • Shading models: AOMapShadingModel turns the first hit's distance into occlusion. LightmapShadingModel treats the texel as white diffuse so the path gathers its irradiance.
  • Post process: gutters are filled, then the map is denoised with OIDN and stitched across chart seams with a port of Zalo's LightMapSeams.
  • Unwrapping: UVUnwrapper packs every mesh into one atlas with xatlas (via watlas).

Future improvements

Map Generation

  • Jitter the triangle id raster every frame, as three.js' LightMapper does, for smoother texels on triangle edges.
  • A faster and more complete mip chain gutter fill.
  • Bent normal, directional, specular occlusion, and indirect-only maps.
  • A radiance cache approach.
  • A port of the SVGF denoiser. Requires custom output variables in core.
  • Atlas improvements: multiple pages, instances, per-mesh texel density.
  • Use upstream three.js copies of classes where possible.

Core

  • variance detection, stop pixels once their noise is low, rather than at a fixed sample count.
  • emissive triangle sampling.
  • path termination hooks, for radiance caches.
  • more pluggable post-processing steps: gutter fill, stitching, denoising.

Before Merge

  • Clean up "getObjectInfo"
  • Upstream necessary changes / generators as much as possible to three.js
  • Include support for SVGF / custom AoVs? Can be included in the shading model class?
  • Path to radiance cache?

Videos

AO Map Gen Light Map Gen
Live demo link link
25spp, 20482 map generation video
aomap.mp4
lightmap.mp4

@gkjohnson
gkjohnson marked this pull request as draft November 5, 2026 05:23
Flattened from webgpu/aomap-prototype.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant