PBRT v4 - Part I: Kroken Scene

Jan Walter July 03, 2023 [TRACE] #pbrt-v4

The fourth edition of the Physically Based Rendering book was released this year (in 2023). The C++ source code is available on GitHub and after compiling it (via CMake) I wanted to render my first picture:

4096 samples per pixel

The nice thing about pbrt-v4 is that we can watch the resulting image being rendered via tev. First start the EXR Viewer:

$ tev
12:21:30 SUCCESS  Initialized IPC, listening on 127.0.0.1:14158
12:21:30 INFO     Loading window...
12:22:18 INFO     Accepted IPC client connection into socket fd 34 (host: 127.0.0.1:38522)
12:23:42 SUCCESS  Loaded 'camera-1.exr (16590)' via IPC after 0.013 seconds.
12:24:47 INFO     Client disconnected from socket fd 34
12:30:10 INFO     Accepted IPC client connection into socket fd 34 (host: 127.0.0.1:52838)
...

Then connect to the viewer by using the --display-server command line option:

$ time ./pbrt --stats --spp 4096 --display-server localhost:14158 ../../pbrt-v4-scenes/kroken/camera-1.pbrt 
pbrt version 4 (built Jul  3 2023 at 12:16:24)
Copyright (c)1998-2021 Matt Pharr, Wenzel Jakob, and Greg Humphreys.
The source code to pbrt (but *not* the book contents) is covered by the Apache 2.0 License.
See the file LICENSE.txt for the conditions of the license.
Warning: /media/datadisk3/git/github/pbrt-v4-scenes/kroken/lights.pbrt:7:4: Converting non-RGB "L" parameter to RGB so that a portal light can be used.
Rendering: [+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++]  (4134.9s)          
Statistics:
  BVH
    Interior nodes                                              287361520
    Leaf nodes                                                  287361531
    Nodes visited                                            1696162946832
    Primitives per leaf node                     287902422 /    287361531 (1.00x)
  Geometry
    Spheres                                                             2
    Triangles added from displacement mapping                   247702869
    Buffer cache hits                                  239 /          955 (25.03%)
    Triangles per mesh                           287904585 /          248 (1160905.58x)
  Integrator
    Camera rays traced                                         2304000000
    Surface interactions                                       8840973743
    Volume interactions                                          20663051
  Intersections
    Regular ray intersection tests                            15575663309
    Ray-Triangle intersection tests            18868481914 /  86881406902 (0.22x)
  Memory
    BVH                                                             19.27 GiB
    Film pixels                                                    103.00 MiB
    Image maps                                                     159.38 MiB
    Light BVH                                                      184.91 kB
    Primitives                                                       4.29 GiB
    Redundant vertex and index buffers                             347.69 MiB
    Tokenizer buffers                                              244.50 kB
    Triangles                                                        2.15 GiB
    Unreported / unused                                             16.97 GiB
  Scene
    AreaLights                                                       2175
    Lights                                                           2176
    Materials                                                          80
    Object instances created                                           10
    Textures                                                          164

real	70m24,642s
user	1891m16,519s
sys	1m47,339s

Compiling

$ cmake --version
cmake version 3.26.4

