106.0 引入
本人之前尝试过在windows系统中编译pbrt-v3,但是出现了很多错误。pbrt-v3的源代码中部分Linux的函数没有用宏包好,而是直接使用,所以在windows环境下就报错了。而且,报错的这些函数和pbrt的“图形”核心并无关系,所以本人不想深入研究这些函数。所以,决定转到Linux系统。所以,也就有了前面安装Linux系统的博文:
Q105:PC双系统:Windows 7下硬盘安装Ubuntu 16.04
http://blog.csdn.net/libing_zeng/article/details/72273281
(另外,原版电子书相关博文:Physically Based Rendering, Third Edition 第三版电子书 )
所以,这篇文章记录的是在新安装的Linux系统中安装编译PBRT-V3。
106.1 相关步骤
打开Linux终端。
1.安装git;
sudo apt-get install git
sudo apt-get install git-core
2.下载pbrt-v3源代码;
git clone --recursive https://github.com/mmp/pbrt-v3/
3.安装cmake;
sudo apt-get install cmake
4.安装zlib(zlib1g-dev);
sudo apt-get install zlib1g-dev
5.安装bison;
sudo apt-get install bison
6.安装flex;
sudo apt-get install flex
7.在代码文件夹(pbrt-v3)中新建一个文件夹”build”,定位到build文件夹中;
cd ~/pbrt-v3/build
8.cmake ../;
(结束时,会在build文件夹中产生一个makefile文件)
9.make -j4;
(根据前面产生的makefile文件进行编译,编译完成后在build文件夹会产生pbrt、pbrt_test等可执行文件)
10.链接可执行文件;
(以便系统能够找到这些可执行文件)
ln -s ~/pbrt-v3/build/* /usr/bin/
11.找一个场景脚本文件
先来个简单的场景文件。内容如下:
#sharp.pbrt -- a simple pbrt input file that displays a cone, sphere
# and refletive plane
#Richard P. Sharp - CIS782 Fall 2004
#first we set up the eye
LookAt 1 1 10 0 0 -1 0 1 0 #ex ey ez lx ly lz ux uy uz
#the camera
Camera "perspective" "float fov" [30]
#this is the filter used for antialiasing
PixelFilter "mitchell" "float xwidth" [2] "float ywidth" [2]
#name the file
Film "image" "string filename" ["sharp.exr"]
"integer xresolution" [400] "integer yresolution" [400]
#begin describing scene
WorldBegin
#light source
AttributeBegin
CoordSysTransform "camera"
LightSource "distant"
"point from" [0 0 0] "point to" [0 0 1]
"color L" [3 3 3]
AttributeEnd
#transform the world
AttributeBegin
Translate 0 -1 0