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

本文详细介绍了如何在Mac系统下安装并编译PBRT-V3,包括使用Homebrew安装必要的依赖软件,配置编译环境,以及编译后的可执行文件链接和测试过程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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

通过cypress 上传文件并检查文件是否上传成功 <div class="w-100%"><!--v-if--><div class="el-upload el-upload--text is-drag" tabindex="0"><div class="el-upload-dragger"><!--v-if--><i class="el-icon el-icon--upload"><i class="el-icon v-icon" style="font-size: 40px;"><span class="" style="font-size: 40px; height: 1em;"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" width="1.37em" height="1em" viewBox="0 0 1920 1408" data-icon="fa:cloud-upload" class="iconify iconify--fa"><path fill="currentColor" d="M1280 736q0-14-9-23L919 361q-9-9-23-9t-23 9L522 712q-10 12-10 24q0 14 9 23t23 9h224v352q0 13 9.5 22.5t22.5 9.5h192q13 0 22.5-9.5t9.5-22.5V768h224q13 0 22.5-9.5t9.5-22.5m640 288q0 159-112.5 271.5T1536 1408H448q-185 0-316.5-131.5T0 960q0-130 70-240t188-165q-2-30-2-43q0-212 150-362T768 0q156 0 285.5 87T1242 318q71-62 166-62q106 0 181 75t75 181q0 76-41 138q130 31 213.5 135.5T1920 1024"></path></svg></span></i></i><div class="el-upload__text" style="color: rgb(12, 97, 182);"> 拖动文件到此处或点击上传</div><div class="el-upload__text mt-10px"> 支持的文件格式:xls、xlsx、pdf、jpg、png、doc、docx、zip、rar、7z,不超过100M </div></div><input class="el-upload__input" name="file" multiple="" accept=".pdf,.doc,.docx,.xls,.xlsx,.jpg,.jpeg,.png,.zip,.rar,.7z" type="file"></div><!--v-if--><ul class="el-upload-list el-upload-list--text"><li class="el-upload-list__item is-success" tabindex="0"><!--v-if--><div class="el-upload-list__item-info"><a class="el-upload-list__item-name"><i class="el-icon el-icon--document"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024"><path fill="currentColor" d="M832 384H576V128H192v768h640zm-26.496-64L640 154.496V320zM160 64h480l256 256v608a32 32 0 0 1-32 32H160a32 32 0 0 1-32-32V96a32 32 0 0 1 32-32m160 448h384v64H320zm0-192h160v64H320zm0 384h384v64H320z"></path></svg></i><span class="el-upload-list__item-file-name" title="立项备案导出.xlsx">立项备案导出.xlsx</span></a><!--v-if--></div><label class="el-upload-list__item-status-label"><i class="el-icon el-icon--upload-success el-icon--circle-check"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024"><path fill="currentColor" d="M512 896a384 384 0 1 0 0-768 384 384 0 0 0 0 768m0 64a448 448 0 1 1 0-896 448 448 0 0 1 0 896"></path><path fill="currentColor" d="M745.344 361.344a32 32 0 0 1 45.312 45.312l-288 288a32 32 0 0 1-45.312 0l-160-160a32 32 0 1 1 45.312-45.312L480 626.752l265.344-265.408z"></path></svg></i></label><i class="el-icon el-icon--close"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024"><path fill="currentColor" d="M764.288 214.592 512 466.88 259.712 214.592a31.936 31.936 0 0 0-45.12 45.12L466.752 512 214.528 764.224a31.936 31.936 0 1 0 45.12 45.184L512 557.184l252.288 252.288a31.936 31.936 0 0 0 45.12-45.12L557.12 512.064l252.288-252.352a31.936 31.936 0 1 0-45.12-45.184z"></path></svg></i><!-- Due to close btn only appears when li gets focused disappears after li gets blurred, thus keyboard navigation can never reach close btn--><!-- This is a bug which needs to be fixed --><!-- TODO: Fix the incorrect navigation interaction --><i class="el-icon--close-tip">按 delete 键可删除</i><!--v-if--></li><li class="el-upload-list__item is-success" tabindex="0"><!--v-if--><div class="el-upload-list__item-info"><a class="el-upload-list__item-name"><i class="el-icon el-icon--document"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024"><path fill="currentColor" d="M832 384H576V128H192v768h640zm-26.496-64L640 154.496V320zM160 64h480l256 256v608a32 32 0 0 1-32 32H160a32 32 0 0 1-32-32V96a32 32 0 0 1 32-32m160 448h384v64H320zm0-192h160v64H320zm0 384h384v64H320z"></path></svg></i><span class="el-upload-list__item-file-name" title="sh001.jpg">sh001.jpg</span></a><!--v-if--></div><label class="el-upload-list__item-status-label"><i class="el-icon el-icon--upload-success el-icon--circle-check"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024"><path fill="currentColor" d="M512 896a384 384 0 1 0 0-768 384 384 0 0 0 0 768m0 64a448 448 0 1 1 0-896 448 448 0 0 1 0 896"></path><path fill="currentColor" d="M745.344 361.344a32 32 0 0 1 45.312 45.312l-288 288a32 32 0 0 1-45.312 0l-160-160a32 32 0 1 1 45.312-45.312L480 626.752l265.344-265.408z"></path></svg></i></label><i class="el-icon el-icon--close"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024"><path fill="currentColor" d="M764.288 214.592 512 466.88 259.712 214.592a31.936 31.936 0 0 0-45.12 45.12L466.752 512 214.528 764.224a31.936 31.936 0 1 0 45.12 45.184L512 557.184l252.288 252.288a31.936 31.936 0 0 0 45.12-45.12L557.12 512.064l252.288-252.352a31.936 31.936 0 1 0-45.12-45.184z"></path></svg></i><!-- Due to close btn only appears when li gets focused disappears after li gets blurred, thus keyboard navigation can never reach close btn--><!-- This is a bug which needs to be fixed --><!-- TODO: Fix the incorrect navigation interaction --><i class="el-icon--close-tip">按 delete 键可删除</i><!--v-if--></li></ul></div>
最新发布
07-12
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值