• Stars
    star
    1,136
  • Rank 41,003 (Top 0.9 %)
  • Language
    Go
  • License
    MIT License
  • Created over 7 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

a Physically Based Renderer (PBR) in Go

pbr: a golang 3D renderer

Package pbr implements Physically-Based Rendering via a unidirectional CPU-only Monte Carlo path tracer.

GoDoc

pbr uses dep for dependency management.

$ go get github.com/hunterloftis/pbr
$ dep ensure
$ make

Examples

More examples


Hello, World

func main() {
	floor := surface.UnitCube(material.Plastic(1, 1, 1, 0.05))
	floor.Shift(geom.Vec{0, -0.1, 0}).Scale(geom.Vec{10, 0.1, 10})
	ball := surface.UnitSphere(material.Gold(0.05, 1))
	ball.Scale(geom.Vec{0.1, 0.1, 0.1})

	c := camera.NewSLR().MoveTo(geom.Vec{0, 0, -0.5}).LookAt(geom.Vec{0, 0, 0})
	s := surface.NewList(ball, floor)
	e := env.NewGradient(rgb.Black, rgb.Energy{750, 750, 750}, 7)

	scene := render.NewScene(c, s, e)
	err := render.Iterative(scene, "hello.png", 898, 450, 8, true)
	if err != nil {
		fmt.Fprintf(os.Stderr, "\nError: %v\n", err)
	}
}

Hello, World

Features

  • Simple synchronous API, concurrent execution, 100% Go
  • A standalone CLI
  • .obj and .mtl meshes and materials (Wavefront)
  • .hdri environment maps (Radiance)
  • Physically-based materials (metalness/roughness workflow)
  • Texture maps (base, roughness, metalness)
  • Physically-based cameras (depth-of-field, f-stop, focal length, sensor size)
  • Direct, indirect, and image-based lighting
  • Progressive rendering

Related work

CLI

Usage: pbr [--verbose] [--info] [--frames FRAMES] [--time TIME] [--material MATERIAL] [--width WIDTH] [--height HEIGHT] [--scale SCALE] [--rotate ROTATE] [--mark] [--out OUT] [--heat HEAT] [--profile] [--from FROM] [--to TO] [--focus FOCUS] [--lens LENS] [--fstop FSTOP] [--expose EXPOSE] [--bounce BOUNCE] [--indirect] [--ambient AMBIENT] [--env ENV] [--rad RAD] [--floor FLOOR] [--floorcolor FLOORCOLOR] [--floorrough FLOORROUGH] [--sun SUN] [--sunsize SUNSIZE] SCENE

Positional arguments:
  SCENE                  input scene .obj

Options:
  --verbose, -v          verbose output with scene information
  --info                 output scene information and exit
  --frames FRAMES, -f FRAMES
                         number of frames at which to exit [default: +Inf]
  --time TIME, -t TIME   time to run before exiting (seconds) [default: +Inf]
  --material MATERIAL    override material (glass, gold, mirror, plastic)
  --width WIDTH, -w WIDTH
                         rendering width in pixels [default: 800]
  --height HEIGHT, -h HEIGHT
                         rendering height in pixels [default: 450]
  --scale SCALE          scale the scene by this amount
  --rotate ROTATE        rotate the scene by this vector
  --mark                 render a watermark
  --out OUT, -o OUT      output render .png
  --heat HEAT            output heatmap as .png
  --profile              record performance into profile.pprof
  --from FROM            camera location
  --to TO                camera look point
  --focus FOCUS          camera focus ratio [default: 1]
  --lens LENS            camera focal length in mm [default: 50]
  --fstop FSTOP          camera f-stop [default: 4]
  --expose EXPOSE        exposure multiplier [default: 1]
  --bounce BOUNCE, -b BOUNCE
                         number of indirect light bounces [default: 6]
  --indirect             indirect lighting only (no direct shadow rays)
  --ambient AMBIENT      the ambient light color [default: &{1000 1000 1000}]
  --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 FLOOR          size of the floor relative to the scene mesh
  --floorcolor FLOORCOLOR
                         the color of the floor [default: &{0.9 0.9 0.9}]
  --floorrough FLOORROUGH
                         roughness of the floor [default: 0.5]
  --sun SUN              position of a daylight emitter
  --sunsize SUNSIZE      size of the sun [default: 1]
  --help, -h             display this help and exit
  --version              display version and exit

Renders

All of these, and many more are in the Makefile. To render them yourself, you'll need the fixtures directory of 3D assets:

$ make fixtures

Note: the download is over a gigabyte!

Lion

Lambo

Buddha

Sponza

Render Farm

The farm package provides a client and server for quickly spinning up a render farm. The client workers render a scene and POST samples to the server over HTTP. The server integrates the samples into a render which it returns at GET /.

To try out the 'toys' render farm example:

