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

195 篇文章 27 订阅
53 篇文章 22 订阅

前续: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 eye
LookAt 1 5 10   0 0 -3  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" ["cup.exr"]
     "integer xresolution" [400] "integer yresolution" [400]

Integrator "sppm"  "float radius" .075
    "integer numiterations" [10] "integer photonsperiteration" [5000000]

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

AttributeEnd
WorldEnd

渲染该文件:

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 eye
LookAt 1 5 10   0 0 -3  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" ["cup3_glass_bdpt_blue.exr"]
     "integer xresolution" [400] "integer yresolution" [400]


Sampler "sobol" "integer pixelsamples" 512
Integrator "bdpt" "integer maxdepth" 20


#begin describing scene
WorldBegin

LightSource "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 world
AttributeBegin
  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 ]
  AttributeEnd

AttributeEnd
WorldEnd

渲染该文件:

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

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

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值