Skip to content

bsdorra/dspbr-pt

 
 

Repository files navigation

Enterprise PBR Sample Renderer (Demo | Validation Report)

A WebGL path-tracer implementing the Enterprise PBR Shading Model (DSPBR).

Supports the glTF file format with several PBR Next extensions and wip extension proposals (marked as PR below).

The renderer implements the listed extensions in terms of the Enterprise PBR specification. If you're interested in equations head over to the spec repo and check the latest specification document. If you're looking for code, dspbr.glsl should give you most of the relevant pieces.

NOTE
The demo app uses the three.js WebGLRenderer as fallback when path-tracing is disabled. Please check the three.js documentation for information on supported material extensions.

Quickstart

# Installs all dependencies necessary to run and develop the renderer and viewer app
npm install --production

# Alternatively, if you intent to run the validation or CLI rendering (see below) omit the --production flag
# This will additionally install electron (~200MB)
npm install 

# Launch the viewer in a browser with attached file watcher for auto refresh on file edits
npm run dev
# Builds a distributable package of the viewer to ./dist
npm run build

Load glTF assets and HDR IBLs via drag & drop

Validation

The Enterprise PBR Specification repository provides a Validation Suite. The suite is a collection of lightweight test scenes accompanied by HDR reference renderings (generated by the Dassault Systèmes Stellar renderer). It further provides scripts to compare the output of a custom render engine to the provided grund-truth images. The suite generates an overview of the comparison result as HTML report. The report for the current state of dspbr-pt can be found here

In case you start to toy with the shaders you might want to run the validation regularly. It'll give you a good overview on which materials features were messed up by your changes ;)

# Clones the Enterprise PBR repo to the current working dir, runs the validation renderings and generates a report at ./validation/report/index.html
npm run validation

The validation scripts use the CLI rendering functionality as explained below. Validation render settings need to be adjusted directly in the run_validation.py script render call for now.

# line 38
 render_call = ['npm', 'run', 'render', '--', '--', "../"+ file, '--res', '400', '400', '--samples', '512', '-b', '32', '--ibl-rotation', '180'];

CLI Renderer

Command-line rendering is available via headless electron

# Builds the cli renderer to ./dist
npm run build-headless 

# Renders an image via command-line
npm run render -- -- <scene_path> --ibl <hdr_path> --res <width> <height> --samples <num_samples>
# Example
# Writes output image to ./output.png
npm run render -- -- "./assets/scenes/metal-roughness-0.05.gltf" --ibl "./assets/env/Footprint_Court_Env.hdr" -r 512 512 -s 32 

Renderer API Usage

import { PathtracingRenderer, PerspectiveCamera } from './lib/renderer';
import { Loader } from './lib/scene_loader';

let renderer = new PathtracingRenderer(canvas);
let camera = new PerspectiveCamera(45, canvas.width/canvas.height, 0.01, 1000);

const normalizeSceneDimension = true; 
const scenePromise = Loader.loadScene(scene_url, normalizeSceneDimension);
const iblPromise = Loader.loadIBL(ibl_url);

Promise.all([scenePromise, iblPromise]).then(([gltf, ibl]) => {
  renderer.setIBL(ibl);
  renderer.setScene(gltf).then(() => {
    renderer.render(camera, -1, (frame) => {
      controls.update();
      console.log("Finished frame number:", frame);
    })
  });
});

Please check src/app.ts and lib/renderer.ts for more details.

License

  • Source code license info in LICENSE
  • Provided assets are due to their own licenses. Detailed per-asset license information can be found in the asset index file

About

A WebGL2 Enterprise PBR sample renderer

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 44.3%
  • GLSL 40.2%
  • JavaScript 11.9%
  • CSS 1.9%
  • Python 1.1%
  • HTML 0.6%