<< 6/15 >>

面法線と頂点法線 その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からRenderManを使う その1

RenderManはC APIで記述されているが、cgkitと3Delightを使えば、次のように球体を表示、レンダリングできます。
本来ならば、C言語を使ってコンパイルしてやりますが、Python良いですね。便利です。

以下はcgkitを使って3Delightで直接レンダリングしました。3DelightのLibフォルダの3Delight.libが働いてくれます。


#min.py
import cgkit.cri

ri = cgkit.cri.loadRI("3Delight")
cgkit.cri.importRINames(ri, globals())

RiBegin(RI_NULL)
RiDisplay("min.tif", RI_FRAMEBUFFER, RI_RGB)
RiProjection(RI_PERSPECTIVE)
RiTranslate(0,0,1.5)
RiWorldBegin()
RiLightSource("ambientlight","intensity",0.4)
RiLightSource("distantlight")
RiSurface("plastic")
RiColor((1,0.2,0.2))
RiSphere(1,-1,1,360)
RiWorldEnd()
RiEnd()



ri = cgkit.cri.loadRI("3Delight")の部分を
オープンソースRenderMan互換レンダラのAqsis Renderer1.6を使用するならば、


ri = cgkit.cri.loadRI("aqsis_ri2rib")


コマンドプロンプトから、
>min.py
と打ち込むと、RIBが生成されて表示されるだけです。
なので、パイプを使います。こんな感じ・・
>min.py |aqsis

prmanの場合も、cgkitを使う場合は、
ri = cgkit.cri.loadRI("libprman")
>min.py |prman
となります。直接レンダリングではないので、
RenderManProServer-14からついているimport prmanを利用します。


# set PYTHONPATH=C:\Python25;C:\Python\Scripts;%RMANTREE%\bin
#min_pr.py
import prman
ri=prman.Ri()
rendertarget="min_pr.rib"
ri.Begin(ri.RENDER)
ri.Imager("background", {"color color":(.2,.4,.6)})
ri.Display("min_pr.tif", "framebuffer", "rgb")
ri.Format(640,480,1)
ri.Projection(ri.PERSPECTIVE, {ri.FOV: 90})
ri.Translate(0,0,1.5)
ri.WorldBegin()
ri.LightSource("distantlight", {ri.HANDLEID: "1"})
ri.LightSource("ambientlight", {ri.HANDLEID: "2", "intensity":[0.4]})
ri.Color((1,0.2,0.2))
ri.Surface("plastic")
ri.Sphere(1,-1,1,360)
ri.WorldEnd()
ri.End()


>min.pyと打ち込む前に
>set PYTHONPATH=C:\Python25;C:\Python\Scripts;%RMANTREE%\bin
でパスを通しておきます。
以下はレンダリング結果。
min_pr.jpg
  • -
  • -

PythonからRenderManを使う その2

Pixar RenderManのPython APIとcgkitでの記述を並べてみた。
import prmanでは、パラメータを辞書形式で記述。後はほとんど同じ感じてす。
以下は、ティーポットの表示
■import prman


#test2.py
# set PYTHONPATH=C:\Python25;C:\Python\Scripts;%RMANTREE%\bin
import prman
ri=prman.Ri()
rendertarget="test2.rib"
ri.Begin(ri.RENDER)
ri.Imager("background", {"color color":(.2,.4,.6)})
ri.Display("teapot2.png", "file", "rgb")
ri.Format(640,480,1)
ri.Projection(ri.PERSPECTIVE, {ri.FOV: 45})
ri.Translate(0,0,10)
ri.WorldBegin()
ri.LightSource("pointlight", {ri.HANDLEID: "1", "from": [-10,10,-10],"intensity":[300]})
ri.LightSource("pointlight", {ri.HANDLEID: "2", "from": [10,10,-10],"intensity":[300]})
ri.LightSource("pointlight", {ri.HANDLEID: "3", "from": [-10,-10,-10],"intensity":[300]})
ri.Color((0.9,0,0.1))
ri.Surface("plastic")
ri.Translate(0,-1,0)
ri.Rotate(-90,1,0,0)
ri.Geometry("teapot")
ri.WorldEnd()
ri.End()


teapot2.jpg

■cgkit
3Delightを利用した。


#min2.py
import cgkit.cri

ri = cgkit.cri.loadRI("3Delight")
cgkit.cri.importRINames(ri, globals())

