Rendering学習日記

日々、3DCGの世界は進歩しています。勉強して理解したことをまとめていきます。RenderMan互換レンダラーやグローバル・イルミネーション。いろんなことに好奇心を持って、面白くなる。目指せShader書き!!
ありがとうございます。

MacRenderManへの出力

Presenter3Dへ3DMF形式で作ったモデルをインポートしてみた。
変換には、LilyEightを利用。
しかしながらPresenter3Dで出力したShadowMap生成が今ひとつ、
原因がつかめなくていろいろと実験してみた。

影がうまく出てこない。
model1_9.JPG

原因は
    ShadowPass部分の最初のProjection "orthographic"となっているところを"perspective" "fov" 35とイメージ生成と同じにした。

    Option "shadow" "bias0" [0.018]など2行を#でコメントアウトした。

model1_91.JPG

■当初はshadowdistantを外して、shadowspotに変更して、レンダリングしてみた。
model1_92.JPG

しかしながら、モアレがひどい。シャドーマップ生成の解像度をあげてみた。
model1_92.0002.JPG

まだ、出てしまうので4096×4096まであげてみた。
model1_92.4096.JPG
これでも、何か変だった。
原因を探ってみたら、RIB内のOption "shadow" "bias0"の記述をコメントアウトしていなかったためだ。

やっときれいにできたところだ。MacRenderMan面白いです。
model1_923.JPG
Presenter3Dでいろいろ設定し、いじって、出力したRIBをさらにカスタマイズしていくのは大変ですが、出来上がる画像がよくなっていくのが楽しいです。Windowsマシンでレンダリングした方が速いですね。
ありがとうございます。
  • -
  • -

MacRenderManでShaderをコンパイル

googleコードだったか、PythonではしるShaderManで作成したシェーダをMacRenderManのShaderAppでコンパイルしようとしてみた。変数の宣言で難あり、書き換えたらなんとかコンパイルでき、レンダリングもできました。
gari.JPG

シェーダはこちら。
surface garigari (float Km = 1;)
{
point Nf1,Nf6;
color Id6,Itr6;
point PP1,temp_PP2;
float temp_f2;

Nf6 = faceforward( normalize(N), I );
Id6 = 0.8 * diffuse(Nf6);

Itr6 = 0;
if (0 != 0) {
illuminance(P, Nf6, PI)
Itr6 += Cl;
Itr6 *= 0;
}

temp_PP2 = (point(0.0,0.0,0.0) == point(0.0,0.0,0.0)) ? P : point(0.0,0.0
,0.0);
temp_PP2=transform("shader", temp_PP2);
temp_f2 = 2.0*noise(temp_PP2*10)-1.0;


PP1 = P;

Nf1 = normalize( ntransform("shader", N) );
PP1 += vtransform("shader", "current", Km * temp_f2 * vector Nf1);
N = calculatenormal(PP1);
P = PP1;

Ci = (color(0,0.5,1) * (Id6 + Itr6 + color(0,0,0))+temp_f2)+0;
Oi = 1;
}


こちらで実験してみた。レンダリング用のRIB。MacOS8.6、G3の300MHzで36秒でした。
#Option "searchpath" "shader" "@:c:/cutter/RmanNotes/"
Display "gari.tif" "file" "rgb"
#Display "gari" "framebuffer" "rgb"
Projection "perspective" "fov" 90
Format 640 480 1
PixelSamples 2 2
ShadingRate 0.5
#PixelFilter "box" 1 1

Translate 0 0 3.5

WorldBegin
LightSource "ambientlight" 1 "intensity" [0.2]
LightSource "distantlight" 2 "from" [1 1 -2] "to" [0 0 0] "intensity" [2]
Color 0.2 0.4 0.6

#Surface "likemouse3" "float repeatC" 20 "float fuzz" 0.0 "color layer_color" [1 0 0]
#Surface "kinta3" "float repeatC" 16 "color layer_color2" [1 0 1]
Attribute "displacementbound" "sphere" [0.8] "coordinatesystem" ["shader"]
Surface "garigari" "float Km" 0.8
#Polygon "P" [-2 2 0 -2 -2 0 2 -2 0 2 2 0] "st" [0 0 0 1 1 1 1 0]
#Rotate 90 1 0 0
Sphere 2 -2 2 360

WorldEnd
  • -
  • -

Reflectシェーダよる環境マッピング

サンプルとして練習。
シェーダは次の通り
surface reflect (
float Ka = 1;
float Kd = .5;
float Ks = .4;
float Kr = .3;
float roughness = .1;
color specularcolor = 1;)
{
normal Nf = faceforward (normalize(N),I);
vector V = -normalize(I);
color Ct;
vector Rcurrent=reflect(I,Nf);
vector Rworld=vtransform("world",Rcurrent);
color Cr=color environment("envlati.tx",Rworld);

Ct=Cs;

Oi = Os;
Ci = Oi * ( Ct * (Ka*ambient() + Kd*diffuse(Nf)) +
specularcolor * (Ks*specular(Nf,V,roughness)+Kr*Cr));
}


RIBは次の通り
MakeLatLongEnvironment "studio2.tif" "envlati.tx" "gaussian" 2 2


Display "reflect3.tiff" "file" "rgb"
Display "+teapot" "framebuffer" "rgb"
Format 640 400 1.0
Projection "perspective" "fov" 25

Translate 0 0 5

WorldBegin
#Translate -10 -45 0

Rotate -115 1 0 0

LightSource "ambientlight" 1 "intensity" .4
LightSource "distantlight" 2 "intensity" 0.4
"from" [-50 300 200] "to" [0 0 0]
LightSource "distantlight" 2 "intensity" 0.2
"from" [-50 -300 200] "to" [0 0 0]
LightSource "distantlight" 2 "intensity" 0.1
"from" [50 -200 10] "to" [0 0 0]

Color [1 1 1]

Surface "reflect"

Sphere 1 -1 1 360

WorldEnd


PRMan
reflect3.jpg

MacRenderManではシェーダの変数の宣言部分を書き直す。
mac_reflect.JPG

そしてAqsisでは、フィルターがかかっているようである。
aqsis_ref.jpg

環境マップ
Essential RenderManのサンプルを利用しました。Thank you
studio2.jpg
  • -
  • -
<< 5/8 >>