Q109:用PBRT渲染Blender导出的模型

来源:互联网 发布:怎样参加淘宝抢购 编辑:程序博客网 时间:2024/05/16 19:05

前续:Q106:Linux系统下安装编译PBRT-V3

这篇文章的内容主要分两部分:1,用Blender建立模型;2,用PBRT渲染

一、用Blender建立模型

咱在这里要建立的模型是“马克杯”。完全参考:
台湾大神的blender教程全集
中的“马克杯”部分。

小编看视频做的笔记截图:
这里写图片描述

将模型数据导出,截图如下:

这里写图片描述

导出的有如下两个文件:
这里写图片描述

二、用PBRT渲染

参考:http://pbrt.org/users-guide.html

会用到工具obj2pbrt,这个工具是之前在编译PBRT时一起生成的。
Q106:Linux系统下安装编译PBRT-V3 中的

10.链接可执行文件;
(以便系统能够找到这些可执行文件)
ln -s ~/pbrt-v3/build/* /usr/bin/

已经将obj2pbrt安装在系统中,此时只需执行:

obj2pbrt ~/pbrt/cup/cup3/cup3.obj ~/pbrt/cup/cup3/cup3_geo.pbrt

即将从Blender中导出的.obj文件转换成了.pbrt文件。

根据http://pbrt.org/users-guide.html
中的建议,

First, you may find it useful to run

$ pbrt –toply scene.pbrt > newscene.pbrt

This will convert triangle meshes into more compact binary PLY files, giving you a much smaller pbrt scene file to edit.

所以执行:

pbrt --toply ~/pbrt/cup/cup3/cup3_geo.pbrt > ~/pbrt/cup/cup3/cup3/cup3-geo_new.pbrt

执行完这条指令,会在当前目录下生成cup-geo_new.pbrt文件,同时在~/目录下生成mesh_00001.ply文件。
将mesh_00001.ply文件剪切到当前目录中。

接下来,只需要设置场景脚本文件啦。这里,咱用两种方式来进行渲染:方式一、sppm;方式二、bdtp
(sppm、bdtp是PBRT-V3中提供的积分器)

方式一、sppm

脚本文件(命名为cup3_glass_sppm_blue.pbrt)如下:

#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 5 10   0 0 -3  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" ["cup.exr"]     "integer xresolution" [400] "integer yresolution" [400]Integrator "sppm"  "float radius" .075    "integer numiterations" [10] "integer photonsperiteration" [5000000]#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 an orangish sphere  AttributeBegin    Scale 1.5 1.5 1.5    Translate 1.5 1 -1.5    Rotate -135 0 1 0    Material "glass"             "float index" [ 1.2500000000 ]     Shape "plymesh" "string filename" "mesh_00001.ply"   AttributeEnd  #define a reflective ground plane  AttributeBegin    Scale 20 20 20    Material "matte" "color Kd" [0.1 1 1]    #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    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

渲染该文件:

pbrt ~/pbrt/cup/cup3/cup3_glass_sppm_blue.pbrt 

生成图形:

这里写图片描述

方式二、bdtp

脚本文件(命名为cup3_glass_bdtp_blue.pbrt)如下:

#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 5 10   0 0 -3  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" ["cup3_glass_bdpt_blue.exr"]     "integer xresolution" [400] "integer yresolution" [400]Sampler "sobol" "integer pixelsamples" 512Integrator "bdpt" "integer maxdepth" 20#begin describing sceneWorldBeginLightSource "spot"         "point from" [ 0 5 5 ]         "point to" [ 1.5 1 -1.5 ]         "rgb I" [ 139.8113403320 118.6366500854 105.3887557983 ] AttributeBegin    LightSource "infinite"             "rgb L" [ 0.1000000015 0.1000000015 0.1000000015 ] AttributeEnd#transform the worldAttributeBegin  Translate 0 -1 0  Rotate 35 0 1 0  #define an orangish sphere  AttributeBegin    Scale 1.5 1.5 1.5    Translate 1.5 1 -1.5    Rotate -135 0 1 0    Material "glass"             "float index" [ 1.2500000000 ]     Shape "plymesh" "string filename" "mesh_00001.ply"   AttributeEnd  #define a reflective ground plane  AttributeBegin    Scale 20 20 20    Material "matte" "color Kd" [0.1 1 1]    #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    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

渲染该文件:

pbrt ~/pbrt/cup/cup3/cup3_glass_bdtp_blue.pbrt 

生成图形:
这里写图片描述

阅读全文
1 0
原创粉丝点击