まずはレンダリング
下記より、スタンドアロンとAPI SDKをダウンロードする。
https://luxcorerender.org/download/
それぞれ適当なフォルダに展開する(私の場合Cドライブ直下に置いた)。スタンドアロンのフォルダにある、luxcoreui.exe を実行する。出てきたウインドウのRendering→Loadを選択して、SDKのフォルダにあるscenesの下にあるフォルダの中から、適当なcfgファイルを選択すると、レンダリングが開始する。下の画像は、scenes/simple/simple.cfgを選択した場合の画像である。
最初ノイズまみれな画像から、だんだんときれいになっていく様子を見ることができる。ずっとレンダリングし続けるので、止める場合は、Rendering→Pauseを選択する。再開するときは、Rendering→Resumeを押す。
上のウインドウとは別で表示されているコンソールに、以下のようなものが出力され続けるのだが、どうやら処理を進めることで、ノイズが少なくなるということらしい。
[LuxCore][31.734] Noise estimation: first pass
[LuxCore][59.578] Noise estimation: Error mean = 0.00993405
[LuxCore][101.531] Noise estimation: Error mean = 0.00612393
[LuxCore][142.218] Noise estimation: Error mean = 0.00357345
[LuxCore][180.250] Noise estimation: Error mean = 0.00257599
[LuxCore][218.015] Noise estimation: Error mean = 0.00201924
[LuxCore][258.171] Noise estimation: Error mean = 0.00166048
[LuxCore][301.125] Noise estimation: Error mean = 0.00140384
[LuxCore][339.734] Noise estimation: Error mean = 0.00122527
[LuxCore][392.468] Noise estimation: Error mean = 0.00107869
[LuxCore][443.921] Noise estimation: Error mean = 0.000969824
[LuxCore][492.109] Noise estimation: Error mean = 0.000874877
[LuxCore][548.437] Noise estimation: Error mean = 0.000794381
[LuxCore][595.328] Noise estimation: Error mean = 0.000731777
[LuxCore][647.078] Noise estimation: Error mean = 0.00068362
LuxCoreRenderがレンダリングするのに必要なファイルは下記となる。
コンフィグファイル(.cfg):レンダリング設定と、シーンファイルのパスが記載されている。
シーンファイル(.scn):カメラや物体の材質などの設定、ポリゴンデータのパスが記載されている
ポリゴンファイル(.ply):Polygon file format。物体の形状のデータ。フォーマットについては、次のURLで説明されている。http://paulbourke.net/dataformats/ply/
以下、scenes/simpleの中身を見ていく。
コンフィグファイル(simple.cfg)
scene.file = scenes/simple/simple.scn
film.width = 640
film.height = 480
film.imagepipeline.0.type = TONEMAP_LINEAR
film.imagepipeline.1.type = GAMMA_CORRECTION
film.imagepipeline.1.value = 2.2
まず、読み込むシーンファイルを指定して、そのあとfilmの設定をしている。このfilmというのは、文字通りカメラのフィルムのようなもので、最終的な出力画像についてのパラメータを設定している。上記では、画像の幅と高さ、image pipelineとよばれる画像フィルタのようなものの設定をしている。上の場合だと、imagepipline.0に、トーンマッピング(画像のダイナミックレンジを調整する)、imagepipline.1に、ガンマ補正値を2.2にする処理(画像のコントラストをディスプレイに合わせる)を設定している。
シーンファイル(simple.scn)
scene.camera.lookat.orig = 10.951 -20.663 8.017
scene.camera.lookat.target = 0.0 0.0 1.0
カメラの設定をしている。origがカメラ位置で、targetが視点が向く座標(POV-Rayでいうところのlocationとloot_atに相当する)。
scene.materials.whitematte.type = matte
scene.materials.whitematte.kd = 0.75 0.75 0.75
scene.materials.redmatte.type = matte
scene.materials.redmatte.kd = 0.75 0.0 0.0
scene.materials.blumatte.type = matte
scene.materials.blumatte.kd = 0.0 0.0 0.75
scene.materials.greenmatte.type = matte
scene.materials.greenmatte.kd = 0.0 0.57 0.0
材質の設定をしている。マットで、kd(拡散する色の指定)のrgbを指定している。
scene.materials.whitelight.type = matte
scene.materials.whitelight.emission = 120.0 120.0 120.0
scene.materials.whitelight.emission.id = 0
scene.materials.whitelight.kd = 0.0 0.0 0.0
材質設定で、光源の設定をしている。すべての物体は、光を放射することができる。emissionで光の色を指定している(同時に強度を指定できるみたい)。idは、ライトグループを設定するもの(これが何かはまだ理解していない)。
scene.shapes.shape_box2.type = mesh
scene.shapes.shape_box2.ply = scenes/simple/simple-mat-cube2.ply
shapesの設定。shape_box2という形状データを設定している。このデータは、下のbox2の定義で使用している。
scene.objects.lightplanes.ply = scenes/simple/simple-lights.ply
scene.objects.lightplanes.material = whitelight
scene.objects.box1.ply = scenes/simple/simple-mat-cube1.ply
scene.objects.box1.material = redmatte
scene.objects.box2.shape = shape_box2
scene.objects.box2.material = greenmatte
scene.objects.box2.transformation = 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1
scene.objects.box3.ply = scenes/simple/simple-mat-back2.ply
scene.objects.box3.material = blumatte
scene.objects.box4.ply = scenes/simple/simple-mat-back.ply
scene.objects.box4.material = whitematte
ポリゴンデータを設定し、材質を紐づけする。直接plyファイルを指定している場合と、先に定義していた形状データ(shape_box2)を指定している場合がある。box2のみ、transformationを指定しているが、意図は不明。
transformationで指定しているのは、4x4の行列で、これ一つで平行移動、回転、スケーリングを行うことができる。4x4行列を使った変形については、次のURLが詳しい。
http://www.opengl-tutorial.org/jp/beginners-tutorials/tutorial-3-matrices/
上の例では、単位行列なので、特に何もしない。
ポリゴンファイル(*.ply)
物体の形状を定義するには、plyファイルを作成しなければならない。plyファイルは、頂点座標、頂点の法線ベクトル、色情報を含むvertex(頂点)データと、ポリゴンとなるface(面)で構成される。plyファイルの中身を見るのに、MeshLabというツールを使った。simple-mat-cube1.plyを開いてみると、下図のように、三角形ポリゴンが表示され、各頂点から法線ベクトル(青い細い線)が出ていることが分かる。頂点の法線ベクトルから、面の法線ベクトルも計算されているようだ。
通常、plyファイルを作るのに、Blenderのようなツールを使う必要がある。ただ、この部分については、計算で出力したい思惑があり(たとえばレンズを計算によって形状生成したい)、plyファイルを生成する方法を考えようと思う。
コメント
コメントを投稿