RiBegin(RI_NULL)
RiImager("background", "color background",(.2,.4,.6))
RiDisplay("min2.png", RI_FILE, RI_RGB)
RiProjection(RI_PERSPECTIVE,RI_FOV,45)
RiTranslate(0,0,10)
RiWorldBegin()
#RiLightSource("ambientlight","intensity",0.4)
#RiLightSource("distantlight")
RiLightSource("pointlight", RI_HANDLEID, "1", "from",[-10,10,-10],"intensity",[300])
RiLightSource("pointlight", RI_HANDLEID, "2", "from",[10,10,-10],"intensity",[300])
RiLightSource("pointlight", RI_HANDLEID, "3", "from",[-10,-10,-10],"intensity",[300])
RiSurface("plastic")
RiColor((1,0.2,0.2))
RiTranslate(0,-1,0)
RiRotate(-90,1,0,0)
RiReadArchive("teapot.rib")
RiWorldEnd()
RiEnd()


min2.jpg
  • -
  • -

pythonでパーティクル その5

prmanでパーティクル。cgkitは使わないです。
イギリスのbournemouth universityを参考にしました。ありがとうございます。Thank you.
hair_pr.jpg


#hair2.py
#set PYTHONPATH=C:\Python25;C:\Python\Scripts;%RMANTREE%\bin
import random
from random import uniform as ru
import prman
ri=prman.Ri()

points=[]
pappend=points.append
width=[]
wappend=width.append
npoints=[]
npappend=npoints.append
random.seed(129234)
ru=random.uniform
zpos=-2.0
plus=0.1
minus=-0.1
while(zpos < 2.0 ) :
xpos=-2.0
while (xpos < 2.0) :
pappend(xpos+ru(minus,plus))
pappend(0)
pappend(zpos+ru(minus,plus))

pappend(xpos+ru(minus,plus))
pappend(0.1)
pappend(zpos+ru(minus,plus))

pappend(xpos+ru(minus,plus))
pappend(0.2)
pappend(zpos+ru(minus,plus))

pappend(xpos+ru(minus,plus))
pappend(0.3+ru(-0.1,0.1))
pappend(zpos+ru(minus,plus))

wappend(0.006)
wappend(0.001)
npappend(4)
xpos+=0.02
zpos+=0.02

ri.Begin(ri.RENDER)
ri.Imager("background", {"color color":(.2,.4,.6)})
ri.Display("hair_pr.png", "file", "rgb")
ri.Format(640,480,1)
ri.Projection(ri.PERSPECTIVE, {ri.FOV: 90})
ri.Translate(0,0,2)
ri.Rotate(-25,1,0,0)
ri.WorldBegin()
ri.LightSource("distantlight", {ri.HANDLEID: "1"})
ri.LightSource("ambientlight", {ri.HANDLEID: "2", "intensity":[0.4]})
ri.Color((1,0.2,0.2))
ri.Surface("hair")
ri.Curves( "cubic",npoints,"nonperiodic",{ri.P:points, ri.WIDTH : width})
ri.WorldEnd()
ri.End()

  • -
  • -

renderWiki

じっくり読んで、勉強します。
繰り返し繰り返しですね。
ありがとうございます。

In depth renderman
  • -
  • -

RiCurves その1

イギリスのbournemouth universityを参考にしました。ありがとうございます。Thank you.
import prman使ってます。
ricurve_pr.jpg


#ricurve_pr.py
#set PYTHONPATH=C:\Python25;C:\Python\Scripts;%RMANTREE%\bin
import prman
ri=prman.Ri()

filename="ricurve_pr.rib"

ri.Begin(ri.RENDER)
ri.Imager("background", {"color color":(.2,.4,.6)})
ri.Display ("ricurve_pr.png","file","rgb")
ri.Format(512, 384, -1.0)
ri.PixelSamples( 4, 4)
ri.ShadingRate(1)
ri.Projection(ri.PERSPECTIVE, {ri.FOV: 90})
ri.WorldBegin()
ri.LightSource("distantlight", {ri.HANDLEID: "1","to":[0,0,1]})
ri.LightSource("ambientlight", {ri.HANDLEID: "2", "intensity":[0.4]})
ri.Translate(0,0,1.8)
ri.Surface("plastic")

ri.Color([1,0,0])
points= [0, 0, 0 ,-1, -.5 ,1 ,2 ,.5 ,1 ,1 ,0, -1 ]
width=[0.01,0.04]
ri.Curves( "cubic",[4],"nonperiodic",{ri.P:points, ri.WIDTH : width})

ri.Color([0,0,1])
points2=[0,0,0,3,4,5,-1,-.5,1,2,.5,1,1,0,-1]
ri.Curves("linear",[5],"nonperiodic",{ ri.P:points2 , ri.CONSTANTWIDTH:[0.075]})

