Rendering学習日記

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

python cgkit install under Windows7

Microsoft Windows [Version 6.1.7600]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.

W:\python_cg_programing\pythoncgkitinstall>pip install Pillow-2.8.2-cp27-none-wi
n32.whl
Processing w:\python_cg_programing\pythoncgkitinstall\pillow-2.8.2-cp27-none-win
32.whl
Installing collected packages: Pillow
Successfully installed Pillow-2.8.2

W:\python_cg_programing\pythoncgkitinstall>pip freeze
Pillow==2.8.2
pyglet==1.2.2
pyprocessing==0.1.3.22

W:\python_cg_programing\pythoncgkitinstall>pip install pygame-1.9.2a0-cp27-none-
win32.whl
Processing w:\python_cg_programing\pythoncgkitinstall\pygame-1.9.2a0-cp27-none-w
in32.whl
Installing collected packages: pygame
Successfully installed pygame-1.9.2a0

W:\python_cg_programing\pythoncgkitinstall>pip install ode-0.13.1-cp27-none-win3
2.whl
Processing w:\python_cg_programing\pythoncgkitinstall\ode-0.13.1-cp27-none-win32
.whl
Installing collected packages: ode
Successfully installed ode-0.13.1

W:\python_cg_programing\pythoncgkitinstall>pip install cgkit-2.0.0-cp27-none-win
32.whl
Processing w:\python_cg_programing\pythoncgkitinstall\cgkit-2.0.0-cp27-none-win3
2.whl
Installing collected packages: cgkit
Successfully installed cgkit-2.0.0

W:\python_cg_programing\pythoncgkitinstall>pip install PyOpenGL-3.1.1a1-cp27-non
e-win32.whl
Processing w:\python_cg_programing\pythoncgkitinstall\pyopengl-3.1.1a1-cp27-none
-win32.whl
Installing collected packages: PyOpenGL
Successfully installed PyOpenGL-3.1.1a1

W:\python_cg_programing\pythoncgkitinstall>pip freeze
cgkit==2.0.0
ode==0.13.1
Pillow==2.8.2
pygame==1.9.2a0
pyglet==1.2.2
PyOpenGL==3.1.1a1
pyprocessing==0.1.3.22

W:\python_cg_programing\pythoncgkitinstall>
  • -
  • -

Metasequoia PythonでPxrDisneyマテリアル設定

Metasequoia Pythonを使って、RenderMan RIS用のマテリアルPxrDisneyを設定してみました。ありがとうございます。
boxesrnd.jpg


import random

def p(*args):
"""
プリント関数
複数の引数を渡せる。
"""
if len(args)==0:
# 改行させる
MQSystem.println("")
return

for arg in args:
MQSystem.println(str(arg))


# 基本図形、新規オブジェクトで立方体複数つくる
#meta_cube_def_rndc.py
doc = MQSystem.getDocument()
out = MQSystem.println


#
def unitcube(L=50,x=0,y=0,z=0):
obj = MQSystem.newObject() #新規オブジェクト
num=doc.numObject
a=num
obj.name="cube_%d" % a #オブジェクト名をつける

obj.addVertex(x-L/2.0,y-L/2.0,z+L/2.0) #0 頂点番号
obj.addVertex(x+L/2.0,y-L/2.0,z+L/2.0) #1
obj.addVertex(x+L/2.0,y+L/2.0,z+L/2.0) #2
obj.addVertex(x-L/2.0,y+L/2.0,z+L/2.0) #3
obj.addVertex(x-L/2.0,y-L/2.0,z-L/2.0) #4
obj.addVertex(x-L/2.0,y+L/2.0,z-L/2.0) #5
obj.addVertex(x+L/2.0,y+L/2.0,z-L/2.0) #6
obj.addVertex(x+L/2.0,y-L/2.0,z-L/2.0) #7

obj.addFace([0,3,2,1])
obj.addFace([1,2,6,7])
obj.addFace([4,7,6,5])
obj.addFace([0,4,5,3])
obj.addFace([3,5,6,2])
obj.addFace([0,1,7,4])
doc.addObject( obj )

mat1=MQSystem.newMaterial()
doc.addMaterial(mat1) #マテリアルをドキュメントに追加
num0 = doc.numMaterial #現在の材質数を数える
numm=num0-1 #マテリアル番号は一つ少ない
doc.material[numm].shader=5
doc.material[numm].shaderFilename="PxrDisney"
doc.material[numm].color=MQSystem.newColor(random.random(),random.random(),random.random())
doc.material[numm].specular=0.5
doc.material[numm].reflection=0.75

for face in obj.face:
face.material=numm #マテリアルnumm番を面に割り当てる


import traceback
import sys
#dist=0
try:
for dist in range(0,600,200):
for dist2 in range(0,600,200):
#out(str(i))
out(str(dist))
unitcube(100,50+dist,50,dist2)



except:
info=sys.exc_info()
p(info[0])
p(info[1])
p(*traceback.extract_tb(info[2]))

num = doc.numObject #オブジェクトの数
out("オブジェクトの数 %d" % num) #オブジェクトの数を表示


  • -
  • -

