Q106:Mac系统下安装编译PBRT-V3

来源:互联网 发布:stp什么软件打开 编辑:程序博客网 时间:2024/05/16 14:54

Mac和Linux比较类似,所以,“Mac系统下安装编译PBRT-V3”和“Linux系统下安装编译PBRT-V3”是非常相似的。

基于“Q106:Linux系统下安装编译PBRT-V3”,看看Mac下不同的地方。

对了,如果在Mac上使用类似于Linux上apt-get工具来安装软件的话,(Mac上对应的是homebrew)homebrew的安装参考:
Mac上安装homebrew(类似于Linux上的apt-get)
如果不使用homebrew,通过app store下载对应软件或者在其他地方找对应软件Mac版,也是可以的。下方,小编是用homebrew方式。

1.安装git;

sudo brew install git

2.下载pbrt-v3源代码;

git clone --recursive https://github.com/mmp/pbrt-v3/

3.安装cmake;

这个在Mac上,小编遇到的情况是需要先安装gcc。最好,直接将Xcode装了吧。

sudo brew install cmake

4.安装zlib(zlib1g-dev);

(Mac上自带)

5.安装bison;

(Mac上自带)

6.安装flex;

(Mac上自带)

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/local/bin/

注意,这里是和Linux上是不同的。Linux上,咱是链接到/usr/bin;而Mac上是链接到/usr/local/bin

Mac上如果链接到/usr/bin,则会报错“Operation not permitted ”。应对措施:
这是因为苹果在OS X 10.11中引入的SIP特性使得即使加了sudo(也就是具有root权限)也无法修改系统级的目录,其中就包括了/usr/bin。要解决这个问题有两种做法:一种是比较不安全的就是关闭SIP,也就是rootless特性;另一种是将本要链接到/usr/bin下的改链接到/usr/local/bin下就好了。
(这段文字来源于:https://segmentfault.com/q/1010000003958979)

11.找一个场景脚本文件

这个和Linux上一样,咱还是用sharp.part

#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 eyeLookAt 1 1 10   0 0 -1  0 1 0 #ex ey ez lx ly lz ux uy uz#the cameraCamera "perspective" "float fov" [30]#this is the filter used for antialiasingPixelFilter "mitchell" "float xwidth" [2] "float ywidth" [2]#name the fileFilm "image" "string filename" ["sharp.exr"]     "integer xresolution" [400] "integer yresolution" [400]#begin describing sceneWorldBegin#light sourceAttributeBegin  CoordSysTransform "camera"  LightSource "distant"               "point from" [0 0 0] "point to"   [0 0 1]              "color L"    [3 3 3]AttributeEnd#transform the worldAttributeBegin  Translate 0 -1 0  Rotate 35 0 1 0  #define a sphere  AttributeBegin    Translate -1 .75 -1.5    Rotate -90 1 0 0    Material "matte" "color Kd" [0.1 0.9 0.1]    Shape "sphere" "float radius" [.75]   AttributeEnd  #define a cone  AttributeBegin    Translate 0 0 2.5    Rotate -90 1 0 0    #this describes the material properties    Material "matte" "color Kd" [0.9 0.1 0.1]    #this is the shape    Shape "cone" "float radius" [.75] "float height" [2]  AttributeEnd  #define a reflective ground plane  AttributeBegin    Scale 20 20 20    Material "uber" "color Kd" [0.1 0.1 0.9] "color Kr" [0.9 0.9 0.9] "color Ks" [0.1 0.1 0.1] "float roughness" [0.9] "float index" [1.34]    #this is a triangle mesh, the first set of points define four xyz     #coordinates, the second set defines the mesh by indexing into    #those points for the triangle mesh including two triangles    Shape "trianglemesh" "point P" [ -1 0 -1  1 0 -1  1 0 1  -1 0 1 ]      "integer indices" [ 0 1 2 2 3 0 ]  AttributeEndAttributeEndWorldEnd

12.运行可执行文件;

pbrt ~/pbrt/sharp.pbrt

(执行完成后,结果图形文件保存在和可执行文件pbrt形同的路径下,名为sharp.exr)
(这里和Linux不同,Linux是保存在~/)

13. 查看及转换图形格式

不需要像Linux上那样去另外安装一个软件来打开.exr格式,
Mac自带的“预览”工具可以直接打开.exr文件,同时还可以将.exr格式转换成其他图形格式。

这里写图片描述

这里写图片描述

再次提醒,这里咱主要参考:“Q106:Linux系统下安装编译PBRT-V3”

原创粉丝点击