Procedural
- RenderMan
- by yuichirou yokomakura
- 2011.01.02 Sunday 11:13
PythonプログラムをRenderMan RIBで実行するテスト
RIBの出力:
RunProgram例:
ケッソン先生のサイト参考になります。ありがとうございます。
RIBの出力:
RunProgram例:
ケッソン先生のサイト参考になります。ありがとうございます。
- -
- -
日々、3DCGの世界は進歩しています。勉強して理解したことをまとめていきます。RenderMan互換レンダラーやグローバル・イルミネーション。いろんなことに好奇心を持って、面白くなる。目指せShader書き!!
ありがとうございます。
import sys
args = sys.stdin.readline()
while args:
values = args.split()
pixels = float(values[0])
rad = float(values[1])
print 'TransformBegin'
print 'Sphere %s %s %s 360' % (rad, -rad, rad)
print 'TransformEnd'
sys.stdout.write('\377')
sys.stdout.flush()
# read the next set of inputs
args = sys.stdin.readline()
Display "untitled" "framebuffer" "rgb"
Format 400 400 1
Projection "perspective" "fov" 30
ShadingRate 5
LightSource "distantlight" 1 "intensity" 1.5 "from" [0 0 0] "to" [0 0 1]
Translate 0 0 5
Rotate -30 1 0 0
Rotate 20 0 1 0
Scale 1 1 -1
WorldBegin
TransformBegin
Surface "plastic" "Ks" 0.6
Procedural "RunProgram" ["python pytest.py" "1.0"] [-1 1 -1 1 -1 1]
TransformEnd
WorldEnd
#sp_rect2.py
import sys
import random
while sys.stdin.readline():
dist = 1
x = 0.0
distx = 10.0
disty = 10.0
distz = 10.0
while x <= distx:
z = 0.0
while z <= distz:
y = 0.0
while y <= disty:
r = random.random() * .5
sys.stdout.write("TransformBegin\n")
sys.stdout.write("Translate " + str(x - 5.0) + " " + str(y - 5.0) + " " + str(z - 5.0) + "\n")
sys.stdout.write('Sphere [' + str(r) + ' -1 1 360]\n')
sys.stdout.write("TransformEnd\n")
y += dist
z += dist
x += dist
sys.stdout.write('\377')
sys.stdout.flush()
Display "untitled" "framebuffer" "rgb"
Format 640 480 1
Projection "perspective" "fov" 30
ShadingRate 5
LightSource "distantlight" 1 "intensity" 1.5 "from" [0 0 0] "to" [0 0 1]
Translate 0 0 30
Rotate -30 1 0 0
Rotate 20 0 1 0
Scale 1 1 -1
WorldBegin
TransformBegin
Surface "plastic" "Ks" 0.6
Procedural "RunProgram" ["python sp_rect2.py" ""] [-9.91912 9.91912 -9.91912 9.91912 -9.91912 9.91912]
TransformEnd
WorldEnd
r=RIBArchive(
filename = 'butu.rib', pos = (0,0,0) )
r.rib='Color 0.9 0.9 1.0\nSurface "plastic"' #r.rib='Surface "check_ref'
t=RIBArchive(
filename = 'butu.rib', pos = (0.5,0,0) )
t.rib='Color 1 0.9 0.9\nSurface "plastic"'
Plane(
lx = 50, ly = 50, pos = (0,0,0.6), material = GLMaterial(diffuse=(0.8, 0.7, 0.7)) )
Plane(
lx = 50, ly = 50, pos = (0,-0.44,0), rot= mat3().fromEulerXYZ(radians(90), 0, 0), material = GLMaterial(diffuse=(0.8, 0.6, 0.6)) )
s=RIBArchive(
filename = 'butu.rib', pos = (-0.5,0,0) )
s.rib='ShadingRate 0.25\nAttribute "trace" "int displacements" [1]\nAttribute "displacementbound" "float sphere" [0.001] "string cordinatesystem" ["shader"]\nDeclare "Km" "uniform float"\nDisplacement "dented" "Km" 0.05\nSurface "metal" "Ks" [1.5] "roughness" [1.0]\nColor [ 0.8 0.8 0.8 ]'