npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

babylon-pathtracer

v0.1.0

Published

Progressive GPU path tracer (Cycles-style) as a Babylon.js plugin: scene-agnostic ingestion, first-hit AOVs, firefly clamping, GPU a-trous denoise, reproducible sampling and PNG export.

Readme

babylon-pathtracer

A Cycles-style progressive GPU path tracer for Babylon.js — scene-agnostic ingestion, first-hit AOVs, firefly clamping, GPU a-trous denoise, reproducible sampling and PNG export.

Build a scene the normal Babylon way (MeshBuilder, PBRMaterial, lights, glTF, scene.environmentTexture), hand it to the library, and it path-traces it on the GPU with progressive sample accumulation.

Usage guide and settings reference: USAGE.md.


Requirements

  • Node ≥ 18 — only for the local demo server and the build. There is nothing to npm install to build, test, or run the demo.
  • A browser with WebGL2 and float render targets (WebGL1 is not supported).
  • Internet access for the demo — it loads Babylon from a CDN.

Start here

1. Run the demo

Serve the repo root over HTTP, then open the demo page:

npx serve .                    # or: python -m http.server 3000

Open http://localhost:3000/exmaples/test.html.

You get a procedural scene (ground, a row of spheres, coloured lights) with a live control panel: view modes, AOVs, a-trous denoise, firefly clamp, seed, material edits, light toggles, post-process and PNG export. The tracer's one asset — the blue-noise texture — is read from textures/.

Serve over HTTP, not file://. On file:// the texture fetch fails and the geometry Web Worker is blocked.

2. Build and test

npm run build     # -> dist/pt_lib.core.js, dist/pt_lib.esm.js, dist/pt_lib.iife.js
npm test          # seven headless suites (Babylon is mocked)

Two things worth knowing:

  • It is npm run build, not npm build. build is a script in package.json; npm only maps a handful of names (test, start, …) to bare commands. npm run on its own lists every available script.
  • dist/ is committed on purpose, so <script> / CDN users get a working bundle. Rebuild after editing anything in src/ and commit the regenerated dist/ in the same commit.

Use it in your project

The package is not on the npm registry yet. Until the first publish, consume it one of three ways:

a) A file: dependency (best while developing against it)

npm install @babylonjs/core
npm install /path/to/babylon-pathtracer

b) A packed tarball

npm pack                       # in this repo -> babylon-pathtracer-0.1.0.tgz
npm install /path/to/babylon-pathtracer-0.1.0.tgz

c) The IIFE bundle, no install at all — see Script tag below.

@babylonjs/core is a peer dependency. The package is ESM-only (there is no CommonJS build); use the IIFE bundle for classic <script> usage.

ESM

import { PT_LIB } from "babylon-pathtracer";

const app = PT_LIB.scenes.universal.create(canvas, {
  resolutionScale: 1.0,
  maxSamples: 256,
  fireflyClamp: 8,          // 0 = off
  setup: async (scene, camera) => {
    const ball = BABYLON.MeshBuilder.CreateSphere("ball", { diameter: 2 }, scene);
    ball.material = new BABYLON.PBRMaterial("m", scene);
    new BABYLON.PointLight("key", new BABYLON.Vector3(3, 6, -3), scene);
  }
});

// optional: GPU denoise (ships with the library)
app.pathTracer.setDenoise(PT_LIB.denoise.aTrous({ iterations: 3 }));

// optional: reproducibility + a still
app.pathTracer.setSeed(7);
await app.pathTracer.exportImage({ download: true, aovs: true });

The library also attaches to the global as PT_LIB (and BABYLON.PathTracer), which is why the snippet above can keep using BABYLON.*. Prefer explicit imports? The ESM entry also re-exports PathTracer, scenes, denoise, glsl, ingestScene and buildScenePrelude.

Script tag (IIFE)

The IIFE bundle contains everything — GLSL, the BVH, ingestion, both denoisers and the inlined worker sources — so it is the only library script you need:

<script src="https://cdn.babylonjs.com/babylon.max.js"></script>
<script src="dist/pt_lib.iife.js"></script>
<script>
  const app = PT_LIB.scenes.universal.create(canvas, { /* ... */ });
</script>

It needs a global BABYLON (load Babylon first) and exposes window.PT_LIB.


What you get

| | | |---|---| | Ingestion | Ordinary Babylon meshes / PBRMaterial / StandardMaterial / lights / environmentTexture — no hardcoded scene content. A Web Worker does the packing + BVH build by default. | | Render | Progressive accumulation, imageProcessingConfiguration tonemap, a post-process chain after the tonemap. | | Quality | Specular NEE, IBL, fireflyClamp, reproducible seed. | | Denoise | PT_LIB.denoise.aTrous() — a GPU edge-aware filter over the AOVs, zero readback, live-tunable. | | Output | exportImage() → PNG of beauty ± the albedo / normal / depth AOVs. |

Denoise

// GPU a-trous: works immediately, live-tunable
const atrous = PT_LIB.denoise.aTrous({ iterations: 3, phiNormal: 128 });
pt.setDenoise(atrous);
atrous.setParams({ iterations: 4, phiDepth: 8 });

Repository layout

dist/       prebuilt bundles (committed): esm, iife, core, hand-written .d.ts
src/        the library source (PathTracer, core ingestion/BVH/GLSL, denoise, scenes)
tools/      build + headless test scripts (plain Node)
exmaples/   the runnable demo (test.html + GUI.js + demo.css)
textures/   the demo's assets — blue-noise texture, HDR environment, test.glb

Credits

Based on the Three.js Path Tracing Renderer by Erich (@erichlof), ported to Babylon.js by @PichouPichou. See CREDITS.md.

Licensing

CC0-1.0 — see LICENSE and CREDITS.md. The library is a port of an existing Babylon.js path tracer; upstream is CC0 with Shadertoy-derived snippets credited in CREDITS.md.