RIB ファイルの文法と機能
【概要】
RIB ファイルとは,RenderMan で使われるシーン記述ファイルである.このページでは,RIB ファイルにおけるプリミティブ(球などの要素)の記述やカメラの指定などについて,基本的な文法と機能を説明する.記載の RIB ファイルは,RenderMan 互換のレンダラーである aqsis で確認済みである.
【目次】
【関連する外部ページ】
- RenderMan のマニュアル: https://rmanwiki.pixar.com/
簡単な RIB ファイルの作成とテスト
RIB ファイルを作成する.ファイル名は何でもよいが,以下の説明では sample.rib とする.
- sample.rib の作成
Display "sample.tiff" "file" "rgba" Display "+sample.tiff" "framebuffer" "rgb" Format 800 600 1 Projection "perspective" "fov" [60] WorldBegin Translate 0 0 2 Color 0.2 0.4 1 Sphere 1 -1 1 360 WorldEnd - 描画(レンダリング)の実行
コマンドプロンプト(またはコンソール)で aqsis を実行し,sample.rib を描画する.
aqsis -progress sample.rib
- 実行結果の確認
下記のように表示されるので確認する.
RIB ファイルの入門
上記の「簡単な RIB ファイル」に関係する文法と機能を説明する.
レンダリングに関する指定
- Display <ファイル名> <出力方法> <データの種類>
- 出力方法: file または framebuffer
- データの種類: 「rgba」は「R, G, B, 不透明度」の意味
- Format <横方向の画素数> <縦方向の画素数> <画素の縦横比>
第 1 引数が横方向の画素数(幅),第 2 引数が縦方向の画素数(高さ),第 3 引数が画素の縦横比(ピクセルアスペクト比)である.
カメラに関する指定
- Projection <投影方法> ...
投影方法には perspective(透視投影)と orthographic(正射影)がある.
perspective の場合,「"fov" [60]」を付けると視野角 60 度になる(視野角は 0 から 180 の範囲で指定できる).
- カメラの位置は,デフォルトでは世界座標系の原点にあり,向きは (0, 0, 1) である.
モデルに関する指定
- WorldBegin, WorldEnd
シーンの記述を囲む.
- Sphere <球の半径> <zの下限> <zの上限> <描画範囲の角度>
半径のあと,zmin(z 方向の下限)と zmax(z 方向の上限)で球を z 軸方向に切り取る.最後が描画範囲の角度(thetamax)である.
- Color <r> <g> <b>
表面色の r, g, b 成分.0 から 1 の値をとる.
- Translate <x> <y> <z>
モデルを世界座標系の (x, y, z) に平行移動する.
種々のプリミティブを含む RIB ファイル
Display "sample.tiff" "file" "rgba"
Display "+sample.tiff" "framebuffer" "rgb"
Format 800 600 1
Projection "perspective" "fov" [60]
WorldBegin
LightSource "ambientlight" 0.2 "intensity" .8
Translate 0 0 6
Rotate -90 1 0 0
## A sphere
Color 1 0 0
Translate -2 0 1
Sphere 0.5 -0.5 0.5 360
## A cone
Color 0 1 0
Translate 2 0 -1
Cone 1 0.5 360
## A cylinder
Color 0 0 1
Translate 2 0 1
Cylinder 0.5 -0.5 0.5 360
## A hyperboloid
Color 1 1 0
Translate -4 0 -2
Hyperboloid 0.4 -0.4 -0.4 0.4 0.4 0.4 360
## A paraboloid
Color 1 0 1
Translate 2 0 -1
Paraboloid 0.5 0 0.9 360
## A torus
Color 0 1 1
Translate 2 0 1
Torus .4 .15 0 360 360
## A disk
Color 0 1 0
Translate -2 0 3
Disk 0 .5 360
WorldEnd
表示は下記のようになる.