MagicaVoxelからFujiyama Rendererへ

Fujiyama Renderer0.2.9、MagicaVoxelからobjをexport。blenderに読み込みply出力。s,tをuv1,uv2に書き換え、textureをjpgにして読み込みました。直接jpgやplyを読み込んでます。objの表示に影が出るのでplyを使います。
magica.jpg
Magicavoxelのtextureは拡大。Magicavoxelからobj出力時のテクスチャは1 x 256pixels、変換できないので、100 x 256にしたらできました。ありがとうございます。
ch02.jpg


#!/usr/bin/env python

#set PYTHONPATH=C:\Python27;C:\Fujiyama-Renderer\python
# 1 teapot with 32 point lights
# This script is the python version of teapot.scn with minor changes.
# It also demonstrates how to load *.ply and *.hdr files
# directly without pre-conversion.
# Copyright (c) 2011-2014 Hiroshi Tsubokawa

import fujiyama

si = fujiyama.SceneInterface()

#plugins
si.OpenPlugin('PlasticShader')
si.OpenPlugin('GlassShader')
si.OpenPlugin('ConstantShader')

#Camera
si.NewCamera('cam1', 'PerspectiveCamera')
si.SetProperty3('cam1', 'translate', 0, 1, 7)
si.SetProperty3('cam1', 'rotate', -5.710593137499643, 0, 0)

#Light
si.NewLight('light0', 'PointLight')
si.SetProperty3('light0', 'translate', 0.900771, 12, 4.09137)
si.SetProperty1('light0', 'intensity', 0.03125)
si.NewLight('light1', 'PointLight')
si.SetProperty3('light1', 'translate', 2.02315, 12, 5.28021)
si.SetProperty1('light1', 'intensity', 0.03125)
si.NewLight('light2', 'PointLight')
si.SetProperty3('light2', 'translate', 10.69, 12, 13.918)
si.SetProperty1('light2', 'intensity', 0.03125)
si.NewLight('light3', 'PointLight')
si.SetProperty3('light3', 'translate', 4.28027, 12, 7.58462)
si.SetProperty1('light3', 'intensity', 0.03125)
si.NewLight('light4', 'PointLight')
si.SetProperty3('light4', 'translate', 12.9548, 12, 1.19914)
si.SetProperty1('light4', 'intensity', 0.03125)
si.NewLight('light5', 'PointLight')
si.SetProperty3('light5', 'translate', 6.55808, 12, 2.31772)
si.SetProperty1('light5', 'intensity', 0.03125)
si.NewLight('light6', 'PointLight')
si.SetProperty3('light6', 'translate', 0.169064, 12, 10.9623)
si.SetProperty1('light6', 'intensity', 0.03125)
si.NewLight('light7', 'PointLight')
si.SetProperty3('light7', 'translate', 1.25002, 12, 4.51314)
si.SetProperty1('light7', 'intensity', 0.03125)
si.NewLight('light8', 'PointLight')
si.SetProperty3('light8', 'translate', 2.46758, 12, 5.73382)
si.SetProperty1('light8', 'intensity', 0.03125)
si.NewLight('light9', 'PointLight')
si.SetProperty3('light9', 'translate', 3.55644, 12, 6.84334)
si.SetProperty1('light9', 'intensity', 0.03125)
si.NewLight('light10', 'PointLight')
si.SetProperty3('light10', 'translate', 4.76112, 12, 8.00264)
si.SetProperty1('light10', 'intensity', 0.03125)
si.NewLight('light11', 'PointLight')
si.SetProperty3('light11', 'translate', 13.3267, 12, 9.10333)
si.SetProperty1('light11', 'intensity', 0.03125)
si.NewLight('light12', 'PointLight')
si.SetProperty3('light12', 'translate', 14.4155, 12, 2.68084)
si.SetProperty1('light12', 'intensity', 0.03125)
si.NewLight('light13', 'PointLight')
si.SetProperty3('light13', 'translate', 8.10755, 12, 3.79629)
si.SetProperty1('light13', 'intensity', 0.03125)
si.NewLight('light14', 'PointLight')
si.SetProperty3('light14', 'translate', 9.21103, 12, 4.9484)
si.SetProperty1('light14', 'intensity', 0.03125)
si.NewLight('light15', 'PointLight')
si.SetProperty3('light15', 'translate', 2.83469, 12, 6.09221)
si.SetProperty1('light15', 'intensity', 0.03125)
si.NewLight('light16', 'PointLight')
si.SetProperty3('light16', 'translate', 4.00945, 12, 7.18302)
si.SetProperty1('light16', 'intensity', 0.03125)
si.NewLight('light17', 'PointLight')
si.SetProperty3('light17', 'translate', 12.6072, 12, 0.832089)
si.SetProperty1('light17', 'intensity', 0.03125)
si.NewLight('light18', 'PointLight')
si.SetProperty3('light18', 'translate', 6.21169, 12, 1.98055)
si.SetProperty1('light18', 'intensity', 0.03125)
si.NewLight('light19', 'PointLight')
si.SetProperty3('light19', 'translate', 7.39599, 12, 10.5563)
si.SetProperty1('light19', 'intensity', 0.03125)
si.NewLight('light20', 'PointLight')
si.SetProperty3('light20', 'translate', 8.52421, 12, 4.15086)
si.SetProperty1('light20', 'intensity', 0.03125)
si.NewLight('light21', 'PointLight')
si.SetProperty3('light21', 'translate', 9.5891, 12, 5.39715)
si.SetProperty1('light21', 'intensity', 0.03125)
si.NewLight('light22', 'PointLight')
si.SetProperty3('light22', 'translate', 3.18967, 12, 13.9542)
si.SetProperty1('light22', 'intensity', 0.03125)
si.NewLight('light23', 'PointLight')
si.SetProperty3('light23', 'translate', 4.41432, 12, 0.082813)
si.SetProperty1('light23', 'intensity', 0.03125)
si.NewLight('light24', 'PointLight')
si.SetProperty3('light24', 'translate', 5.48803, 12, 1.21856)
si.SetProperty1('light24', 'intensity', 0.03125)
si.NewLight('light25', 'PointLight')
si.SetProperty3('light25', 'translate', 6.57647, 12, 2.31432)
si.SetProperty1('light25', 'intensity', 0.03125)
si.NewLight('light26', 'PointLight')
si.SetProperty3('light26', 'translate', 0.265098, 12, 10.9453)
si.SetProperty1('light26', 'intensity', 0.03125)
si.NewLight('light27', 'PointLight')
si.SetProperty3('light27', 'translate', 8.84422, 12, 12.1117)
si.SetProperty1('light27', 'intensity', 0.03125)
si.NewLight('light28', 'PointLight')
si.SetProperty3('light28', 'translate', 10.0154, 12, 5.67625)
si.SetProperty1('light28', 'intensity', 0.03125)
si.NewLight('light29', 'PointLight')
si.SetProperty3('light29', 'translate', 11.0907, 12, 14.4043)
si.SetProperty1('light29', 'intensity', 0.03125)
si.NewLight('light30', 'PointLight')
si.SetProperty3('light30', 'translate', 4.71726, 12, 7.98851)
si.SetProperty1('light30', 'intensity', 0.03125)
si.NewLight('light31', 'PointLight')
si.SetProperty3('light31', 'translate', 13.3907, 12, 9.08986)
si.SetProperty1('light31', 'intensity', 0.03125)
si.NewLight('light32', 'PointLight')
si.SetProperty3('light32', 'translate', 0, 1, 7)
si.SetProperty1('light32', 'intensity', 0.75)
#Texture
# You can specify file paths to *.hdr/*.jpg file via python API
si.NewTexture('tex1', '../hdr/grace-new.hdr')
si.NewTexture('tex2', '../mip/ch02.jpg')

