Rendering学習日記

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

pythonでパーティクル その3

cgkitとPrmanを組み合わせる。どうも3Delightとprmanでは、RiPointの仕様がちがうようです。
3Delightのマニュアルはこちらになりますが、blobbyが使えて、遊べそうです。

さてさてPrmanだと以下の通りになります。
#point2.py - Create a simple Particle System
import random, math
import cgkit.cri
from cgkit.cgtypes import *
from random import uniform as ru


# Load the RenderMan API.
# Replace the library name with whatever renderer you want to use.
ri = cgkit.cri.loadRI("C:\Program Files (x86)\Pixar\RenderManProServer-14.4\lib\libprman")
cgkit.cri.importRINames(ri, globals())

points=[]
width=[]
colour=[]
normals=[]
pappend=points.append
wappend=width.append
cappend=colour.append
nappend=normals.append

for i in range(0,1500):
for ix in range(0,3):
cappend(ru(0,1))
pappend(ru(-2,2))
nappend(ru(0,1))
wappend(ru(0.01,0.2))


RiBegin(RI_NULL)
RiImager("background", "color background",(.2,.4,.6))
RiDisplay ("point2_pr.tif","file","rgb",RI_NULL)
RiFormat(512, 384, -1.0)
RiPixelSamples( 4, 4)
RiShadingRate(1)
RiProjection ("perspective","fov",30,RI_NULL)
RiWorldBegin()
RiLightSource("ambientlight","intensity",0.4)
RiLightSource("distantlight", "from",[0,0,1])
RiTranslate(0,0,6)
RiSurface("plastic")
RiPoints("P",points,"Cs",colour,"width",width,"N",normals,RI_NULL)
RiWorldEnd()
RiEnd()

実行方法は、

>point2_pr.py |prman

point2_pr.jpg
ありがとうございます。調べて納得して、繰り返し繰り返しですね。
  • -
  • -

pythonでパーティクル その6

Essential RenderManを参考に、cgkitで作成した。レンダリングは3Delightです。試してみると面白いです。ありがとうございます。
color_par.jpg
#color.py - Create Particles of different colors
import random, math
import cgkit.cri
from cgkit.cgtypes import *


# Load the RenderMan API.
# Replace the library name with whatever renderer you want to use.
ri = cgkit.cri.loadRI("3delight")
cgkit.cri.importRINames(ri, globals())


COUNT = 2000

def jitter(scale):
val=random.random()*1000
return (val/500-1)*scale

position=[]
color=[]
constantwidth=2.5
fov=30

#/*Generate Particle Postions*/
for i in range(COUNT):
x=math.sin(i*0.5)*50+jitter(2)
y=math.cos(i*0.1)*50+jitter(2)
z=math.cos(i*0.5)*100+jitter(2)
color0=jitter(0.5)+0.5
color1=jitter(0.5)+0.5
color2=jitter(0.5)+0.5
position.append(vec3(x, y, z))
color.append(vec3(color0, color1, color2))

RiBegin(RI_NULL)
RiDisplay ("color_par.tif","file","rgb",RI_NULL)
RiFormat(512, 384, -1.0)
RiPixelSamples( 4, 4)
RiShadingRate(0.5)
RiProjection ("perspective","fov",fov,RI_NULL)
RiWorldBegin()
RiLightSource("ambientlight","intensity",0.4)
RiLightSource("distantlight", "from",[0,0,1])
RiTranslate(0,0,250)
RiSurface("plastic")
RiPoints("P",position,"constantwidth", constantwidth,"Cs",color,RI_NULL)
RiWorldEnd()
RiEnd()
  • -
  • -

pythonでパーティクル その7

Essential RenderManを参考に、cgkitを利用して、Pointsのwidthを調整してみる。レンダリングは3Delightです。ありがとうございます。
width.jpg
RenderMan Procedual Primitives
#width.py - Create Particles of different sizes
import random, math
import cgkit.cri
from cgkit.cgtypes import *

# Load the RenderMan API.
# Replace the library name with whatever renderer you want to use.
ri = cgkit.cri.loadRI("3delight")
cgkit.cri.importRINames(ri, globals())

COUNT = 2000

def jitter(scale):
val=random.random()*1000
return (val/500-1)*scale

position=[]
constantwidth=0.5
fov=30
red=[1,0,0]
green=[0,1,0]
width=[]
constantwidth=1.0
fov=30


#/*Generate Particle Postions*/
for i in range(COUNT):
x=math.sin(i*0.5)*50+jitter(2)
y=math.cos(i*0.1)*50+jitter(2)
z=math.cos(i*0.5)*100+jitter(2)
w=jitter(1.0)+0.5
position.append(vec3(x, y, z))
width.append(w)

RiBegin(RI_NULL)
RiDisplay ("width.tiff","file","rgb",RI_NULL)
RiFormat(512, 384, -1.0)
RiPixelSamples( 4, 4)
RiShadingRate(0.5)
RiProjection ("perspective","fov",fov,RI_NULL)
RiWorldBegin()
RiLightSource("ambientlight","intensity",0.4)
RiLightSource("distantlight", "from",[0,0,1])
RiTranslate(0,0,250)
RiSurface("plastic")
RiColor(red)
RiPoints("P",position,"constantwidth", constantwidth,RI_NULL)
RiColor(green)
RiPoints("P",position,"width",width,RI_NULL)
RiWorldEnd()
RiEnd()
  • -
  • -
<< 14/22 >>