3D engine that AI agents drive
Merge pull request #630 from codepawl/feat/623-progressive-tracer
Nguyen Xuan An40f20023da89
diff --cc src/path-tracer-gpu.jsindex 54738d9f,12234761..d76706da--- a/src/path-tracer-gpu.js+++ b/src/path-tracer-gpu.js@@@ -191,23 -205,17 +205,25 @@@ export function getContext()return session;}+let kernelCompileCount = 0;++/** How many path tracing kernels (the light bake's texel kernel not counted) this page has compiled so far: a job of many frames compiles one, because every frame reuses the cached program. */+export function gpuKernelCompileCount() {+ return kernelCompileCount;+}+/** The kernel for a scene, compiled once per variant: a scene with a subsurface part gets the random walk, any other scene the plain kernel. */- function getKernel(hasSubsurface, texelBake = false) {+ export function getKernel(hasSubsurface, texelBake = false, options = {}) {const { gl, programs } = getContext();- const key = `${hasSubsurface}:${texelBake}`;+ const blueNoise = options.samplingPattern === 'blue-noise-first';+ const lightImportance = options.lightSelection === 'importance';+ const key = `${hasSubsurface}:${texelBake}:${blueNoise}:${lightImportance}`;if (!programs.has(key)) {const started = performance.now();- const program = createProgram(gl, { hasSubsurface, texelBake });+ const program = createProgram(gl, { hasSubsurface, texelBake, blueNoise, lightImportance });gl.getProgramParameter(program, gl.LINK_STATUS);programs.set(key, { program, compileSeconds: (performance.now() - started) / 1000 });+ if (!texelBake) kernelCompileCount++;}return programs.get(key);}