Tuesday, August 29, 2017

Building pbrt-v3 in VS 2015, rendering a metal teapot

Finding Physically Based Rendering: From Theory to Implementation at my university last August and then figuring out this January how to build pbrt-v3 and use cmake for the first time was really exciting for me. Hardly knew anything about them then (and now too haha), but would like to look more into raytracing with this in the future.

For now, I'd like to share the bare steps I took to get pbrt-v3 built in VS 2015 in 64-bit and to render a "teapot-metal.pbrt" sample. Again, I know close to nothing about pbrt and little about cmake, but I still think it'd be cool to share the steps I found to get something rendered here, for people interested in computer graphics at this level.

EDIT: Important to note is that Debug build of pbrt for debugging purposes runs way slower than Release build. Also, possible minor bug fix with PBRT_FLOAT_AS_DOUBLE. Made general other notes about pbrt in a blog post here

(Using Windows 8.1, Visual Studio 2015, and CMake 3.7.2. For git, I just got it working by installing Github Desktop for Windows)

1. Open cmd. Switch to a folder where you want the pbrt-v3 source code folder to be cloned into.

2. Type "git clone --recursive https://github.com/mmp/pbrt-v3/.
  -Cloning will take a while. A folder named "pbrt-v3" will appear when done.

3. Open CMake GUI.
  -For "Where is the source code", click "Browse Source", and select the "pbrt-v3" folder.
  -For "Where to build the binaries", select an empty folder. I made a folder called "pbrt_build".

4. Click "Configure". In "Specify the generator for this project", Select "Visual Studio 14 2015 Win64" (this will make a VS 2015 solution that only has a 64-bit build option). Click Finish.

5. CMake will do configuration processing. When it's finished, it'll show values in red. Click "Configure" again to confirm the configuration.

6. Click "Generate" to actually create a VS 2015 solution. Then click "Open Project" to open the solution.

7. VS 2015 will probably do some initial processing. When it's done, click "Build -> Build Solution".
  -The configuration I'm building in is Debug - x64.

8. With a successful build, you'll get a "pbrt.exe" to use. I'd say check it out at this point, for curiosity.

  -To check out the build, open your solution directory (you can right-click "Solution 'PBRT-V3' (40 projects)" in the Solution Explorer and click "Open Folder in File Explorer").

  -Open the Debug folder from there. There'll be a bunch of exes, "pbrt.exe" included. Open cmd in the Debug folder (you can Shift -> Right-click -> Open command window here, for convenience).

  -Type "pbrt". You'll see version information. Hit "Ctrl+C" at the prompt to exit the program.



9. Knowing about pbrt.exe, you can render a sample. I'll be focusing on a file set based on a teapot-metal.pbrt. To check out the entire sample set linked in the pbrt site, follow steps 10 and 11. The sample set is massive, 10 GB, so I provided the files for the teapot in my dropbox in step 12 if you just want that.

10. To check out the entire 10 GB sample set linked in the pbrt site, in cmd, switch to a folder where you want to clone a "pbrt-v3-scenes" folder into.

11. Type "git clone git://git.pbrt.org/pbrt-v3-scenes".
  -The scenes folder is super massive, 10 GB. Cloning seems to compress the folder to ~3.11 GB from looking at cmd, but still very large.



12. If you want to just get the files for rendering the sample teapot I'll be using, here's a link in my dropbox. Download all the files somewhere. Make sure to preserve the directory structure. The files referenced in teapot-metal.pbrt are relative.

13. Run cmd. Type "pbrt <directory>\teapot-metal.pbrt". For my computer, I downloaded the entire 10 GB sample set, and I typed:

pbrt "C:\Users\Nicolas\Desktop\pbrt_test\pbrt-v3-scenes\simple\teapot-metal.pbrt"

  -You should see licensing info. immediately, and a progress bar appear after a while (probably due to some pre-procsessing stuff).

14. Wait a long time. Keep your computer on.
  -When I did my first pbrt render with this teapot, the stats showed 26752.9 seconds. (That's 7.4 hours!)

15. On completion, you'll see a teapot-metal.exr file in the same directory as where you ran the pbrt command. Open/convert as needed. For me, I had to convert it to some file I could open. Currently, I find you can use Convertio to convert an exr to a jpg for example. It's free, no hassle.

16. That's it! Here's the jpg I got while writing this:







No comments:

Post a Comment