<< pythonでパーティクル その5 戻る pythonでパーティクル その7 >>

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でパーティクル その5 戻る pythonでパーティクル その7 >>