Skip to content

Commit

Permalink
Initial commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
mmp committed Jun 15, 2015
0 parents commit 5c81f47
Show file tree
Hide file tree
Showing 251 changed files with 159,665 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*~
src/build
src/bin
src/objs
.sconsign.dblite
8 changes: 8 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Copyright (c) 1998-2012, Matt Pharr and Greg Humphreys.
All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
161 changes: 161 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
pbrt, Version 3
===============

This repository holds the current snapshot of the source code to the new
version of pbrt that will be described in the forthcoming third edition of
*Physically Based Rendering: From Theory to Implementation*. As before,
the code is available under the BSD license.

Although the new version of the book won't be released until mid-2016,
we're making the source code available now so that interested users can
look at the code, try out the system, and possibly help us out. (See [how
you can help](#how-you-can-help) for more information about contributing.)
The initial release of the source code doesn't include updated
documentation (and the book isn't out yet!), so you should only try it out
if you're comfortable digging into source code.

Some [example scenes are available for
download](http://pbrt.org/pbrt-v3-scenes.tar.bz2).

The [pbrt website](http://pbrt.org) has general information about
both *Physically Based Rendering* as well as pbrt-v2, the previous version
of the system.

Significant Changes
-------------------

The system has seen many changes since the second edition. To figure out
how to use the new features, you may want to look at the example scene
files in the `scenes/` directory and read through the source code to figure
out the parameters and details of the following. (Better documentation will
come once everything is finalized.)

* Bidirectional path tracing: `Integrator "bdpt"` does proper bidirectional
path tracing with multiple importance sampling.
* Metropolis sampling: `Integrator "mlt"` uses the bidirectional path
tracer with Hachisuka et al.'s "Multiplexed Metropolis Light Transport"
technique.
* Improved numerical robustness for intersection calculations: epsilons are
small and provably conservative. [Section
draft](http://pbrt.org/fp-error-section.pdf)
* Subsurface scattering: all new implementation, integrated into the path
tracing integrator. See the `scenes/head` example scene.
* Curve shape: thin ribbons described by bicubic Bezier curves. Great for
hair, fur, and grass.
* PLY mesh support: meshes in PLY format can be used directly: `Shape
"plymesh" "string filename" "mesh.ply"`
* Realistic camera model: tracing rays through lenses to make images! See
the `scenes/dragons` example scene.
* Participating media: the boundaries of shapes are now used to delineate
the extent of regions of participating media in the scene. See the
`scenes/medium-sphere` example scene.
* New samplers: a much-improved Halton sampler, and an all-new Sobol'
sampler are both quite effective for path tracing and bidirectional path
tracing.
* Fourier representation of measured materials: an implementation of Jakob
et al's [A Comprehensive Framework for Rendering Layered
Materials](http://www.cs.cornell.edu/projects/layered-sg14/). (See an
example in the `scenes/dragons` example scene).
* New versions of the BSDF files it uses can be generated with a visual
layer editor provided in a [special branch of the Mitsuba renderer](https://www.mitsuba-renderer.org/repos/mitsuba.git/files/layered-0.5.1).
To compile this branch, install PyQt (matching your system’s
Python Version) and compile Mitsuba with the -DDOUBLE_PRECISION flag
(see the documentation for details on building Mitsuba). After sourcing
the ’setpath.sh’ script on a terminal, enter the ‘editor’ directory and
run ‘main.py’ to launch the visual layer editor.
* Improved microfacet models: specular transmission through microfacets,
and Heitz's improved importance sampling.
* No external dependencies: thanks to
[Syoyo Fujita's tinyexr](https://github.com/syoyo/tinyexr),
[Sean Barrett's stb_image_write.h](https://github.com/nothings/stb),
[Diego Nehab's rply](http://www.impa.br/~diego/software/rply),
and [Emil Mikulic's TARGA library](http://dmr.ath.cx/gfx/targa/), no
external libraries need to be compiled to build pbrt.

Many other small things have been improved (parallelization scheme, image
updates, statistics system, overall cleanliness of interfaces); see the
source code for details.

Building The System
-------------------

Currently only a makefile and [SCons](http://scons.org) build files are
available. If you have SCons installed, run `scons` from the `src/`
directory to build the system; otherwise, run `make` from the `src/`
directory.

File Format Changes
-------------------

We've tried to keep the scene description file format as unchanged as
possible. However, progress in other parts of the system required changes
to the scene description format.

First, the "Renderer", "SurfaceIntegrator", and "VolumeIntegrator"
directives have all been unified under "Integrator"; only a single
integrator now needs to be specified.

The following specific implementations were removed:

* Accelerator "grid"
* Use "bvh" or "kdtree" instead.
* Material "measured", "shinymetal"
* The new "fourier" material should now be used for measured BRDFs.
* Use "uber" in place of "shinymetal".
* VolumeRegion: all
* Use the new participating media representation [described above](#significant-changes)
* SurfaceIntegrator: photonmap, irradiancecache, igi, dipolesubsurface,
ambientocclusion, useprobes, diffuseprt, glossyprt
* Use "sppm" for the "photonmap".
* The "path" integrator now handles subsurface scattering directly.
* The others aren't as good as path tracing anyway. :-)
* VolumeIntegrator: single, emission
* Use the "volpath" path tracing integrator.
* Sampler: bestcandidate
* Use any other sampler.
* Renderer: all
* Use "Integrator", as described above.

How You Can Help
----------------

pbrt has benefited immensely both from its users who have extended it in
interesting ways and found bugs as well as from the many sharp-eyed readers
of the book over the years. If you're interested in helping out with the
third edition, some areas where we'd appreciate help are below. We'll
happily acknowledge contributors in the book's preface; we'll send a signed
copy of the book to folks who make significant contributions.

* Finding bugs: though we've tried to test thoroughly,
there are certainly bugs in the code, and we'd like to find them before
they are published in the book! The
[pbrt-v3 issue tracker](https://github.com/mmp/pbrt-v3/issues) is the best
place to report anything suspicious you find. Useful things to do include:
* Running various scenes through the renderer and checking the results.
* Using static code analysis tools (e.g. MSVC's /analyze) on the code
* Using dynamic tools like valgrind, Address Sanitizer, Thread Sanitizer,
etc. when rendering various scenes.
* Improving the build: our Makefile doesn't even properly track
dependencies. We also provide scons files, but scons isn't widely
installed. There's no XCode project or MSVC build solution. We'd happily
take improvements in this area!
* Portability: the system has been developed on Linux and OS X using x86
CPUs. It should be widely portable to other OSes and CPUs, but the only way
to get those details right is for people to try it and let us know which
targets don't currently work.
* Images and figures: we'd like to refresh many of the figures in the book,
but probably won't have time to get to all of them. If you can spend some
time on making a nice scene or two that we can use for figures, that'd be a
huge help. Specific areas of interest include:
* Subsurface scattering: a human face, biological objects, ...
* Showing off complex light transport using bidirectional path
tracing.
* Illustrating materials: something to replace all the usage of the
killeroo in Chapters 8 and 9...
* Showing the capabilities of the new curves primitive: hair, fur, fields
of grass, ...
* It would be nice to have [MirageYM's 3D
Models](https://github.com/MirageYM/3DModels) available in pbrt's scene
format.


161 changes: 161 additions & 0 deletions src/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
###########################################################################
# user-configurable section
###########################################################################

# 64 bit
MARCH=-m64

OPT=-O3
# change this to -g3 for debug builds
#OPT=-g3
# on some Linux systems, '-g -gdwarf-2' may be necessary if g++ is generating
# DWARF 4 debugging info but the installed gdb doesn't support DWARF 4 yet.
#OPT=-g -gdwarf-2

# comment out this line to enable assertions at runtime
DEFS += -DNDEBUG

#########################################################################
# nothing below this line should need to be changed (usually)
#########################################################################

ARCH = $(shell uname)

LEX=flex
YACC=bison -d -v -t
ifeq ($(ARCH),OpenBSD)
LEXLIB = -ll
endif

ifeq ($(ARCH),Linux)
CC=g++
CXX=g++ -std=c++11
# CXXLIB=-lc++
else
CC=/usr/bin/clang
CXX=/usr/bin/clang++ -std=c++11 -stdlib=libc++
CXXLIB=-lstdc++
endif

LD=$(CXX) $(OPT) $(MARCH)
INCLUDE=-I. -Icore
WARN=-Wall -Wno-deprecated-register
CWD=$(shell pwd)
CXXFLAGS=$(OPT) $(MARCH) $(INCLUDE) $(WARN) $(DEFS)
CCFLAGS=$(CXXFLAGS)
LIBS=$(LEXLIB) -lm $(CPPLIB)

LIB_CXXSRCS = $(wildcard core/*.cpp) core/pbrtlex.cpp core/pbrtparse.cpp
LIB_CXXSRCS += $(wildcard ext/*.cpp)
LIB_CXXSRCS += $(wildcard accelerators/*.cpp cameras/*.cpp filters/*.cpp )
LIB_CXXSRCS += $(wildcard integrators/*.cpp lights/*.cpp materials/*.cpp )
LIB_CXXSRCS += $(wildcard samplers/*.cpp shapes/*.cpp textures/*.cpp media/*.cpp)

LIBOBJS = $(addprefix objs/, $(subst /,_,$(LIB_CXXSRCS:.cpp=.o)))

HEADERS = $(wildcard */*.h)

TOOLS = bin/hdrtoldr bin/exravg bin/exrdiff bin/obj2pbrt bin/bsdftest bin/chi2test

default: dirs bin/pbrt $(TOOLS) bin/pbrt_tests

bin/%: dirs

pbrt: bin/pbrt

dirs:
/bin/mkdir -p bin objs

$(LIBOBJS): $(HEADERS)

.PHONY: dirs tools
.SECONDARY:

objs/libpbrt.a: $(LIBOBJS)
@echo "Building the core rendering library (libpbrt.a)"
@ar rcs $@ $(LIBOBJS)

objs/accelerators_%.o: accelerators/%.cpp
@echo "Building object $@"
@$(CXX) $(CXXFLAGS) -o $@ -c $<

objs/cameras_%.o: cameras/%.cpp
@echo "Building object $@"
@$(CXX) $(CXXFLAGS) -o $@ -c $<

objs/core_%.o: core/%.cpp
@echo "Building object $@"
@$(CXX) $(CXXFLAGS) -o $@ -c $<

objs/ext_%.o: ext/%.cpp
@echo "Building object $@"
@$(CXX) $(CXXFLAGS) -o $@ -c $<

objs/filters_%.o: filters/%.cpp
@echo "Building object $@"
@$(CXX) $(CXXFLAGS) -o $@ -c $<

objs/integrators_%.o: integrators/%.cpp
@echo "Building object $@"
@$(CXX) $(CXXFLAGS) -o $@ -c $<

objs/lights_%.o: lights/%.cpp
@echo "Building object $@"
@$(CXX) $(CXXFLAGS) -o $@ -c $<

objs/main_%.o: main/%.cpp
@echo "Building object $@"
@$(CXX) $(CXXFLAGS) -o $@ -c $<

objs/materials_%.o: materials/%.cpp
@echo "Building object $@"
@$(CXX) $(CXXFLAGS) -o $@ -c $<

objs/samplers_%.o: samplers/%.cpp
@echo "Building object $@"
@$(CXX) $(CXXFLAGS) -o $@ -c $<

objs/shapes_%.o: shapes/%.cpp
@echo "Building object $@"
@$(CXX) $(CXXFLAGS) -o $@ -c $<

objs/textures_%.o: textures/%.cpp
@echo "Building object $@"
@$(CXX) $(CXXFLAGS) -o $@ -c $<

objs/media_%.o: media/%.cpp
@echo "Building object $@"
@$(CXX) $(CXXFLAGS) -o $@ -c $<

objs/pbrt.o: main/pbrt.cpp
@echo "Building object $@"
@$(CXX) $(CXXFLAGS) -o $@ -c $<

objs/tools_%.o: tools/%.cpp
@echo "Building object $@"
@$(CXX) $(CXXFLAGS) -o $@ -c $<

bin/pbrt: objs/main_pbrt.o objs/libpbrt.a
@echo "Linking $@"
@$(CXX) $(CXXFLAGS) -o $@ $^ $(LIBS)

bin/%: objs/tools_%.o objs/libpbrt.a
@echo "Linking $@"
@$(CXX) $(CXXFLAGS) -o $@ $^ $(LIBS)

core/pbrtlex.cpp: core/pbrtlex.ll core/pbrtparse.cpp
@echo "Lex'ing pbrtlex.ll"
@$(LEX) -o$@ core/pbrtlex.ll

core/pbrtparse.cpp: core/pbrtparse.yy
@echo "YACC'ing pbrtparse.yy"
@$(YACC) -o $@ core/pbrtparse.yy
@if [ -e core/pbrtparse.cpp.h ]; then /bin/mv core/pbrtparse.cpp.h core/pbrtparse.hh; fi
@if [ -e core/pbrtparse.hpp ]; then /bin/mv core/pbrtparse.hpp core/pbrtparse.hh; fi

bin/pbrt_tests: $(wildcard tests/*cpp) objs/libpbrt.a
@echo "Building $@"
@$(CXX) $(CXXFLAGS) -o $@ $^ -Itests tests/gtest/gtest-all.cc tests/gtest/gtest_main.cc $(LIBS)

clean:
rm -f objs/* bin/* core/pbrtlex.[ch]* core/pbrtparse.[ch]*
Loading

0 comments on commit 5c81f47

Please sign in to comment.