ri.WorldEnd()
ri.End()


  • -
  • -

PythonからRenderMan その3

イギリスのbournemouth universityを参考にしました。ありがとうございます。Thank you.
RenderManProServer-14からついているimport prmanを利用してます。
cubeを作成しました。
cube_pr.jpg


#cube_pr.py
#set PYTHONPATH=C:\Python25;C:\Python\Scripts;%RMANTREE%\bin
import getpass
import time
# import the python renderman library
import prman

def Cube(width,height,depth) :
w=width/2.0
h=height/2.0
d=depth/2.0
ri.ArchiveRecord(ri.COMMENT, 'Cube Generated by Cube Function')
#rear
face=[-w,-h,d,-w,h,d,w,-h,d,w,h,d]
ri.Patch("bilinear",{'P':face})
#front
face=[-w,-h,-d,-w,h,-d,w,-h,-d,w,h,-d]
ri.Patch("bilinear",{'P':face})
#left
face=[-w,-h,-d,-w,h,-d,-w,-h,d,-w,h,d]
ri.Patch("bilinear",{'P':face})
#right
face=[w,-h,-d,w,h,-d,w,-h,d,w,h,d]
ri.Patch("bilinear",{'P':face})
#bottom
face=[w,-h,d,w,-h,-d,-w,-h,d,-w,-h,-d]
ri.Patch("bilinear",{'P':face})
#top
face=[w,h,d,w,h,-d,-w,h,d,-w,h,-d]
ri.Patch("bilinear",{'P':face})
ri.ArchiveRecord(ri.COMMENT, '--End of Cube Function--')


ri = prman.Ri() # create an instance of the RenderMan interface
ri.Option("rib", {"string asciistyle": "indented"})

filename = "Cube.rib"
# this is the begining of the rib archive generation we can only
# make RI calls after this function else we get a core dump
ri.Begin("__render") #filename)
# ArchiveRecord is used to add elements to the rib stream in this case comments
# note the function is overloaded so we can concatinate output
ri.ArchiveRecord(ri.COMMENT, 'File ' +filename)
ri.ArchiveRecord(ri.COMMENT, "Created by " + getpass.getuser())
ri.ArchiveRecord(ri.COMMENT, "Creation Date: " +time.ctime(time.time()))

# now we add the display element using the usual elements
# FILENAME DISPLAY Type Output format
ri.Display("cube_pr.png", "file", "rgb")
ri.Format(512, 384, -1.0)
ri.PixelSamples( 4, 4)
ri.ShadingRate(1)
# now set the projection to perspective
ri.Projection(ri.PERSPECTIVE,{ri.FOV:50})

# now we start our world
ri.WorldBegin()
ri.LightSource("distantlight", {ri.HANDLEID: "1","to":[0,0,1]})
ri.LightSource("ambientlight", {ri.HANDLEID: "2", "intensity":[0.4]})

ri.Surface("plastic")
ri.Translate(0,0,5)

ri.TransformBegin()
ri.Translate(-2,0,0)
ri.Rotate(25,0,1,0)
ri.Color([0,0,1])
Cube(1,1,1)
ri.TransformEnd()

ri.TransformBegin()
ri.Translate( 0,0,0)
ri.Rotate( 25,1,1,0)
ri.Color([1,0,0])
Cube(1,1,1)
ri.TransformEnd()

ri.TransformBegin()
ri.Translate(2,0,0)
ri.Rotate(-25,1,1,1)
ri.Color([0,1,0])
Cube(0.2,2,0.2);
ri.TransformEnd()

ri.WorldEnd()
ri.End()

  • -
  • -

PythonからRenderMan その4

イギリスのbournemouth universityを参考にしてます。ありがとうございます。Thank You.
RenderManProServer-14からついているimport prmanを利用します。
InlineArchive.jpg


#inlinearchive_pr.py
#set PYTHONPATH=C:\Python25;C:\Python\Scripts;%RMANTREE%\bin
import getpass
import time
# import the python renderman library
import prman

ri = prman.Ri() # create an instance of the RenderMan interface
ri.Option("rib", {"string asciistyle": "indented"})

filename = "InlineArchive.rib"

ri.Begin(ri.RENDER)

