a Physically Based Renderer (PBR) in Go
Go Makefile
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
cmd/pbr material.Material -> material.Map, material.Sample; texture maps v1; … Jan 27, 2018
examples fixed double-bounding-box on spheres and cubes. added moses example. Jan 31, 2018
fixtures/models remove large models Jan 30, 2018
geom fixed double-bounding-box on spheres and cubes. added moses example. Jan 31, 2018
material fixed double-bounding-box on spheres and cubes. added moses example. Jan 31, 2018
obj fixed double-bounding-box on spheres and cubes. added moses example. Jan 31, 2018
rgb simplified material handling; updated lambo scene; added clear-coat i… Jan 24, 2018
surface fixed double-bounding-box on spheres and cubes. added moses example. Jan 31, 2018
.gitattributes remove large .obj and .mtl files Jan 15, 2018
.gitignore tested all examples Jan 30, 2018
Gopkg.lock update Gopkg.lock Jan 30, 2018
Gopkg.toml remove unused dependencies Jan 30, 2018
Makefile fixes #19 Jan 30, 2018
NOTES.md notes Jan 30, 2018
README.md replace huge sample models with a single smaller lucy model for faste… Jan 30, 2018
camera.go documentation, split sampler from renderer, improved cli and options,… Jan 22, 2018
doc.go simplified material handling; updated lambo scene; added clear-coat i… Jan 24, 2018
render.go simplified material handling; updated lambo scene; added clear-coat i… Jan 24, 2018
sampler.go fixed double-bounding-box on spheres and cubes. added moses example. Jan 31, 2018
scene.go fixed double-bounding-box on spheres and cubes. added moses example. Jan 31, 2018

README.md

pbr: a Physically-Based 3D Renderer in Go

Package pbr implements Physically-Based Rendering with a Monte Carlo path tracer. [ Documentation ] [ Github ]

Lambo Render

$ make fixtures
$ make lambo

This is an unbiased forward path-tracer written in Go and inspired by Disney's Hyperion video. It traces light rays from physically-based cameras to surfaces with realistic materials and simulates how the rays should bounce around the scene. It has a simple API for creating scenes in code and a CLI for rendering photorealistic images from the command line.

Try it

Install:

$ go get github.com/hunterloftis/pbr
$ cd $GOPATH/src/github.com/hunterloftis/pbr
$ dep ensure

Run:

$ cd $GOPATH/src/github.com/hunterloftis/pbr
$ go build ./cmd/pbr
$ ./pbr fixtures/models/lucy.obj -complete 8
$ open lucy.png

lucy

Features

Shapes & Transforms

shapes

$ make shapes

The renderer supports spheres, cubes, and triangles that can be moved, scaled, and rotated.

Image-based lighting

ibl

$ make fixtures
$ make ibl

The renderer can use high dynamic range (HDR) panoramic images as complex, omnidirectional light sources. This allows highly detailed real-world lighting to illuminate the scene's surfaces for greater realism and visual interest.

All the above images were rendered with an identical model and identical materials; the only difference between them is the image used for lighting.

Sampling & Branching

falcon adaptive falcon nonadaptive

$ make fixtures
$ make adaptive

Adaptive sampling devotes more time to sampling noisy areas than already-resolved ones. Branched tracing splits primary rays into multiple branches to better sample the most important (first) bounce of each path. Both of these techniques allow the renderer to spend its Ray-Scene intersection budget more effectively.

Both closeups of the Millennium Falcon were rendered in 10 minutes. The top image used naive sampling while the bottom used the default adaptive and branching settings.

Wavefront .obj files

Physically-based materials

Arbitrary light sources

Direct lighting

Thin surfaces

Physically-based cameras

Supersampled anti-aliasing

K-D Tree acceleration

Summary

API

See GoDoc

CLI

Usage: pbr SCENE [options]

Positional arguments:
  SCENE                  input scene .obj

Options:
  --verbose              verbose output with scene information
  --info, -i             output scene information and exit
  --complete COMPLETE, -c COMPLETE
                         number of samples-per-pixel at which to exit [default: +Inf]
  --time TIME, -t TIME   time to run before exiting (seconds) [default: +Inf]
  --out OUT, -o OUT      output render .png
  --heat HEAT            output heatmap as .png
  --noise NOISE          output noisemap as .png
  --profile              record performance into profile.pprof
  --width WIDTH          rendering width in pixels [default: 800]
  --height HEIGHT        rendering height in pixels [default: 450]
  --target TARGET        camera target point
  --focus FOCUS          camera focus point (if other than 'target')
  --dist DIST            camera distance from target
  --lat LAT              camera polar angle on target
  --lon LON              camera longitudinal angle on target
  --lens LENS            camera focal length in mm [default: 50]
  --fstop FSTOP          camera f-stop [default: 4]
  --expose EXPOSE        exposure multiplier [default: 1]
  --ambient AMBIENT      the ambient light color [default: &{600 600 600}]
  --env ENV, -e ENV      environment as a panoramic hdr radiosity map (.hdr file)
  --rad RAD              exposure of the hdr (radiosity) environment map [default: 100]
  --floor                create a floor underneath the scene
  --adapt ADAPT          adaptive sampling multiplier [default: 32]
  --bounce BOUNCE, -d BOUNCE
                         number of light bounces (depth) [default: 8]
  --direct DIRECT, -d DIRECT
                         maximum number of direct rays to cast [default: 1]
  --branch BRANCH, -b BRANCH
                         maximum number of branches on first hit [default: 32]
  --thin                 treat transparent surfaces as having zero thickness
  --help, -h             display this help and exit
  --version              display version and exit