1/2 >>

Guile RMan is a set of bindings for the RenderMan API

Guile RMan is a set of bindings for the RenderMan API as implemented by Aqsis, using SWIG and libffi.
Support for function callbacks written in Scheme
Support Scheme RiProcedurals
Type checking for named paramter lists
Support for both immediate rendering and RIB output
A utilities module to provide simple wrapper around RenderMan block structure
https://github.com/tcolgate/guile-rman

インストール方法いろいろ試してみました。
32ビットLinuxで動作します。
Aqsisは1.6.0
gnu guile2.0.9(最低2.0.0で動きます。)
guile-lib0.2.2(最低0.2.0で動きます。)

■Windows7 64bitにVirtualBoxを入れ、CentOS6.3 i686上で動作確認しました。
●準備
Aqsis1.6をインストールします。
リポジトリにEPELを設定するとしAqsis1.6があります。
http://www.tooyama.org/yum-addrepo-epel.html
を参考にEPELを設定します。
管理者で
#yum --enablerepo=epel search aqsis
で探します。
============================== N/S Matched: aqsis ==============================
aqsis-core.i686 : Command-line tools for Aqsis Renderer
aqsis-data.noarch : Example content for Aqsis Renderer
aqsis-devel.i686 : Development files for Aqsis Renderer
aqsis-libs.i686 : Library files for Aqsis Renderer
aqsis.i686 : Open source 3D rendering solution adhering to the RenderMan: standard
と出てきたら、
yum --enablerepo=epel install aqsis-devel.i686
をインストールすると関連ファイルも含めて全部入れてくれます。

●guile-rman関連のインストール
1. SWIGをインストールします。swig-2.0.11をダウンロードし
$ ./configure
$ make
# make install
します。
CentOSのSWIGは1.3と古いので入れていたら削除します。

2. gnu guile2.0.9をダウンロードします。
https://www.gnu.org/software/guile/download.html

$./configure

うまく行かない場合は、指示を見て
以下のツールをあらかじめインストールします。
readline-devel
texinfo
ltdl-devel
gmp-devel
libunistring-devel
libffi-devel
gc-devel
gc
PCRE-devel

入れたら
$ ./configure
$ make
とても時間がかかります。
管理者になって
# make install
/usr/local/binにインストールされます。

アンインストールは
# make uninstall
でできます。

3. guile-lib0.2.2をダウンロードします。
http://www.nongnu.org/guile-lib/download/
$ ./configure
$ make
管理者になって
# make install
アンインストールは
# make uninstall
でできます。

4. guile-rman のインストール
$ sh autogen.sh
$ ./configure
以上を行います。
guile-rman-master/src/Makefileを以下のように変更。

-I/usr/local/include/aqsisを
-I/usr/include/aqsis

-I/usr/local/includeを
-I/usr/local/include/guile/2.0

rispec.iを以下のように変更。
includeで検索し、
4行目ri.h
ri/ri.h

5行目rif.h
ri/rif.h

107行目ri_types.h
ri/ritypes.h

308行目aqsis/config.h
config.h

309行目ri.h
ri/ri.h

310行目rif.h
ri/rif.h

313行目ri.inl
ri/ri.inl

$ make
をします。
うまく行かない場合。
$ make 2>&1 | tee make.log
を使ってエラー確認、make.logをのぞいて確認すると良いです。

無事makeできたら、
管理者になって
# make install

アンインストールは
# make uninstall
でできます。

以下のサンプルを試してみましょう。simple.scmとして保存します。

#!/usr/bin/guile -s
!#

(use-modules (rman rispec))
(use-modules (rman utilities))

