Thursday, July 30, 2009

Structure SynthとSunflowでミラーの立方体を描画する

Structure SynthとSunflowでミラーの立方体を描画するには、以下のスクリプトを実行します。

// 黄色っぽい立方体
{ z 3 y 1 s 2 color #d0c040 } box
// 水色っぽい立方体
{ x -3 y 1 s 2 color #7799ff } box
//ミラーの立方体
{ y 1 s 2 } box::mirror
// 白色の立方体
{ x 3 y 1 s 2 color #ffffff } box
// 明るい灰色の地面
{ y -1 s 200 0.1 200 color lightgray } box

次に、Structure SynthでSunflowにエクスポートする時に以下のテンプレートファイルを使用します。


<template defaultExtension="Sunflow scene file (*.sc)" name="Sunflow" runAfter="%SUNFLOW%\sunflow.bat "$FILE" -o "$FILE.png"" >
<description>
glass template.

Original template by Syntopia.
The Sunflow coloring was added by Tom Beddard ('subblue')
</description>
<primitive name="begin" ><![CDATA[
%photons {
% caustics 10000000 kd 64 0.5
%}
%% common settings
image {
resolution {width} {height}
aa 0 2
}

gi {
type ambocc
bright { "sRGB nonlinear" 1 1 1 }
dark { "sRGB nonlinear" 0 0 0 }
samples 64
maxdist 3.0
}

accel bih
filter mitchell
bucket 32 spiral

%% camera
camera {
type pinhole
eye {CamPosX} {CamPosY} {CamPosZ}
target {CamTargetX} {CamTargetY} {CamTargetZ}
up {CamUpX} {CamUpY} {CamUpZ}
fov {fov}
aspect {aspect}
}


%% scene background - comment out if not needed
background {
% color { "sRGB nonlinear" {BR} {BG} {BB} }
color { "sRGB nonlinear" 0.5 0.6 0.8 }
}


%% geometry
object {
shader none
transform col 0.001 0 0 0 0 0.001 0 0 0 0 0.001 0 0 0 0 1
type generic-mesh
name "Box"
points 8
1 1 1
1 0 1
0 0 1
0 1 1
0 1 0
0 0 0
1 0 0
1 1 0

triangles 12
0 3 2
0 2 1
2 3 4
2 4 5
3 0 7
3 7 4
0 1 6
0 6 7
1 2 5
1 5 6
5 4 7
5 7 6
normals none
uvs none
}
]]></primitive>
<primitive name="end" ><![CDATA[

]]></primitive>
<primitive name="box" ><![CDATA[
shader {
name "shader{uid}"
type diffuse
diff { "sRGB nonlinear" {r} {g} {b} }
}

instance {
name "{uid}"
geometry "Box"
transform col {matrix}
shader "shader{uid}"
}
]]></primitive>
<primitive name="box" type="mirror">
<![CDATA[
shader {
name "shader{uid}"
type mirror
refl { "sRGB nonlinear" 0.800 0.800 0.800 }
}
instance {
name "{uid}"
geometry "Box"
transform col {matrix}
shader "shader{uid}"
}
]]>
</primitive>
<primitive name="sphere" ><![CDATA[
shader {
name "shader{uid}"
type diffuse
diff { "sRGB nonlinear" {r} {g} {b} }
}

object {
shader "shader{uid}"
type sphere
c {cx} {cy} {cz}
r {rad}
}
]]></primitive>

</template>


Sunflowでの出力画像

No comments:

Post a Comment