CMake suite maintained and supported by Kitware (kitware.com/cmake).
$ pwd
/media/datadisk3/git/github/pbrt-v4
$ mkdir build
$ cd build/
$ cmake ..
-- The CXX compiler identification is GNU 9.4.0
-- The C compiler identification is GNU 9.4.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Setting build type to 'Release' as none was specified.
-- Found Git: /home/linuxbrew/.linuxbrew/bin/git (found version "2.41.0") 
-- OpenEXR at commit: 5cfb5dab6dfada731586b0281bdb15ee75e26782
-- OpenVDB at commit: 414bed84c2fc22e188eac7b611aa85c7edd7a5a9
-- Ptex at commit: 4cd8e9a6db2b06e478dfbbd8c26eb6df97f84483
-- double-conversion at commit: cc1f75a114aca8d2af69f73a5a959aecbab0e87a
-- filesystem at commit: c5f9de30142453eb3c6fe991e82dfc2583373116
-- glfw at commit: 4cb36872a5fe448c205d0b46f0e8c8b57530cfe0
-- libdeflate at commit: 1fd0bea6ca2073c68493632dafc4b1ddda1bcbc3
-- lodepng at commit: 8c6a9e30576f07bf470ad6f09458a2dcd7a6a84a
-- qoi at commit: 028c75fd26e5e0758c7c711216c00404994c1ad3
-- stb at commit: af1a5bc352164740c1cc1354942b1c6b72eacb8a
-- utf8proc at commit: 2484e2ed5e1d9c19edcccf392a7d9920ad90dfaf
-- zlib at commit: 54d591eabf9fe0e84c725638f8d5d8d202a093fa
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE  
-- Found OpenGL: /usr/lib/x86_64-linux-gnu/libOpenGL.so   
-- The ASM compiler identification is GNU
-- Found assembler: /usr/bin/cc
CMake Warning (dev) at src/ext/libdeflate/CMakeLists.txt:12 (option):
  Policy CMP0077 is not set: option() honors normal variables.  Run "cmake
  --help-policy CMP0077" for policy details.  Use the cmake_policy command to
  set the policy and suppress this warning.

  For compatibility with older versions of CMake, option is clearing the
  normal variable 'BUILD_SHARED_LIBS'.
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Performing Test DEFLATE_LINT_WALL
-- Performing Test DEFLATE_LINT_WALL - Success
-- Performing Test DEFLATE_LINT_WUNDEF
-- Performing Test DEFLATE_LINT_WUNDEF - Success
-- Performing Test DEFLATE_LINT_PEDANTIC
-- Performing Test DEFLATE_LINT_PEDANTIC - Success
-- Performing Test DEFLATE_LINT_DECLARATION_AFTER_STATEMENT
-- Performing Test DEFLATE_LINT_DECLARATION_AFTER_STATEMENT - Success
-- Performing Test DEFLATE_LINT_MISSING_PROTOTYPES
-- Performing Test DEFLATE_LINT_MISSING_PROTOTYPES - Success
-- Performing Test DEFLATE_LINT_STRICT_PROTOTYPES
-- Performing Test DEFLATE_LINT_STRICT_PROTOTYPES - Success
-- Performing Test DEFLATE_LINT_VLA
-- Performing Test DEFLATE_LINT_VLA - Success
-- Performing Test DEFLATE_LINT_IMPLICIT_FALLTHROUGH
-- Performing Test DEFLATE_LINT_IMPLICIT_FALLTHROUGH - Success
-- Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found version "1.2.11")  
-- Could NOT find Imath (missing: Imath_DIR)
-- Could NOT find IlmBase (missing: IlmBase_DIR)
-- Could NOT find OpenEXR (missing: OpenEXR_DIR)
-- Found PkgConfig: /home/linuxbrew/.linuxbrew/bin/pkg-config (found version "0.29.2") 
-- Found OpenEXR: /usr/include (found suitable version "2.3.0", minimum required is "2.3") 
-- Found OpenEXR version 2.3.0
CMake Deprecation Warning at src/ext/ptex/CMakeLists.txt:1 (cmake_minimum_required):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.


-- Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE) 
-- Including X11 support
-- Found X11: /usr/include   
-- Looking for XOpenDisplay in /usr/lib/x86_64-linux-gnu/libX11.so;/usr/lib/x86_64-linux-gnu/libXext.so
-- Looking for XOpenDisplay in /usr/lib/x86_64-linux-gnu/libX11.so;/usr/lib/x86_64-linux-gnu/libXext.so - found
-- Looking for gethostbyname
-- Looking for gethostbyname - found
-- Looking for connect
-- Looking for connect - found
-- Looking for remove
-- Looking for remove - found
-- Looking for shmat
-- Looking for shmat - found
-- Looking for IceConnectionNumber in ICE
-- Looking for IceConnectionNumber in ICE - found
-- Unable to find -lprofiler
-- Looking for a CUDA compiler
-- Looking for a CUDA compiler - /usr/local/cuda/bin/nvcc
-- Found CUDA: /usr/local/cuda (found version "11.0") 
-- Found CUDA: 11.0.221
CMake Warning at CMakeLists.txt:189 (message):
  Found CUDA but PBRT_OPTIX7_PATH is not set.  Disabling GPU compilation.


