Want to take your software engineering career to the next level? Join the mailing list for career tips & advice Click here

pt

A path tracer written in Go.

Subscribe to updates I use pt


Statistics on pt

Number of watchers on Github 1527
Number of open issues 4
Average time to close an issue about 3 hours
Main language Go
Average time to merge a PR about 20 hours
Open pull requests 0+
Closed pull requests 1+
Last commit over 3 years ago
Repo Created almost 6 years ago
Repo Last Updated over 2 years ago
Size 1.4 MB
Organization / Authorfogleman
Contributors3
Page Updated
Do you use pt? Leave a review!
View open issues (4)
View pt activity
View on github
Book a Mock Interview With Me (Silicon Valley Engineering Leader, 100s of interviews conducted)
Software engineers: It's time to get promoted. Starting NOW! Subscribe to my mailing list and I will equip you with tools, tips and actionable advice to grow in your career.
Evaluating pt for your project? Score Explanation
Commits Score (?)
Issues & PR Score (?)

pt: a golang path tracer

Build Status GoDoc

This is a CPU-only, unidirectional path tracing engine written in Go. It has lots of features and a simple API.

Examples


Features

  • Supports OBJ and STL
  • Supports textures, bump maps and normal maps
  • Supports raymarching of signed distance fields
  • Supports volume rendering from image slices
  • Supports various material properties
  • Supports configurable depth of field
  • Supports iterative rendering
  • Supports adaptive sampling and firefly reduction
  • Uses k-d trees to accelerate ray intersection tests
  • Uses all CPU cores in parallel
  • 100% pure Go with no dependencies besides the standard library

Installation

go get -u github.com/fogleman/pt/pt

Examples

The are lots of examples to learn from! To try them, just run, e.g.

cd go/src/github.com/fogleman/pt
go run examples/gopher.go

Optional Embree Acceleration

You can optionally utilize Intel's Embree ray tracing kernels to accelerate triangle mesh intersections. First, install embree on your system: http://embree.github.io/ Then get the go-embree wrapper and checkout the embree branch of pt.

git checkout embree
go get -u github.com/fogleman/go-embree

Hello World

The following code demonstrates the basics of the API.

package main

import . "github.com/fogleman/pt/pt"

func main() {
    // create a scene
    scene := Scene{}

    // create a material
    material := DiffuseMaterial(White)

    // add the floor (a plane)
    plane := NewPlane(V(0, 0, 0), V(0, 0, 1), material)
    scene.Add(plane)

    // add the ball (a sphere)
    sphere := NewSphere(V(0, 0, 1), 1, material)
    scene.Add(sphere)

    // add a spherical light source
    light := NewSphere(V(0, 0, 5), 1, LightMaterial(White, 8))
    scene.Add(light)

    // position the camera
    camera := LookAt(V(3, 3, 3), V(0, 0, 0.5), V(0, 0, 1), 50)

    // render the scene with progressive refinement
    sampler := NewSampler(4, 4)
    renderer := NewRenderer(&scene, &camera, sampler, 960, 540)
    renderer.AdaptiveSamples = 128
    renderer.IterativeRender("out%03d.png", 1000)
}

Hello World

Adaptive Sampling

There are several sampling options that can reduce the amount of time needed to converge to an acceptable noise level. Both images below were rendered in 60 seconds. On the left, no advanced features were enabled. On the right, the features listed below were used.

Gopher

Here are some of the options that are utilized to achieve this improvement:

  • stratified sampling - on first intersection, spawn NxN rays in a stratified pattern to ensure well-distributed coverage
  • sample all lights - at each intersection, sample all lights for direct lighting instead of one random light
  • forced specular reflections - at each intersection, force both a diffuse and specular bounce and weigh them appropriately
  • adaptive sampling - spend more time sampling pixels with high variance
  • firefly reduction - very heavily sample pixels with very high variance

Combining these features results in cleaner, faster renders. The specific parameters that should be used depend greatly on the scene being rendered.

Links

Here are some resources that I have found useful.

Samples

Go

Dragon

Cornell

Lucy

SDF

Spheres

Suzanne

Molecule

pt questions on Stackoverflow (View All Questions)
  • Can Intel PT (Processor Trace) be disabled/configured from within an OS?
  • Building App in Xamarin Studio using a Mac wont show string in a correct way (language = pt-BR)
  • Copy filter data in another worksheet in form of PT
  • How can I link to a URL ending with .pt directly with Chameleon, Pyramid?
  • Checking if a file is open to prevent error - Pt. 2
  • Eloquent Javascript 2nd. Chapter 4. Computing Correlation. Lycanthrope’s log - [IndexOf Defined] Pt 1
  • identifying strings within intervals, pt 2
  • identifying strings within intervals, pt 1
  • Weird sizes / bounds on Java2d / AWT text rendering with given font pt size and dpi screen resolution?
  • pt-deadlock-logger start as deamon
  • pt-query-digest filter queries by user and database
  • How do I convert pt to sp?
  • Getting started with Intel Processor Trace (Intel PT)
  • Changing rendered fonts to PT Sans
  • Percona pt-deadlock-logger doesn't detect deadlock
  • Why do Data Services use the Servlet Ports as opposed to NIO/PT - WSO2
  • Prompt for value, then copy but add text (Pt 2)
  • T-SQL Query Help Pt. II
  • How to get pt-upgrade (Percona toolkit) to context switch on databases
  • pt-query-digest filter queries with no key or bad key
  • Doing a top level navigation with drop downs: have IE bugs pt.2
  • Best way to manage pages by language/location US/PT (Drupal)
  • Does setting --max-load Threads_running=X for pt-online-schema-change generate new threads after limit?
  • pt-table-checksum Waiting for the --replicate table to replicate
  • R error: Overfull \hbox (pt too wide) in paragraph at lines
  • Apache re-write rule PT not working with IP Address
  • Phonegap using pt instead of px
  • How to conver text size 12 pt in sp and dp?
  • Parse Time PT##H##M to NSDate
  • Android write PDF file whith itextpdf pt-BR language
pt list of languages used
Other projects in Go
Powered by Autocode - Instant Webhooks, Scripts and APIs
Autocode logo wordmark