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

15 篇文章 1 订阅

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 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
  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 ]
  AttributeEnd

AttributeEnd
WorldEnd

12.运行可执行文件;

pbrt ~/pbrt/sharp.pbrt

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

13. 查看及转换图形格式

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

这里写图片描述

这里写图片描述

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

  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值