-- Performing Test COMPILER_SUPPORTS_MARCH_NATIVE
-- Performing Test COMPILER_SUPPORTS_MARCH_NATIVE - Success
-- Performing Test HAVE_MMAP
-- Performing Test HAVE_MMAP - Success
-- Performing Test HAS_INTRIN_H
-- Performing Test HAS_INTRIN_H - Failed
-- Performing Test HAVE_DECLSPEC_NOINLINE
-- Performing Test HAVE_DECLSPEC_NOINLINE - Failed
-- Performing Test HAVE_ATTRIBUTE_NOINLINE
-- Performing Test HAVE_ATTRIBUTE_NOINLINE - Success
-- Performing Test HAVE_PRE_POST_BAR_RESTRICT
-- Performing Test HAVE_PRE_POST_BAR_RESTRICT - Success
-- Performing Test HAVE_PRE_BAR_RESTRICT
-- Performing Test HAVE_PRE_BAR_RESTRICT - Success
-- Performing Test HAVE__ALIGNED_MALLOC
-- Performing Test HAVE__ALIGNED_MALLOC - Failed
-- Performing Test HAVE_POSIX_MEMALIGN
-- Performing Test HAVE_POSIX_MEMALIGN - Success
-- Performing Test INT64_IS_OWN_TYPE
-- Performing Test INT64_IS_OWN_TYPE - Failed
-- Configuring done (5.8s)
-- Generating done (0.1s)
-- Build files have been written to: /media/datadisk3/git/github/pbrt-v4/build
$ cmake --build .
...
[100%] Linking CXX executable cctest
[100%] Built target cctest

Using imgtool

Using imgtool for whitebalance and conversion

Above is a slightly modified version using the imgtool (which comes with pbrt-v4) to convert the OpenEXR file to PNG and apply a whitebalance:

$ ./imgtool whitebalance --temperature 6200 camera-1.exr --outfile wb-camera-1.exr
$ ./imgtool convert --aces-filmic wb-camera-1.exr --outfile camera-1.png

The difference is a bit hard to catch by eye, but the imf_diff tool helps to see it, using false-color:

$ imf_diff -d -f kroken-001.png camera-1.png diff-001.jpg
differing pixels:	 98.718% (555290 of 562500)
average difference:	  7.245%
maximum difference:	  9.987%
Summary: Many pixels differ slightly.
== "kroken-001.png" and "camera-1.png" are different

Using imf_diff from mental images

camera-4

There are seven camera perspectives of the same scene (kroken) shipping with the current version of the repository full of pbrt-v4-scenes. Here's another example, how the scene looks like from camera-4:

4096 samples per pixel

And the resulting statistics:

$ time ./pbrt --stats --spp 4096 --display-server localhost:14158 ../../pbrt-v4-scenes/kroken/camera-4.pbrt 
pbrt version 4 (built Jul  3 2023 at 12:16:24)
Copyright (c)1998-2021 Matt Pharr, Wenzel Jakob, and Greg Humphreys.
The source code to pbrt (but *not* the book contents) is covered by the Apache 2.0 License.
See the file LICENSE.txt for the conditions of the license.
Warning: /media/datadisk3/git/github/pbrt-v4-scenes/kroken/lights.pbrt:7:4: Converting non-RGB "L" parameter to RGB so that a portal light can be used.
Rendering: [+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++]  (4612.3s)          
Statistics:
  BVH
    Interior nodes                                              287364302
    Leaf nodes                                                  287364313
    Nodes visited                                            1640129095053
    Primitives per leaf node                     287904106 /    287364313 (1.00x)
  Geometry
    Spheres                                                             2
    Triangles added from displacement mapping                   247704553
    Buffer cache hits                                  239 /          955 (25.03%)
    Triangles per mesh                           287906269 /          248 (1160912.38x)
  Integrator
    Camera rays traced                                         3221225472
    Surface interactions                                      12319864491
    Volume interactions                                           5000267
  Intersections
    Regular ray intersection tests                            19757521699
    Ray-Triangle intersection tests            25378979959 / 123058811405 (0.21x)
  Memory
    BVH                                                             19.27 GiB
    Film pixels                                                    144.00 MiB
    Image maps                                                     159.38 MiB
    Light BVH                                                      184.91 kB
    Primitives                                                       4.29 GiB
    Redundant vertex and index buffers                             347.69 MiB
    Tokenizer buffers                                              244.55 kB
    Triangles                                                        2.15 GiB
    Unreported / unused                                             17.76 GiB
  Scene
    AreaLights                                                       2175
    Lights                                                           2176
    Materials                                                          80
    Object instances created                                           10
    Textures                                                          164

real	78m25,715s
user	2115m43,111s
sys	1m39,895s

Currently this scene does not render with the Rust version rs-pbrt based on pbrt-v3, but there are a couple of things which might get ported:

  1. The connection to tev would allow to watch the renderer doing it's job.
  2. Can we somehow use a denoiser?
  3. Can the parser be adjusted to read pbrt-v4 scenes (maybe by adding some missing materials)?

Back to top