(RiBegin "simple.rib")
(RiDisplay "simple.tif" "file" "rgb")
(RiFormat 640 480 1)
(RiProjection "perspective" '("fov" 30))
(RiTranslate 0 0 5)
; (RiProgressHandler progress)
(RiPixelFilter RiBoxFilter 1 1)
(RiWorldBegin)
(RiLightSource "ambientlight" (list "intensity" 0.2))
(RiLightSource "distantlight" (list "intensity" 1.2 ))
(RiAttributeBegin)
(RiColor (Color 1.0 0.6 0.0))
(RiSurface "plastic")
(RiTransformBegin)
(RiRotate 90 1 0 0)
(RiSphere 1 -1 1 360)
(RiTransformEnd)
(RiAttributeEnd)
(RiWorldEnd)
(RiEnd)


$ guile simple.scm
と実行することで、simple.tifが出力されれば成功です。
simple.jpg

次はtest2.scmで保存します。

#!/usr/bin/guile -s
!#

(use-modules (rman rispec))
(use-modules (rman utilities))

(RiBegin "test2.rib")
(RiDisplay "sphere2.tif" "file" "rgb")
(RiFormat 640 480 1)
(RiProjection "perspective" '("fov" 40.0))
(RiTranslate 0 0 6)
; (RiProgressHandler progress)
(RiPixelFilter RiBoxFilter 1 1)
(RiWorldBegin)
(let ((o1 (Object (RiSphere 1 -1 1 360))))
(RiLightSource "ambientlight" (list "intensity" 0.2))
(RiLightSource "distantlight" (list "intensity" 1.2
"uniform point from" (Point 3 3 -3)))
(RiColor (Color 1.0 0.0 0.0))
(RiSurface "plastic")
(RiTranslate -2.0 0 0)
(RiObjectInstance o1)
(RiColor (Color 0.0 1.0 0.0))
(RiSurface "plastic")
(RiTranslate 2.0 0 0)
(RiObjectInstance o1)
(RiColor (Color 0.0 0.0 1.0))
(RiSurface "plastic")
(RiTranslate 2.0 0 0)
(RiObjectInstance o1))
(RiWorldEnd)
(RiEnd)

$ guile test2.scm
とやることで、sphere2.tifが出力されれば成功です。
sphere2.jpg
  • -
  • -

Guile RMan #2 shadowmap

Essential RenderManを参考にguile-rmanでやってみた。
Points、Polygon、Patchの表記がわからないので、Diskを地面にしました。
witshadow.jpg

1 影なし


noshadow.scmで保存

#!/usr/bin/guile -s
!#

(use-modules (rman rispec))
(use-modules (rman utilities))

(RiBegin "noshadow.rib")
(RiDisplay "npshadow.tif" "file" "rgb")
(RiFormat 640 480 1)
(RiProjection "perspective" '("fov" 30))
(RiTranslate 0 0 6)
(RiRotate -48 1 0 0)
(RiRotate -20 0 1 0)
(RiPixelFilter RiBoxFilter 1 1)
(RiWorldBegin)
(RiLightSource "ambientlight" (list "intensity" 0.1))
(RiLightSource "spotlight" (list "intensity" 10 "from" (Point 0 4 0)
"to" (Point 0 0 0 )
"coneangle" 0.45
"conedeltaangle" 0.05))
(RiAttributeBegin)
(RiColor (Color 1.0 0 0))
(RiSurface "plastic")
(RiTransformBegin)
(RiSphere 1 -1 1 360)
(RiTransformEnd)
(RiTransformBegin)
(RiColor (Color 0 1 0))
(RiSurface "matte")
(RiRotate -90 1 0 0)
(RiDisk -0.5 5 360)
;;(RiPatch "bilinear" (list "P" #f32(-5 -1 -5 5 -1 -5 -5 -1 5 5 -1 5)))
(RiTransformEnd)
(RiAttributeEnd)
(RiWorldEnd)
(RiEnd)

2 shadowmapを生成する


makeshadow.scmで保存

#!/usr/bin/guile -s
!#

(use-modules (rman rispec))
(use-modules (rman utilities))

(RiBegin "makeshadow.rib")
(RiHider "hidden" (list "string depthfilter" "midpoint"))
(RiDisplay "zbuffer.zfile" "zfile" "z")
(RiFormat 512 512 1)
(RiProjection "perspective" '("fov" 40))
(RiTranslate 0 0 4)
(RiRotate -90 1 0 0)
(RiWorldBegin)
(RiAttributeBegin)
(RiColor (Color 1.0 0 0))

(RiTransformBegin)
(RiSphere 1 -1 1 360)
(RiTransformEnd)
(RiTransformBegin)
(RiColor (Color 0 1 0))

(RiRotate -90 1 0 0)

(RiDisk -0.5 5 360)
(RiTransformEnd)
(RiAttributeEnd)
(RiWorldEnd)
(RiMakeShadow "zbuffer.zfile" "map.shad")
(RiEnd)


3 影つき


withshadow.scmで保存

#!/usr/bin/guile -s
!#

(use-modules (rman rispec))
(use-modules (rman utilities))

(RiBegin "withshadow.rib")
(RiHider "hidden" (list "string depthfilter" "midpoint"))
(RiDisplay "witshadow.tif" "file" "rgb")
(RiFormat 640 480 1)
(RiProjection "perspective" '("fov" 30))
(RiTranslate 0 0 6)
(RiRotate -48 1 0 0)
(RiRotate -20 0 1 0)
(RiPixelFilter RiBoxFilter 1 1)
(RiWorldBegin)
(RiLightSource "ambientlight" (list "intensity" 0.1))
(RiLightSource "shadowspot" (list "string shadowname" "map.shad" "intensity" 10
"from" (Point 0 4 0)
"to" (Point 0 0 0 )
"coneangle" 0.45
"conedeltaangle" 0.05))
(RiAttributeBegin)
(RiColor (Color 1.0 0 0))
(RiSurface "plastic")
(RiTransformBegin)
(RiSphere 1 -1 1 360)
(RiTransformEnd)
(RiTransformBegin)
(RiColor (Color 0 1 0))
(RiSurface "matte")
(RiRotate -90 1 0 0)
(RiDisk -0.5 5 360)
(RiTransformEnd)
(RiAttributeEnd)
(RiWorldEnd)
(RiEnd)

CentOS6.3 64bitで動作確認。
CentOS X86_64でswig2.0.11、guile2.0.9、guile-lib0.2.2をmake install、guile-rmanもmake installしaqsis1.6でレンダリングできました。rib出力はRifGetDeclarationで不可。
ありがとうございます。
  • -
  • -

Guile RMan #3 RiPolygon and RiPoints

guile-rmanでのRiPolygonの表記がわかりました。RiPointsもわかりましたが"width"設定がわからないところ。
rect.jpg
以下はサンプルです。points.scmで保存しました。

#!/usr/bin/guile -s
!#

(use-modules (rman rispec))
(use-modules (rman utilities))

(RiBegin "points.rib")
(RiDisplay "points.tif" "file" "rgb")
(RiFormat 640 480 1)
(RiProjection "perspective" '("fov" 30))
(RiTranslate 0 0 3)
; (RiProgressHandler progress)
(RiPixelFilter RiBoxFilter 1 1)
(RiWorldBegin)
(RiLightSource "ambientlight" (list "intensity" 0.2))
(RiLightSource "distantlight" (list "intensity" 1.2 ))
(RiAttributeBegin)
(RiColor (Color 1 0 0))
(RiSurface "plastic")
(RiTransformBegin)
(RiTranslate -0.5 -0.5 0)
;;(RiRotate -90 1 0 0)
;;(RiDisk 0 0.5 270)
;;(RiCone 1 0.5 150)
;;(RiCone 1.5 0.5 360)
(RiPolygon 4 (list "P" #f32(0 0 0 0 1 0 1 1 0 1 0 0)))
;;(RiPoints 4 (list "P" #f32(0 0 0 0 1 0 1 1 0 1 0 0) "width" 0.25)) ;;"Cs" #f32(1 0 0 0 1 0 0 0 1 1 1 0) "width" #f32(0.25 0.25 0.25 0.25)
(RiTransformEnd)
(RiAttributeEnd)
(RiWorldEnd)
(RiEnd)


(RiPoints 1 (list "P" #f32(0 0 0)))
で原点に点を表示します。
points.jpg
  • -
  • -

Guile RMan #4 RiPoints

guile-rmanでのRiPointsでは"constantwidth"を使う。ありがとうございます。
points4.jpg

#!/usr/bin/guile -s
!#

(use-modules (rman rispec))
(use-modules (rman utilities))

(RiBegin "points4.rib")
(RiDisplay "points4.tif" "file" "rgb")
(RiFormat 640 480 1)
(RiProjection "perspective" '("fov" 30))
(RiTranslate 0 0 3)
(RiPixelFilter RiBoxFilter 1 1)
(RiWorldBegin)
(RiLightSource "ambientlight" (list "intensity" 0.2))
(RiLightSource "distantlight" (list "intensity" 1.2 ))
(RiAttributeBegin)
(RiColor (Color 1 0 0))
(RiSurface "plastic")
(RiTransformBegin)
(RiTranslate -0.5 -0.5 0)
(RiPoints 4 (list "P" #f32(0 0 0 0 1 0 1 1 0 1 0 0) "constantwidth" 0.4))
(RiTransformEnd)
(RiAttributeEnd)
(RiWorldEnd)
(RiEnd)

  • -
  • -

Guile RMan #5 RtLightHandle

やっと、わかりました。PixarのRenderMan C Bindingにヒントがありました。bulb.cを参考にしました。ありがとうございます。
guile-rmanでのRtLightHandleの記述例:

(define light2 (RiLightSource "distantlight" (list "intensity" 1.2 )))
(RiIlluminate light2 0 )

LightID、"light2"をRiIlluminateでオフ(0)にしています。
以下は、サンプルilluminate.scm
ambientlightのみの灯りになっています。

#!/usr/bin/guile -s
!#

(use-modules (rman rispec))
(use-modules (rman utilities))

(RiBegin "illum.rib")
(RiDisplay "illum.tif" "file" "rgb")
(RiFormat 640 480 1)
(RiProjection "perspective" '("fov" 30))
(RiTranslate 0 0 5)
; (RiProgressHandler progress)
(RiPixelFilter RiBoxFilter 1 1)
(RiWorldBegin)
(display (RiLightSource "ambientlight" (list "intensity" 0.2)))
(newline)
(define light2 (RiLightSource "distantlight" (list "intensity" 1.2 )))
(newline)
(RiIlluminate light2 0 )
(RiAttributeBegin)
(RiColor (Color 1.0 0.6 0.0))
(RiSurface "plastic")
(RiTransformBegin)
(RiRotate 90 1 0 0)
(RiSphere 1 -1 1 360)
(RiTransformEnd)
(RiAttributeEnd)
(RiWorldEnd)
(RiEnd)

  • -
  • -

Guile RMan #6 ShadowMap part 2

illum3.jpg

FramBegin〜Endを使ってAqsisサンプルのSoftshadowをguile-rmanで生成してみました。

#!/usr/bin/guile -s
!#
(use-modules (rman rispec))
(use-modules (rman utilities))

(RiBegin "illum3.rib")
;;(RiOption "limits" (list "bucketsize" #f32(32 32)))
(RiOption "limits" (list "eyesplits" 10))
(RiDeclare "bias" "float")
(RiHider "hidden" (list "depthfilter" "midpoint"))
(RiDisplay "softshadow.zfile" "zfile" "z")
(RiClipping 0.01 10)
(RiSides 2)
(RiFormat 512 512 1)
(RiPixelFilter RiBoxFilter 2 2)
(RiPixelSamples 1 1)
(RiShadingRate 2)

(RiFrameBegin 1)
(RiProjection "perspective" '("fov" 57.30))
(RiRotate -35.26 1.00 0.00 0.00)
(RiRotate 45.00 0.00 1.00 0.00)
(RiTranslate -5.00 -5.00 5.00)

(RiWorldBegin)
(RiSurface "null")
(RiSphere 1 -1 1 360)
(RiWorldEnd)
(RiFrameEnd)

(RiMakeShadow "softshadow.zfile" "softshadow.shad")


(RiDisplay "illum3.tif" "file" "rgba")
(RiFormat 512 384 1)

(RiPixelFilter RiGaussianFilter 2 2)
(RiPixelSamples 2 2)
(RiClipping 0.2 10)
(RiShadingRate 1)
(RiFrameBegin 2)

(RiProjection "perspective" '("fov" 45))
(RiTranslate 0 0 5)
(RiRotate -25 1 0 0)

(RiWorldBegin)
(RiLightSource "ambientlight" (list "intensity" 0.2))
(RiLightSource "shadowspot" (list "intensity" 80
"from" (Point 5 5 -5)
"to" (Point 0 0 0)
"coneangle" 0.5
"float blur" 0.03
"string shadowname" "softshadow.shad"))

(RiColor (Color 0.4 0.4 0.1))
(RiSurface "matte")
(RiSphere 1 -1 1 360)

(RiOrientation "rh")
(RiColor (Color 0.5 0 0))
(RiSurface "matte")
(RiPatch "bilinear" (list "P" #f32(-10 -1 -10
10 -1 -10
-10 -1 10
10 -1 10)))
(RiWorldEnd)
(RiFrameEnd)
(RiEnd)


Max eyesplits for object "unnamed" exceeded
Object "unnamed" spans the epsilon plane
Object "unnamed" spans the epsilon plane
Max eyesplits for object "unnamed" exceeded
Object "unnamed" spans the epsilon plane
Max eyesplits for object "unnamed" exceeded
が出ますがレンダリングできました。
  • -
  • -

Guile RMan #7 AutoShadow

Aqsis1.6では、
Attribute "autoshadows" "string shadowmapname" ["autoshadow.shad"] "integer res" [600]
を利用して、影の自動生成を行います。

これと、もう一つ
Option "Render" "integer multipass" [1]
がないと、シャドウマップは生成されません。

simple3.jpg
以下、Aqsis1.6.0のサンプルautoshadow.ribを参考にしました。

#!/usr/bin/guile -s
!#
(use-modules (rman rispec))
(use-modules (rman utilities))

(RiBegin "illum2.rib")
(RiOption "Render" (list "integer multipass" 1))
(RiHider "hidden" (list "depthfilter" "midpoint"))
(RiDisplay "illum2.tif" "file" "rgb")
(RiFormat 512 384 1)
(RiProjection "perspective" '("fov" 30))
(RiTranslate 0 0 3)
(RiRotate -40 1 0 0)
(RiRotate -20 0 1 0)
(RiPixelFilter RiGaussianFilter 2 2)
(RiWorldBegin)
(RiLightSource "ambientlight" (list "intensity" 0.3))
(RiAttributeBegin)
(RiAttribute "autoshadows" (list "string shadowmapname" "autoshadow.shad" "integer res" 4096))
(RiTranslate 5 5 -5)
(RiRotate -45 0.0 1.0 0.0)
(RiRotate 35 1.0 0.0 0.0)
(define light1 (RiLightSource "shadowspot" (list "intensity" 300
"coneangle" 0.5
"string shadowname" "autoshadow.shad"
)))
(RiAttributeEnd)
(RiIlluminate light1 1 )
(RiAttributeBegin)

(RiTransformBegin)
(RiColor (Color 0.8 0.8 0.8))
(RiSurface "plastic")
(RiPolygon 4 (list "P" #f32(-1 0 -1 -1 0 1 1 0 1 1 0 -1)))
(RiTransformEnd)

(RiTransformBegin)
(RiColor (Color 0.8 0.4 0.2))
(RiSurface "plastic")
(RiRotate -90 1 0 0)

(RiScale 0.2 0.2 0.2)
(RiGeometry "teapot")
(RiTransformEnd)

(RiAttributeEnd)
(RiWorldEnd)
(RiEnd)



"integer res" 1024
"float blur" 0.008
と調整してみた。

(RiAttributeBegin)
(RiAttribute "autoshadows" (list "string shadowmapname" "autoshadow.shad" "integer res" 1024))
(RiTranslate 5 5 -5)
(RiRotate -45 0.0 1.0 0.0)
(RiRotate 35 1.0 0.0 0.0)
(define light1 (RiLightSource "shadowspot" (list "intensity" 300
"coneangle" 0.5
"float blur" 0.008
"string shadowname" "autoshadow.shad"
)))
(RiAttributeEnd)


illum3.jpg
  • -
  • -

Guile RMan #8 くりかえし処理その1

関数を定義し、繰り返し処理を行いました。
sphere6.jpg
いろいろできそうです。

#!/usr/bin/guile -s
!#

(use-modules (rman rispec))
(use-modules (rman utilities))

(RiBegin "test6.rib")
(RiDisplay "sphere6.tif" "file" "rgb")
(RiFormat 640 480 1)
(RiProjection "perspective" '("fov" 40.0))
(RiTranslate 0 0 6)
(RiPixelFilter RiBoxFilter 1 1)
(RiWorldBegin)
(RiLightSource "ambientlight" (list "intensity" 0.2))
(RiLightSource "distantlight" (list "intensity" 1.2
"uniform point from" (Point 3 3 -3)))

(define (test x)
(define posx -3)
(let ((n 0))
(while (< n x)
(RiTransformBegin)
(set! posx (+ posx 1 ))
(RiTranslate posx 0 0 )
(RiColor (Color .9 .1 .1))
(RiSurface "plastic")
(RiSphere 0.5 -0.5 0.5 360)
(set! n (+ n 1))
(RiTransformEnd)
)))

(test 5)

(RiWorldEnd)
(RiEnd)



(use-modules (rman ri2rib))
を使うと空のRIBが出るだけで、課題です。
以下、エラー。
guile: symbol lookup error: /usr/local/lib/libguile_rman_ri2rib.so: undefined symbol: RifGetDeclaration
  • -
  • -

Guile RMan #9 くりかえし処理その2

球体の色を徐々に変化させてみた。
guile-rmanとAqsis1.6 (CentOS6.4 64bitで稼働。)
sphere70.jpg

#!/usr/bin/guile -s
!#

(use-modules (rman rispec))
(use-modules (rman utilities))

(RiBegin "test7.rib")
(RiDisplay "sphere7.tif" "file" "rgb")
(RiFormat 640 480 1)
(RiProjection "perspective" '("fov" 40.0))
(RiTranslate 0 0 6)
(RiPixelFilter RiBoxFilter 1 1)
(RiWorldBegin)
(RiLightSource "ambientlight" (list "intensity" 0.2))
(RiLightSource "distantlight" (list "intensity" 1.2
"uniform point from" (Point 3 3 -3)))

(define (test x)
(define posx -3)
(define col 0.2)
(define col2 0.9)
(let ((n 0))
(while (< n x)
(RiTransformBegin)
(set! posx (+ posx 1 ))
(RiTranslate posx 0 0 )
(set! col (+ col .2))
(set! col2 (- col2 .2))
(RiColor (Color col .2 col2))
(RiSurface "plastic")
(RiSphere 0.5 -0.5 0.5 360)
(set! n (+ n 1))
(RiTransformEnd)
)))

(test 5)

(RiWorldEnd)
(RiEnd)

  • -
  • -

Guile RMan #10 くりかえし処理その3

guileで乱数を発生させた。毎回変化させるには、
(set! *random-state* (random-state-from-platform))
を記述しておいた。
(RiColor (Color (random 1.0) (random 1.0) (random 1.0)))
たぶん、0から1までの乱数と思われる。
sphere7r.jpg
sphere7r2.jpg

#!/usr/bin/guile -s
!#

(use-modules (rman rispec))
(use-modules (rman utilities))

(RiBegin "test7.rib")
(RiDisplay "sphere7.tif" "file" "rgb")
(RiFormat 640 480 1)
(RiProjection "perspective" '("fov" 40.0))
(RiTranslate 0 0 6)
(RiPixelFilter RiBoxFilter 1 1)
(RiWorldBegin)
(RiLightSource "ambientlight" (list "intensity" 0.2))
(RiLightSource "distantlight" (list "intensity" 1.2
"uniform point from" (Point 3 3 -3)))

(define (test x)
(define posx -3)
(set! *random-state* (random-state-from-platform))
(let ((n 0))
(while (< n x)
(RiTransformBegin)
(set! posx (+ posx 1 ))
(RiTranslate posx 0 0 )
(RiColor (Color (random 1.0) (random 1.0) (random 1.0)))
(RiSurface "plastic")
(RiSphere 0.5 -0.5 0.5 360)
(set! n (+ n 1))
(RiTransformEnd)
)))

(test 5)

(RiWorldEnd)
(RiEnd)

  • -
  • -

1/2 >>