Baike.dev
All toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
P

pt

> 编程语言
Open source

A path tracer written in Go.

2.1K stars0 likes0 views
WebsiteGitHub

About

A path tracer written in Go.

pt: a golang path tracer

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


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.

bash
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.

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

Hello World

The following code demonstrates the basics of the API.

…

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.

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.

  • WebGL Path Tracing - Evan Wallace
  • Global Illumination in a Nutshell
  • Simple Path Tracing - Iñigo Quilez
  • Realistic Raytracing - Zack Waters
  • Reflections and Refractions in Ray Tracing - Bram de Greve
  • Better Sampling - Rory Driscoll
  • Ray Tracing for Global Illumination - Nelson Max at UC Davis
  • Physically Based Rendering - Matt Pharr, Greg Humphreys

Samples

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Go

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言