#Shader
si.NewShader('teapot_shader', 'PlasticShader')
si.NewShader('floor_shader', 'PlasticShader')
si.NewShader('dome_shader', 'ConstantShader')

#Mesh
# You can specify file paths to *.ply/*.obj file via python API
si.NewMesh('teapot_mesh', '../ply/sword2.ply')
si.NewMesh('floor_mesh', '../ply/floor.ply')
si.NewMesh('dome_mesh', '../ply/dome.ply')

#ObjectInstance
si.NewObjectInstance('teapot1', 'teapot_mesh')
si.SetProperty3('teapot1', 'translate', 0, -0.55, 1.5)
si.SetProperty3('teapot1', 'rotate', -90, -30, 0)
si.AssignShader('teapot1', 'teapot_shader')
si.AssignTexture('teapot_shader', 'diffuse_map', 'tex2')

si.NewObjectInstance('floor1', 'floor_mesh')
si.SetProperty3('floor1', 'translate', 0, -0.6, 0)
si.AssignShader('floor1', 'floor_shader')

si.NewObjectInstance('dome1', 'dome_mesh')
si.SetProperty3('dome1', 'scale', .5, .5, .5)
si.SetProperty3('dome1', 'rotate', 0, 30, 0)
si.AssignShader('dome1', 'dome_shader')
si.AssignTexture('dome_shader', 'texture', 'tex1')

#ObjectGroup
si.NewObjectGroup('group1')
si.AddObjectToGroup('group1', 'teapot1')
si.AssignObjectGroup('teapot1', 'shadow_target', 'group1')
si.AssignObjectGroup('floor1', 'shadow_target', 'group1')

#FrameBuffer
si.NewFrameBuffer('fb1', 'rgba')

#Renderer
si.NewRenderer('ren1')
si.AssignCamera('ren1', 'cam1')
si.AssignFrameBuffer('ren1', 'fb1')
si.SetProperty2('ren1', 'resolution', 640, 480)
#si.SetProperty2('ren1', 'resolution', 160, 120)

#Rendering
si.RenderScene('ren1')

#Output
# You can specify file paths to *.exr file via python API
si.SaveFrameBuffer('fb1', '../objimport01.exr')

#Run commands
si.Run()
#si.Print()


magica2.jpg
  • -
  • -
<< 14/184 >>