ri.ArchiveBegin("Wave")
ri.Rotate(90,1,0,0)
ri.Sphere(0.030303,-0.030303,0,360)
ri.Torus(0.0606061,0.030303,0,180,360)
ri.Torus(0.121212,0.030303,180,360,360)
ri.Torus(0.181818,0.030303,0,180,360)
ri.Torus(0.242424,0.030303,180,360,360)
ri.Torus(0.30303,0.030303,0,180,360)
ri.Torus(0.363636,0.030303,180,360,360)
ri.Torus(0.424242,0.030303,0,180,360)
ri.Torus(0.484848,0.030303,180,360,360)
ri.Torus(0.545455,0.030303,0,180,360)
ri.Torus(0.606061,0.030303,180,360,360)
ri.Torus(0.666667,0.030303,0,180,360)
ri.Torus(0.727273,0.030303,180,360,360)
ri.Torus(0.787879,0.030303,0,180,360)
ri.Torus(0.848485,0.030303,180,360,360)
ri.ArchiveEnd()

#ArchiveRecord is used to add elements to the rib stream in this case comments
# note the function is overloaded so we can concatinate output
ri.ArchiveRecord(ri.COMMENT, 'File ' +filename)
ri.ArchiveRecord(ri.COMMENT, "Created by " + getpass.getuser())
ri.ArchiveRecord(ri.COMMENT, "Creation Date: " +time.ctime(time.time()))

# now we add the display element using the usual elements
# FILENAME DISPLAY Type Output format
ri.Display("InlineArchive.png", "file", "rgb")
ri.Format(512, 384, -1.0)
ri.Projection(ri.PERSPECTIVE,{ri.FOV:30})

# now we start our world
colours ={
"red":[1,0,0],
"white":[1,1,1],
"green":[0,1,0],
"blue":[0,0,1],
"black":[0,0,0],
"yellow":[1,1,0]
}

# start our world
ri.WorldBegin()
ri.LightSource("distantlight", {ri.HANDLEID: "1","to":[0,0,1]})
ri.LightSource("ambientlight", {ri.HANDLEID: "2", "intensity":[0.4]})

ri.Translate(0,0,9) #move the global view position
ri.Surface("plastic")

ri.TransformBegin()
ri.Rotate(40,1,0,0)
ri.Color(colours["red"])
ri.Attribute ("identifier",{"name": "Wave1"})
ri.ReadArchive("Wave")
ri.TransformEnd()

ri.TransformBegin()
ri.Rotate(55,1,0,0)
ri.Color(colours["green"])
ri.Translate(2.2,0,0)
ri.Attribute( "identifier",{ "name" :"Wave2"})
ri.ReadArchive("Wave")
ri.TransformEnd()

ri.TransformBegin()
ri.Rotate(35,1,0,0)
ri.Color(colours["blue"])
ri.Translate(-2.2,0,0)
ri.Attribute("identifier",{ "name" : "Wave3"})
ri.ReadArchive("Wave")
ri.TransformEnd()
#end our world

ri.WorldEnd()
ri.End()

  • -
  • -

PythonからRenderMan その5

引き続き、イギリスのbournemouth universityを参考にしてます。ありがとうございます。勉強になります。Csを球にセットしてます。
RenderManProServer-14からついているimport prmanを利用します。
Param.jpg


#param_pr.py
#set PYTHONPATH=C:\Python25;C:\Python\Scripts;%RMANTREE%\bin
import getpass
import time
# import the python renderman library
import prman

ri = prman.Ri() # create an instance of the RenderMan interface
ri.Option("rib", {"string asciistyle": "indented"})

filename = "Param.rib"
ri.Begin(ri.RENDER)
# ArchiveRecord is used to add elements to the rib stream in this case comments
# note the function is overloaded so we can concatinate output
ri.ArchiveRecord(ri.COMMENT, 'File ' +filename)
ri.ArchiveRecord(ri.COMMENT, "Created by " + getpass.getuser())
ri.ArchiveRecord(ri.COMMENT, "Creation Date: " +time.ctime(time.time()))

# now we add the display element using the usual elements
# FILENAME DISPLAY Type Output format
ri.Display("Param.png", "file", "rgb")
ri.Format(512, 384, -1.0)
# now set the projection to perspective
ri.Projection(ri.PERSPECTIVE,{ri.FOV:50})

# now we start our world
ri.WorldBegin()
ri.LightSource("distantlight", {ri.HANDLEID: "1","to":[0,-1,1]})
ri.LightSource("ambientlight", {ri.HANDLEID: "2", "intensity":[0.4]})

ri.Translate(0,0,3)
ri.TransformBegin()
colours=[1,0,0,0,0,1,1,0,0,0,1,0]
ri.Rotate(90,1,1,1)
ri.Surface("plastic")
ri.Sphere(1,-1,1,360,{"Cs":colours})
ri.TransformEnd()
ri.WorldEnd()
ri.End()

  • -
  • -

<< 6/15 >>