$ heroku create
$ heroku stack:set container
$ heroku labs:enable runtime-dyno-metadata
$ git push heroku master
$ heroku scale web=1:performance-l worker=10:performance-l
$ heroku open

More Repositories

1

newton

A playful, particle-based physics engine designed from the ground up for JavaScript.
JavaScript
917
star
2

throng

A simple worker-manager for clustered Node.js apps
JavaScript
856
star
3

playfuljs-demos

680
star
4

awaiting

The async/await utility for browsers and Node.js.
JavaScript
674
star
5

playfuljs

www.playfuljs.com
CSS
520
star
6

stoppable

Node's `server.close` the way you expected it to work.
JavaScript
403
star
7

jackrabbit

Simple AMQP / RabbitMQ job queues for node based on amqplib
JavaScript
293
star
8

cryo

JSON on steroids.
JavaScript
157
star
9

oneweekend

Ray Tracing book series implemented in Golang, chapter-by-chapter
Go
153
star
10

notes

Notes about things.
147
star
11

knockout.namespaces

Namespaces plugin for KnockoutJS
JavaScript
57
star
12

pathtracer

A simple, naive path tracer in JavaScript
JavaScript
50
star
13

summarize

Node.js module to extract and summarize html content
JavaScript
41
star
14

pbr2

Go
38
star
15

component-test

An experiment to see what a simple node app would look like with "Components" from the @visionmedia blog
JavaScript
29
star
16

nodevember-14

JavaScript
28
star
17

heroku-node-errcodes

Examples of intentionally triggering various Heroku H* errors with Node.js
JavaScript
21
star
18

heroku-destroy-temp

Heroku CLI plugin to destroy temporary apps.
JavaScript
13
star
19

ludumstar

JavaScript
12
star
20

backbone.viewmodel

ViewModels with UI Bindings for Backbone (ala KnockoutJS, Flex, .NET, MVVM pattern)
JavaScript
7
star
21

dotfiles

personal dotfiles (steam deck dev machine)
Shell
7
star
22

itemize

A lazy, fluent web crawler for Node.js with a modern async/await API.
JavaScript
6
star
23

heroku-cli-node

A Heroku CLI plugin for Node.js app development
JavaScript
5
star
24

tetrinet

JavaScript
5
star
25

node-boilerplate

Structure for your node.js project
JavaScript
4
star
26

lanes

Simple, generic, sticky routing for clustered Node.js apps
JavaScript
4
star
27

server-jsx

Render react views on your node.js server
JavaScript
4
star
28

blit

2D Sprites that render to WebGL
JavaScript
4
star
29

cltjs-node

Node.js in 30 minutes
JavaScript
3
star
30

nko-quickstart

"Hello, world" with deployment instructions.
JavaScript
3
star
31

mongoose-file

Attach a file to a mongoose Schema
JavaScript
3
star
32

docker-plugin

JavaScript
3
star
33

babylonterrain

Testing babylonjs with terrain generation
JavaScript
3
star
34

music-city-game

Workshop for Music City Code 2019
JavaScript
3
star
35

storj

An attempt at the interesting Storj challenge
Go
2
star
36

blitzkrieg

Middleware to provide an authorized domain for blitz.io load testing in Node.js.
JavaScript
2
star
37

space-snake

Ludum Dare 38: A Small World
JavaScript
2
star
38

node-production

Running Node all the way from development to production on Heroku.
JavaScript
2
star
39

okay.js

A knockout knockoff
JavaScript
2
star
40

get-large-json

Test for getting large in-memory json objects
JavaScript
2
star
41

hunterloftis.com

Personal homepage
JavaScript
2
star
42

heroku-buildpack-sfdx

Shell
1
star
43

heroku-buildpack-empty

Quick example of a no-op buildpack
Shell
1
star
44

simplenode

A simple boilerplate for single-page node projects deployable on Ubuntu VPS.
JavaScript
1
star
45

heroku-node-template

Easily template new node projects with best practices for Heroku.
JavaScript
1
star
46

ld39

JavaScript
1
star
47

backpacksncats

Our blog
CSS
1
star
48

Quarry

JavaScript
1
star
49

node-dev-env

Dockerfile
1
star
50

arduino_wiimotionplus

Reading wii motionplus data with the arduino
C++
1
star
51

handoff

JavaScript
1
star
52

socket.io-chat-distributed

Socket.io chat scaled across multiple nodes, backed by redis
HTML
1
star
53

df-micro-web

JavaScript
1
star
54

deno-pointers

Testing out Deno with a little state
TypeScript
1
star
55

game-workshop

JavaScript
1
star
56

dogfight

JavaScript
1
star
57

mongoose-timestamps

A simple mongoose plugin for storing last created and last modified information
1
star
58

loopbusy

Node.js middleware to send 503s and keep your server alive when it's too busy to queue more requests.
JavaScript
1
star
59

processing_wiimotionplus

Renders position data sent over serial by the WMP Arduino code
Java
1
star