Run the Pbrt-V4 Repository on Windows | Physically Based Rendering Series #1



Run the Pbrt-V4 Repository on Windows | Physically Based Rendering Series #1

pbrt-v4 is the official repository for Matt Pharr’s book Physically Based Rendering (4th) [1]. It is always great to have code in hand when reading a book. But till now, running the repository on Windows is still not very smooth.

· Step 1: Clone
· Step 2: Configure & Generate
· Step 3: Compile
· Step 4: Run a Simple Demo
· References

Step 1: Clone

A couple of months ago, I made a pull request for a quick fix for building on Windows and it was merged. However, build failure came again after some new updates.

I speculate that this was due to a submodule update but I do not have much time to deal with it. Maybe after a while I could have an idea.

Therefore, because it looks like there is no big change after that commit. I will stick with that commit and play around the code.

git clone https://github.com/mmp/pbrt-v4.git
cd pbrt-v4
git checkout f5767b3c727ef92aed91ff7567193181e89d76a7
git submodule update --init --recursive

Step 2: Configure & Generate


mkdir build
cd build
cmake ..

It configures and generates project files successfully. My CMake version is 3.31.3 and my OS is Windows 11 (Windows 10 should also work).

Step 3: Compile

Open build/PBRT-V4.sln and compile the pbrt_exe . No issue.

pbrt_exeis the main command-line renderer in pbrt-v4.

Step 4: Run a Simple Demo

We only need to a scene file to get started.

Write a scene filesimple_scene.pbrtmanually:

LookAt 3 4 1.5  # eye
.5 .5 0 # look at point
0 0 1 # up vector
Camera "perspective" "float fov" 45

Sampler "halton" "integer pixelsamples" 128
Integrator "volpath"
Film "rgb" "string filename" "simple.png"
"integer xresolution" [400] "integer yresolution" [400]

WorldBegin

# uniform blue-ish illumination from all directions
LightSource "infinite" "rgb L" [ .4 .45 .5 ]

# approximate the sun
LightSource "distant" "point3 from" [ -30 40 100 ]
"blackbody L" 3000 "float scale" 1.5

AttributeBegin
Material "dielectric"
Shape "sphere" "float radius" 1
AttributeEnd

AttributeBegin
Texture "checks" "spectrum" "checkerboard"
"float uscale" [16] "float vscale" [16]
"rgb tex1" [.1 .1 .1] "rgb tex2" [.8 .8 .8]
Material "diffuse" "texture reflectance" "checks"
Translate 0 0 -1
Shape "bilinearmesh"
"point3 P" [ -20 -20 0 20 -20 0 -20 20 0 20 20 0 ]
"point2 uv" [ 0 0 1 0 1 1 0 1 ]
AttributeEnd

Put it next to pbrt.exe (build/Debug/ ), and run:

.\pbrt.exe .\simple_scene.pbrt

This will generate a png image simple.pngin the same folder:

Optionally, they also offer links to various scene resources on pbrt.org.

Have a try!


If you found this article helpful, please show your support by clicking the clap icon 👏 and following me 🙏. Thank you for taking the time to read it, and have a wonderful day!

References

  1. Pharr, M., Jakob, W., & Humphreys, G. (2023). Physically based rendering: From theory to implementation. MIT Press.
  2. https://pbrt.org/

Leave a Reply

Your email address will not be published. Required fields are marked *

css.php