Giter Site home page Giter Site logo

rassaifred / dspbr-pt Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dassaultsystemes-technology/dspbr-pt

0.0 1.0 0.0 4.79 MB

A WebGL2 Enterprise PBR sample renderer

License: Apache License 2.0

JavaScript 11.92% GLSL 40.49% Python 1.07% HTML 0.57% CSS 1.87% TypeScript 44.08%

dspbr-pt's Introduction

Enterprise PBR Sample Renderer (Demo | Validation Report)

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

Overview

Caveats

The renderer serves as a fancy wrapper for the Enterprise PBR Shading Model code sample, performance is not a priority. Some major limiting factors are

  • Naive single-level BVH acceleration structure which is slow and prohibits dynamic scenes.
  • Plain WebGL2 for accessibility reasons. Implied API limits and required overhead in shader complexity to make "arbitrary" scenes with texturable PBR materials work for path-tracing is insane and a major performance drag.
  • No light importance sampling. Expect a significant amount of slow-converging noise for high frequency lighting scenarios and rough materials.

Demo App

Drag & Drop glTF files to render your scenes.

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.

Notes

  • For performance reasons, the default bounce depth is set to 4. The result is therefore biased. For scenes with a complex transmission/reflection setup or major indirect light contribution, the bounce depth needs to be increased. ⚠️ You only want to play with this setting on a beefy GPU, otherwise a timeout is not unlikely. There's a "force IBL eval" flag which forces the integrator to evaluate IBL lighting at the end of a path without shadow test. This brings light into dark spot which would only receive light via multiple indirections otherwise.
  • Pixel-ratio is set to 0.5 by default, which sets the render resolution to half the size of the provided canvas. If you can afford it, set it to 1.0 for a beautiful, crispy, pixel-perfect eye-candy sensation.

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

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

dspbr-pt's People

Contributors

bsdorra avatar proog128 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.