Rendering学習日記

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

面法線と頂点法線 その5

出力したRIBの調整。
場合によっては、コンバータで出力した面が裏向きなっていて、いくらライトのintensityをあげても明るくならなかったり、plasticなどのシェーダを入れておかないといけませんが、記述していないと明るくなりません。裏向きの場合、Scale 1 1 -1とWorldBeginの前に記入してみて実験してみるとわかります。

以下は、メタセコイアから出力した面。plasticシェーダを割り当てているので、ライトが強いとハイライトができます。
##RenderMan RIB-Structure 1.0
version 3.03
Format 512 300 1
PixelSamples 3 3
ShadingRate 1
Display "test_men2.tif" "file" "rgb"
Projection "perspective" "fov" 5.963
ConcatTransform [
0.423401210556 -0.592993260602 -0.684901750458 0
0 0.756010361246 -0.654559648686 0
-0.905942280115 -0.277141347635 -0.320095702145 0
-4.13227435274e-005 5.57033550876e-005 1499.99997798 1
]

WorldBegin
LightSource "ambientlight" 0 "intensity" [ 0.8 ] "lightcolor" [ 1 1 1 ]
LightSource "distantlight" 1 "intensity" [ 3 ] "lightcolor" [ 1 1 1 ] "from" [ -1 1 -1 ] "to" [ 0 0 0 ]
LightSource "distantlight" 2 "intensity" [ 0.8 ] "lightcolor" [ 1 1 1 ] "from" [ 1 1 2.5 ] "to" [ 0 0 0 ]

AttributeBegin
Attribute "identifier" "name" ["obj1"]
Color [1 0 0]
Surface "plastic"
PointsPolygons [ 3 3 3 3 ] [ 0 1 2 0 2 3 4 5 0 4 0 3 ]
"P" [
50 20 0
50 0 -100
-50 0 -100
-50 20 -0
-50 0 100
50 0 100
]
"N" [ 0 1 0
0 0.980581 -0.196116
0 0.980581 -0.196116
0 1 0
0 0.980581 0.196116
0 0.980581 0.196116 ] "st" [ 1 0 1 1 0 1 1 0 0 1 0 0 ]

AttributeEnd

WorldEnd

test_men2.jpg
  • -
  • -

面法線と頂点法線 その6

metared(mqo2rib)で変換したものを調整した。頂点法線が多いので削除。
勉強します。
3Delightでレンダリングした。

モデルデータ
##Renderman RIB-Structure 1.0
## filename: men_mdl.rib
##------------ obj1 ------------##
AttributeBegin
Declare "st" "facevarying float[2]"
### MaterialName: Default
Color [1 0 0]
Surface "plastic"
PointsPolygons
[3 3 3 3]
[0 1 2 0 2 3 4 5 2 4 2 1]
"P" [50.000000 0.000000 100.000000
50.000000 20.000000 0.000000
-50.000000 20.000000 0.000000
-50.000000 0.000000 100.000000
50.000000 0.000000 -100.000000
-50.000000 0.000000 -100.000000]
"N" [0.000000 0.980581 0.196116
0.000000 1.000000 0.000000
0.000000 1.000000 0.000000
0.000000 0.980581 0.196116
0.000000 0.980581 -0.196116
0.000000 0.980581 -0.196116]
"st" [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
AttributeEnd
##------------ obj1 ------------##


ライトをとても明るくした。
<
##Renderman RIB-Structure 1.0
Display "men.tif" "file" "rgba"
Display "+men.tif" "framebuffer" "rgba"

Format 640 480 1
PixelSamples 4 4
PixelFilter "catmull-rom" 3 3
ShadingRate 1

Imager "background" "background" [0.500 0.500 0.600]

Sides 1
Orientation "lh"
Projection "perspective" "fov" [9.52728338145235]
Rotate -40.8862682605356 1 0 0 # pich
Rotate 52.9183819582828 0 1 0 # head
Translate -90.469199 -98.183947 68.375702
Scale 0.1 0.1 0.1
WorldBegin
Attribute "visibility" "trace" [1]
Attribute "visibility" "transmission" ["Os"]
Attribute "visibility" "transmission" "opaque"
Attribute "light" "shadows" "on"
Attribute "trace" "displacements" [1]
LightSource "ambientlight" 0 "intensity" [ 0.1 ] "lightcolor" [ 1 1 1 ]
LightSource "distantlight" 1 "intensity" [ 100 ] "lightcolor" [ 1 1 1 ] "from" [ -1 1 -1 ] "to" [ 0 0 0 ]
LightSource "distantlight" 2 "intensity" [ 3 ] "lightcolor" [ 1 1 1 ] "from" [ 1 1 2.5 ] "to" [ 0 0 0 ]
ReadArchive "men_mdl.rib"
WorldEnd


men.jpg
  • -
  • -

辞書と正規化

メタセコイアのPythonを使うために、
辞書と関数について検証してみました。
勉強になります。ありがとうございます。

C:\Python22jp>python
Python 2.2.3 (SJIS enhanced) (#42, Jun 8 2003, 01:46:45) [MSC 32 bit (Intel)] o
n win32
Type "help", "copyright", "credits" or "license" for more information.
>>> c={}
>>> for i in range(5):
... c[i]=[]
...
>>> c
{0: [], 1: [], 2: [], 3: [], 4: []}
>>> c[0]=[1,2,3]
>>> c
{0: [1, 2, 3], 1: [], 2: [], 3: [], 4: []}
>>> def add(a,b):
... return [a[i]+b[i] for i in range(len(a))]
...
>>> c[1]=[3,2,1]
>>> add(c[0],c[1])
[4, 4, 4]
>>> c
{0: [1, 2, 3], 1: [3, 2, 1], 2: [], 3: [], 4: []}
>>> c[2]=add(c[0],c[1])
>>> c
{0: [1, 2, 3], 1: [3, 2, 1], 2: [4, 4, 4], 3: [], 4: []}
>>> import math
>>> def normalize(x,y,z):
... s=math.sqrt(x*x+y*y+z*z)
... if s==0:s=1
... else: s=1.0/s
... return x*s,y*s,z*s
...
>>> c[0]
[1, 2, 3]
>>> normalize(1,2,3)
(0.2672612419124244, 0.53452248382484879, 0.80178372573727319)
>>> normalize(c[0])
Traceback (most recent call last):
File "", line 1, in ?
TypeError: normalize() takes exactly 3 arguments (1 given)
>>> normalize(*c[0])
(0.2672612419124244, 0.53452248382484879, 0.80178372573727319)
>>> normalize(4,4,4)
(0.57735026918962584, 0.57735026918962584, 0.57735026918962584)
>>> normalize(*add(c[0],c[1]))
(0.57735026918962584, 0.57735026918962584, 0.57735026918962584)
>>>
  • -
  • -
<< 9/17 >>