Rendering学習日記

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

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
Fujiyama Renderer | - | -

Fujiyama Renderer 0.2.8 for Windows 64bit

Fujiyama Renderer0.2.8、メタセコイアmekaをobj→blenderでply出力。s,tをuv1,uv2に書き換え、textureをjpgにして読み込みました。直接jpgやobjやplyを読み込みできるようになったのでちょっと便利になりました。ありがとうございます。
floor.plyをblenderで読み込み、UV editingでunwrapし、obj exportしました。
teapotscn03.jpg
以下はサンプル


#!/usr/bin/env python
# -*- coding: utf-8 -*-
#export PYTHONPATH=$PYTHONPATH:/usr/lib/python2.6/site-packages/:$HOME/Fujiyama-Renderer/bin/
#set PYTHONPATH=C:\Python26;C:\Fujiyama-Renderer\python

import fujiyama
si = fujiyama.SceneInterface()

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


#Camera
si.NewCamera('cam1', 'PerspectiveCamera')
si.SetProperty3('cam1', 'rotate', -20, 0.00, 0.00)
si.SetProperty3('cam1', 'translate', 0.00, 6.00, 7.00)
si.SetProperty1('cam1', 'fov', 45)

#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)

#Texture
si.NewTexture( 'tex1', '../hdr/ennis.hdr')
si.NewTexture('tex2', '../hdr/uvmap.jpg')
si.NewTexture('tex3', '../hdr/00tex_master.jpg')


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


#Mesh
si.NewMesh('teapot_mesh', '../ply/meka.ply')
si.NewMesh('floor_mesh', '../ply/floor3.obj')
si.NewMesh('dome_mesh', '../ply/dome.ply')


#ObjectInstance
si.NewObjectInstance('teapot1','teapot_mesh')
si.SetProperty3('teapot1', 'translate', 0, 0, -2)
si.SetProperty3('teapot1', 'scale', 1.6, 1.6, 1.6)
si.AssignShader('teapot1','teapot_shader')
si.AssignTexture('teapot_shader', 'diffuse_map', 'tex3')


si.NewObjectInstance('floor1','floor_mesh')
si.SetProperty3('floor1','translate', 0, 0, -2.5)
si.SetProperty3('floor1','scale', .6, .6, .6)
si.SetProperty3('floor1','rotate', 90, 0, 0)
si.AssignShader('floor1','floor_shader')
si.AssignTexture('floor_shader', 'diffuse_map', 'tex2')

si.NewObjectInstance('dome1','dome_mesh')
si.SetProperty3( 'dome1', 'scale', .5, .5, .5)
si.SetProperty3( 'dome1', 'rotate', 0 ,135, 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')

#Properties
si.ShowPropertyList('Renderer')

#Renderer
si.NewRenderer('ren1')
si.AssignCamera('ren1', 'cam1')
si.AssignFrameBuffer('ren1', 'fb1')
#si.SetProperty2('ren1', 'resolution', 1024, 600)
si.SetProperty2('ren1', 'resolution', 512, 300)
#si.SetProperty2('ren1', 'resolution', 160, 120)


si.SetProperty1('ren1', 'raymarch_step', .01)
si.SetProperty1('ren1', 'raymarch_shadow_step', .02)
si.SetProperty1('ren1', 'raymarch_reflect_step', .02)


#Rendering
si.RenderScene('ren1')

#Output
si.SaveFrameBuffer('fb1', '../teapotscn03.exr')

#Run commands

si.Run()
#si.Print()




ありがとうございます。
Fujiyama Renderer | - | -

Fujiyama Renderer 0.2.3 for Windows7 64bit

Fujiyama is free and open source, distribution oriented ray-tracing renderer

Windows 64bit Binary
http://fujiyama-renderer.com/downloads.html

Download Fujiyama-Renderer-for-Win-v0.2.3-x64.zip

Create C:\Fujiyama-Renderer folder.

コンピュータ右クリック→プロパティ→システムの詳細設定→環境変数→システム環境変数内のPATHをクリック→「編集」をクリック
変数値の行の最後に以下のパスを記入します。

;C:\Fujiyama-Renderer\bin;

clip-1.jpg

Fujiyama-Rendererフォルダ内にmeshフォルダ、mipフォルダを作ります。
PLY Dataをダウンロードします。meshフォルダにモデルデータを入れます。
dome.ply
floor.ply
teapot.ply


コマンドプロンプトより
>ply2mesh dome.ply dome.mesh
>ply2mesh floor.ply floor.mesh
>ply2mesh teapot.ply teapot.mesh

モデルデータをmeshに変換しました。

次にHDRファイルをダウンロードします。
http://gl.ict.usc.edu/Data/HighResProbes/
glacier.hdr
grace-new.hdr
をダウンロードします。mipフォルダに入れます。

コマンドプロンプトより
>hdr2mip glacier.hdr glacier.mip
>hdr2mip grace-new.hdr grace-new.mip

HDRファイルをmipファイルに変換しました。

続いてsceneフォルダのシーンをレンダリングしてみましょう。
エディタでteapot.scnを開きます。
113行目
NewTexture tex1 ../../mip/grace-new.mip

NewTexture tex1 ../mip/grace-new.mip
に変更。

123行目
NewMesh teapot_mesh ../../mesh/teapot.mesh
NewMesh floor_mesh ../../mesh/floor.mesh
NewMesh dome_mesh ../../mesh/dome.mesh

NewMesh teapot_mesh ../mesh/teapot.mesh
NewMesh floor_mesh ../mesh/floor.mesh
NewMesh dome_mesh ../mesh/dome.mesh
に変更し保存します。

レンダリングします。
sceneフォルダからコマンドプロンプトを使って
>scene teapot.scn

C:\Fujiyama-Renderer\scenes>scene teapot.scn
-- OpenPlugin: [PlasticShader]
-- OpenPlugin: [GlassShader]
-- OpenPlugin: [ConstantShader]
-- NewCamera: [cam1] [PerspectiveCamera]
-- SetProperty3: [cam1] [translate] [0] [1] [7]
-- SetProperty3: [cam1] [rotate] [-5.710593137499643] [0] [0]
-- NewLight: [light0] [PointLight]
-- SetProperty3: [light0] [translate] [0.900771] [12] [4.09137]
-- SetProperty1: [light0] [intensity] [0.03125]
-- NewLight: [light1] [PointLight]
-- SetProperty3: [light1] [translate] [2.02315] [12] [5.28021]
-- SetProperty1: [light1] [intensity] [0.03125]
-- NewLight: [light2] [PointLight]
-- SetProperty3: [light2] [translate] [10.69] [12] [13.918]
-- SetProperty1: [light2] [intensity] [0.03125]
-- NewLight: [light3] [PointLight]
-- SetProperty3: [light3] [translate] [4.28027] [12] [7.58462]
-- SetProperty1: [light3] [intensity] [0.03125]
-- NewLight: [light4] [PointLight]
-- SetProperty3: [light4] [translate] [12.9548] [12] [1.19914]
-- SetProperty1: [light4] [intensity] [0.03125]
-- NewLight: [light5] [PointLight]
-- SetProperty3: [light5] [translate] [6.55808] [12] [2.31772]
-- SetProperty1: [light5] [intensity] [0.03125]
-- NewLight: [light6] [PointLight]
-- SetProperty3: [light6] [translate] [0.169064] [12] [10.9623]
-- SetProperty1: [light6] [intensity] [0.03125]
-- NewLight: [light7] [PointLight]
-- SetProperty3: [light7] [translate] [1.25002] [12] [4.51314]
-- SetProperty1: [light7] [intensity] [0.03125]
-- NewLight: [light8] [PointLight]
-- SetProperty3: [light8] [translate] [2.46758] [12] [5.73382]
-- SetProperty1: [light8] [intensity] [0.03125]
-- NewLight: [light9] [PointLight]
-- SetProperty3: [light9] [translate] [3.55644] [12] [6.84334]
-- SetProperty1: [light9] [intensity] [0.03125]
-- NewLight: [light10] [PointLight]
-- SetProperty3: [light10] [translate] [4.76112] [12] [8.00264]
-- SetProperty1: [light10] [intensity] [0.03125]
-- NewLight: [light11] [PointLight]
-- SetProperty3: [light11] [translate] [13.3267] [12] [9.10333]
-- SetProperty1: [light11] [intensity] [0.03125]
-- NewLight: [light12] [PointLight]
-- SetProperty3: [light12] [translate] [14.4155] [12] [2.68084]
-- SetProperty1: [light12] [intensity] [0.03125]
-- NewLight: [light13] [PointLight]
-- SetProperty3: [light13] [translate] [8.10755] [12] [3.79629]
-- SetProperty1: [light13] [intensity] [0.03125]
-- NewLight: [light14] [PointLight]
-- SetProperty3: [light14] [translate] [9.21103] [12] [4.9484]
-- SetProperty1: [light14] [intensity] [0.03125]
-- NewLight: [light15] [PointLight]
-- SetProperty3: [light15] [translate] [2.83469] [12] [6.09221]
-- SetProperty1: [light15] [intensity] [0.03125]
-- NewLight: [light16] [PointLight]
-- SetProperty3: [light16] [translate] [4.00945] [12] [7.18302]
-- SetProperty1: [light16] [intensity] [0.03125]
-- NewLight: [light17] [PointLight]
-- SetProperty3: [light17] [translate] [12.6072] [12] [0.832089]
-- SetProperty1: [light17] [intensity] [0.03125]
-- NewLight: [light18] [PointLight]
-- SetProperty3: [light18] [translate] [6.21169] [12] [1.98055]
-- SetProperty1: [light18] [intensity] [0.03125]
-- NewLight: [light19] [PointLight]
-- SetProperty3: [light19] [translate] [7.39599] [12] [10.5563]
-- SetProperty1: [light19] [intensity] [0.03125]
-- NewLight: [light20] [PointLight]
-- SetProperty3: [light20] [translate] [8.52421] [12] [4.15086]
-- SetProperty1: [light20] [intensity] [0.03125]
-- NewLight: [light21] [PointLight]
-- SetProperty3: [light21] [translate] [9.5891] [12] [5.39715]
-- SetProperty1: [light21] [intensity] [0.03125]
-- NewLight: [light22] [PointLight]
-- SetProperty3: [light22] [translate] [3.18967] [12] [13.9542]
-- SetProperty1: [light22] [intensity] [0.03125]
-- NewLight: [light23] [PointLight]
-- SetProperty3: [light23] [translate] [4.41432] [12] [0.082813]
-- SetProperty1: [light23] [intensity] [0.03125]
-- NewLight: [light24] [PointLight]
-- SetProperty3: [light24] [translate] [5.48803] [12] [1.21856]
-- SetProperty1: [light24] [intensity] [0.03125]
-- NewLight: [light25] [PointLight]
-- SetProperty3: [light25] [translate] [6.57647] [12] [2.31432]
-- SetProperty1: [light25] [intensity] [0.03125]
-- NewLight: [light26] [PointLight]
-- SetProperty3: [light26] [translate] [0.265098] [12] [10.9453]
-- SetProperty1: [light26] [intensity] [0.03125]
-- NewLight: [light27] [PointLight]
-- SetProperty3: [light27] [translate] [8.84422] [12] [12.1117]
-- SetProperty1: [light27] [intensity] [0.03125]
-- NewLight: [light28] [PointLight]
-- SetProperty3: [light28] [translate] [10.0154] [12] [5.67625]
-- SetProperty1: [light28] [intensity] [0.03125]
-- NewLight: [light29] [PointLight]
-- SetProperty3: [light29] [translate] [11.0907] [12] [14.4043]
-- SetProperty1: [light29] [intensity] [0.03125]
-- NewLight: [light30] [PointLight]
-- SetProperty3: [light30] [translate] [4.71726] [12] [7.98851]
-- SetProperty1: [light30] [intensity] [0.03125]
-- NewLight: [light31] [PointLight]
-- SetProperty3: [light31] [translate] [13.3907] [12] [9.08986]
-- SetProperty1: [light31] [intensity] [0.03125]
-- NewTexture: [tex1] [../mip/grace-new.mip]
-- NewShader: [teapot_shader] [GlassShader]
-- NewShader: [floor_shader] [PlasticShader]
-- NewShader: [dome_shader] [ConstantShader]
-- NewMesh: [teapot_mesh] [../mesh/teapot.mesh]
-- NewMesh: [floor_mesh] [../mesh/floor.mesh]
-- NewMesh: [dome_mesh] [../mesh/dome.mesh]
-- NewObjectInstance: [teapot1] [teapot_mesh]
-- AssignShader: [teapot1] [teapot_shader]
-- NewObjectInstance: [floor1] [floor_mesh]
-- SetProperty3: [floor1] [translate] [-2] [0] [-2]
-- AssignShader: [floor1] [floor_shader]
-- NewObjectInstance: [dome1] [dome_mesh]
-- SetProperty3: [dome1] [scale] [.5] [.5] [.5]
-- SetProperty3: [dome1] [rotate] [0] [30] [0]
-- AssignShader: [dome1] [dome_shader]
-- AssignTexture: [dome_shader] [texture] [tex1]
-- NewObjectGroup: [group1]
-- AddObjectToGroup: [group1] [teapot1]
-- AssignObjectGroup: [teapot1] [shadow_target] [group1]
-- AssignObjectGroup: [floor1] [shadow_target] [group1]
-- NewFrameBuffer: [fb1] [rgba]
-- NewRenderer: [ren1]
-- AssignCamera: [ren1] [cam1]
-- AssignFrameBuffer: [ren1] [fb1]
-- SetProperty2: [ren1] [resolution] [640] [480]
-- RenderScene: [ren1]

# Building Accelerators
# Accelerator Count: 8
# Building Accelerators Done
# 0h 0m 1s

# Preprocessing Lights
# Light Count: 32
# Preprocessing Lights Done
# 0h 0m 1s

# Rendering Frame
# Thread Count: 12
# Tile Count: 80

....1....2....3....4....5....6....7....8....9....0
-------------------------------------------------- 10% (0h 0m 1s)
....1....2....3....4....5....6....7....8....9....0
-------------------------------------------------- 20% (0h 0m 1s)
....1....2....3....4....5....6....7....8....9....0
-------------------------------------------------- 30% (0h 0m 1s)
....1....2....3....4....5....6....7....8....9....0
-------------------------------------------------- 40% (0h 0m 1s)
....1....2....3....4....5....6....7....8....9....0
-------------------------------------------------- 50% (0h 0m 2s)
....1....2....3....4....5....6....7....8....9....0
-------------------------------------------------- 60% (0h 0m 5s)
....1....2....3....4....5....6....7....8....9....0
-------------------------------------------------- 70% (0h 0m 10s)
....1....2....3....4....5....6....7....8....9....0
-------------------------------------------------- 80% (0h 0m 11s)
....1....2....3....4....5....6....7....8....9....0
-------------------------------------------------- 90% (0h 0m 12s)
....1....2....3....4....5....6....7....8....9....0
-------------------------------------------------- 100% (0h 0m 16s)

# Frame Done
# 0h 0m 16s

-- SaveFrameBuffer: [fb1] [../teapot.fb]

画像を確認します。コマンドプロンプトを使って
>fbview ../teapot.fb

ウインドウを広くしてあげると良いです。
clip-2.jpg

OpenEXRファイルに変換するには、変換したいfbファイルがある場所で
コマンドプロンプトを使って
>fb2exr teapot.fb teapot.exr

fujiyama rendererでpythonを使う場合、fujiyama/bin/フォルダにfujiyama.pyをコピーします。
fujiyama.pyファイルを開いて、31と41行目のbin/sceneと二箇所書いてあるところのbin/を削除して保存します。後はset pythonpath=で通してからレンダリングを行います。

>set PYTHONPATH=C:\Python26;C:\Fujiyama-Renderer\bin

例えば、
>python sample.py
でimport fujiyamaが動き、レンダリングします。
シーンファイル内の各モデルや画像のパスを調整してからレンダリングしてください。
Fujiyama Renderer | - | -

はじめてのFujiyama Renderer その29

Fujiyama Renderer 0.2.1がリリースされました。既にmulti threadsでのレンダリングで速くなっている。
バンプ・マッピングができるようになりました。
bump_mapping.jpg
sphere_uv.plyを利用してます。TextureはFujiyama RendererのDownloadsからのリンクを利用しました。以下はPython APIを利用、例です。ありがとうございます。


#!/usr/bin/env python

# 4 textured spheres with 1 dome light with an HDRI
# Copyright (c) 2011-2013 Hiroshi Tsubokawa

import fujiyama

si = fujiyama.SceneInterface()

#Plugins
si.OpenPlugin('ConstantShader')
si.OpenPlugin('PlasticShader')

#Camera
si.NewCamera('cam1', 'PerspectiveCamera')
si.SetProperty3('cam1', 'translate', 0, 0, 10)

# Rotation of dome light and dome object used for background iamge.
rot = 110

#Texture
si.NewTexture('env_tex1', '../mip/pisa.mip')
si.NewTexture('rock_tex1', '../mip/rock.mip')
si.NewTexture('rust_tex1', '../mip/rust.mip')
si.NewTexture('concrete_tex1', '../mip/concrete.mip')
si.NewTexture('pattern_tex1', '../mip/pattern.mip')

#Light
si.NewLight('light1', 'DomeLight')
si.SetProperty3('light1', 'rotate', 0, rot, 0)
# You chang the number of samples on the env map. the default is 16.
#si.SetProperty1('light1', 'sample_count', 256)
si.SetProperty1('light1', 'sample_count', 32)
si.AssignTexture('light1', 'environment_map', 'env_tex1');

#Shader
si.NewShader('sphere_shader1', 'PlasticShader')
si.AssignTexture('sphere_shader1', 'diffuse_map', 'rock_tex1')
si.AssignTexture('sphere_shader1', 'bump_map', 'rock_tex1')
si.SetProperty1('sphere_shader1', 'bump_amplitude', 1)

si.NewShader('sphere_shader2', 'PlasticShader')
si.AssignTexture('sphere_shader2', 'diffuse_map', 'rust_tex1')
si.AssignTexture('sphere_shader2', 'bump_map', 'rust_tex1')
si.SetProperty1('sphere_shader2', 'bump_amplitude', 1)

si.NewShader('sphere_shader3', 'PlasticShader')
si.AssignTexture('sphere_shader3', 'diffuse_map', 'concrete_tex1')
si.AssignTexture('sphere_shader3', 'bump_map', 'concrete_tex1')
si.SetProperty1('sphere_shader3', 'bump_amplitude', 1)

si.NewShader('sphere_shader4', 'PlasticShader')
si.AssignTexture('sphere_shader4', 'diffuse_map', 'pattern_tex1')
si.AssignTexture('sphere_shader4', 'bump_map', 'pattern_tex1')
si.SetProperty1('sphere_shader4', 'bump_amplitude', -1)

si.SetProperty3('sphere_shader4', 'diffuse', .5, .5, .5)
si.SetProperty1('sphere_shader4', 'ior', 10)

si.NewShader('dome_shader', 'ConstantShader')
si.AssignTexture('dome_shader', 'texture', 'env_tex1')

#Mesh
si.NewMesh('sphere_mesh', '../mesh/sphere_uv.mesh')
si.NewMesh('dome_mesh', '../mesh/dome.mesh')

#ObjectInstance
si.NewObjectInstance('sphere1', 'sphere_mesh')
si.SetProperty3('sphere1', 'translate', -1.7, 1.2, 0)
si.AssignShader('sphere1', 'sphere_shader1')

si.NewObjectInstance('sphere2', 'sphere_mesh')
si.SetProperty3('sphere2', 'translate', 1.7, 1.2, 0)
si.SetProperty3('sphere2', 'rotate', 0, 20, 0)
si.AssignShader('sphere2', 'sphere_shader2')

si.NewObjectInstance('sphere3', 'sphere_mesh')
si.SetProperty3('sphere3', 'translate', -1.7, -1.2, 0)
si.SetProperty3('sphere3', 'rotate', 0, 20, 0)
si.AssignShader('sphere3', 'sphere_shader3')

si.NewObjectInstance('sphere4', 'sphere_mesh')
si.SetProperty3('sphere4', 'translate', 1.7, -1.2, 0)
si.AssignShader('sphere4', 'sphere_shader4')

si.NewObjectInstance('dome1', 'dome_mesh')
si.SetProperty3('dome1', 'rotate', 0, rot, 0)
si.SetProperty3('dome1', 'scale', -.5, .5, .5)
si.AssignShader('dome1', 'dome_shader')

#ObjectGroup
# Create shadow_target for sphere1.
# Since 'DomeLight' has infinite distance, we need to exclude
# 'dome1' object which is for just background image.
si.NewObjectGroup('shadow_target1')
si.AddObjectToGroup('shadow_target1', 'sphere1')
si.AssignObjectGroup('sphere1', 'shadow_target', 'shadow_target1')
# and each sphere reacts to only 'dome1' and itself, not to the other spheres
si.NewObjectGroup('reflect_target1')
si.AddObjectToGroup('reflect_target1', 'dome1')
si.AddObjectToGroup('reflect_target1', 'sphere1')
si.AssignObjectGroup('sphere1', 'reflect_target', 'reflect_target1')

si.NewObjectGroup('shadow_target2')
si.AddObjectToGroup('shadow_target2', 'sphere2')
si.AssignObjectGroup('sphere2', 'shadow_target', 'shadow_target2')
si.NewObjectGroup('reflect_target2')
si.AddObjectToGroup('reflect_target2', 'dome1')
si.AddObjectToGroup('reflect_target2', 'sphere2')
si.AssignObjectGroup('sphere2', 'reflect_target', 'reflect_target2')

si.NewObjectGroup('shadow_target3')
si.AddObjectToGroup('shadow_target3', 'sphere3')
si.AssignObjectGroup('sphere3', 'shadow_target', 'shadow_target3')
si.NewObjectGroup('reflect_target3')
si.AddObjectToGroup('reflect_target3', 'dome1')
si.AddObjectToGroup('reflect_target3', 'sphere3')
si.AssignObjectGroup('sphere3', 'reflect_target', 'reflect_target3')

si.NewObjectGroup('shadow_target4')
si.AddObjectToGroup('shadow_target4', 'sphere4')
si.AssignObjectGroup('sphere4', 'shadow_target', 'shadow_target4')
si.NewObjectGroup('reflect_target4')
si.AddObjectToGroup('reflect_target4', 'dome1')
si.AddObjectToGroup('reflect_target4', 'sphere4')
si.AssignObjectGroup('sphere4', 'reflect_target', 'reflect_target4')

#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
si.SaveFrameBuffer('fb1', '../bump_mapping.fb')

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


他、Point Cloudsを試しました。こちらもサンプルPython APIを利用してます。
point_cloud.jpg
Fujiyama Renderer | - | -

はじめてのFujiyama Renderer その28

Fujiyama Renderer0.1.3リリースされた。
SSS(Subsurface scattering shader)が使えるようになりました。皮膚や牛乳のような物質の表現ができる。

試しにTeapotを4つの設定でやってみる。光の当て方と視点を検討。
レンダリング時間 1h 28m 45s
teapotscn02.jpg

以下はPythonサンプル


#!/usr/bin/env python
# -*- coding: utf-8 -*-

#export PYTHONPATH=$PYTHONPATH:/usr/lib/python2.6/site-packages/:$HOME/Fujiyama-Renderer/bin/
from colorinc import si

import fujiyama

#si = fujiyama.SceneInterface()

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

#Camera
si.NewCamera('cam1', 'PerspectiveCamera')
si.SetProperty3('cam1', 'rotate', -30, 0.00, 0.00)
si.SetProperty3('cam1', 'translate', 0.00, 6.00, 7.00)
si.SetProperty1('cam1', 'fov', 35)

#Light
"""
si.NewLight('lighta', 'PointLight')
si.SetProperty3('lighta', 'translate', -5, 4, 5)
si.SetProperty1('lighta', 'intensity', 0.03)

si.NewLight('lightb', 'SphereLight')
si.SetProperty3('lightb', 'translate', 5, 4, 5)
si.SetProperty3('lightb', 'scale', .5, .5, .5)
si.SetProperty1('lightb', 'intensity', 0.03)
"""
#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)

#Texture
si.NewTexture( 'tex1', '../mip/ennis.mip')
si.NewTexture('tex2', '../mip/uvmap.mip')

#Shader
si.NewShader('floor_shader', 'PlasticShader')
si.NewShader('dome_shader', 'ConstantShader')
#Shader
si.NewShader('teapot_shader1', 'SSSShader')
si.SetProperty3('teapot_shader1', 'reflect', 0, 0, 0)
si.SetProperty1('teapot_shader1', 'enable_single_scattering', 1)
si.SetProperty1('teapot_shader1', 'enable_multiple_scattering', 0)
si.SetProperty1('teapot_shader1', 'single_scattering_samples', 1)
si.SetProperty1('teapot_shader1', 'multiple_scattering_samples', 1)
si.SetProperty3('teapot_shader1', 'scattering_coefficient', .007, .018, .003)
si.SetProperty3('teapot_shader1', 'absorption_coefficient', .097, .0061, .145)

si.NewShader('teapot_shader2', 'SSSShader')
si.SetProperty3('teapot_shader2', 'reflect', 0, 0, 0)
si.SetProperty1('teapot_shader2', 'enable_single_scattering', 1)
si.SetProperty1('teapot_shader2', 'enable_multiple_scattering', 0)
si.SetProperty1('teapot_shader2', 'single_scattering_samples', 1)
si.SetProperty1('teapot_shader2', 'multiple_scattering_samples', 1)
si.SetProperty3('teapot_shader2', 'scattering_coefficient', .07, .122, .19)
si.SetProperty3('teapot_shader2', 'absorption_coefficient', .00014, .00025, .00142)
si.SetProperty3('teapot_shader2', 'specular', .01, .01, .01)

si.NewShader('teapot_shader3', 'SSSShader')
si.SetProperty3('teapot_shader3', 'reflect', 0, 0, 0)
si.SetProperty1('teapot_shader3', 'enable_single_scattering', 1)
si.SetProperty1('teapot_shader3', 'enable_multiple_scattering', 0)
si.SetProperty1('teapot_shader3', 'single_scattering_samples', 1)
si.SetProperty1('teapot_shader3', 'multiple_scattering_samples', 1)
si.SetProperty3('teapot_shader3', 'scattering_coefficient', .074, .088, .101)
si.SetProperty3('teapot_shader3', 'absorption_coefficient', .0032, .017, .048)
si.SetProperty3('teapot_shader3', 'specular', .1, .1, .1)
si.SetProperty1('teapot_shader3', 'roughness', .2)

si.NewShader('teapot_shader4', 'SSSShader')
si.SetProperty3('teapot_shader4', 'reflect', 0, 0, 0)
si.SetProperty1('teapot_shader4', 'enable_single_scattering', 1)
si.SetProperty1('teapot_shader4', 'enable_multiple_scattering', 0)
si.SetProperty1('teapot_shader4', 'single_scattering_samples', 1)
si.SetProperty1('teapot_shader4', 'multiple_scattering_samples', 1)
si.SetProperty3('teapot_shader4', 'scattering_coefficient', .255, .321, .377)
si.SetProperty3('teapot_shader4', 'absorption_coefficient', .00011, .00024, .0014)


#Mesh
si.NewMesh('teapot_mesh', '../mesh/teapot.mesh')
si.NewMesh('floor_mesh', '../mesh/floor2.mesh')
si.NewMesh('dome_mesh', '../mesh/dome.mesh')

#ObjectInstance
#ObjectInstance
si.NewObjectInstance('teapot1','teapot_mesh')
si.SetProperty3('teapot1', 'translate', -1.7, 0.5, -3)
si.SetProperty3('teapot1', 'scale', 1.6, 1.6, 1.6)
si.AssignShader('teapot1','teapot_shader1')

si.NewObjectInstance('teapot2','teapot_mesh')
si.SetProperty3('teapot2', 'translate', 1.7, 0.5, -3)
si.SetProperty3('teapot2', 'scale', 1.6, 1.6, 1.6)
si.AssignShader('teapot2','teapot_shader2')

si.NewObjectInstance('teapot3','teapot_mesh')
si.SetProperty3('teapot3', 'translate', 1.7, 0.5, 0)
si.SetProperty3('teapot3', 'scale', 1.6, 1.6, 1.6)
si.AssignShader('teapot3','teapot_shader3')

si.NewObjectInstance('teapot4','teapot_mesh')
si.SetProperty3('teapot4', 'translate', -1.7, 0.5, 0)
si.SetProperty3('teapot4', 'scale', 1.6, 1.6, 1.6)
si.AssignShader('teapot4','teapot_shader4')

si.NewObjectInstance('floor1','floor_mesh')
si.SetProperty3('floor1','translate', 0, 0, -2.5)
si.SetProperty3('floor1','scale', 1.1, 1.1, 1.1)
si.SetProperty3('floor1','rotate', 0, 0, 0)
si.AssignShader('floor1','floor_shader')
si.AssignTexture('floor_shader', 'diffuse_map', 'tex2')

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

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


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

#Properties
si.ShowPropertyList('Renderer')

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

si.SetProperty1('ren1', 'raymarch_step', .01)
si.SetProperty1('ren1', 'raymarch_shadow_step', .02)
si.SetProperty1('ren1', 'raymarch_reflect_step', .02)

#Rendering
si.RenderScene('ren1')

#Output
si.SaveFrameBuffer('fb1', '../teapotscn02.fb')

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



teapot33.jpg
Fujiyama Renderer | - | -

はじめてのFujiyama Renderer その27

アンティーク扇風機のモデルをFujiyama Rendererでレンダリングした。
3DSフォーマットをBlenderでPlyに変換出力した。
mekas4.jpg

ありがとうございます。


#!/usr/bin/env python
from math import *
#export PYTHONPATH=$PYTHONPATH:/usr/lib/python2.6/site-packages/:$HOME/Fujiyama-Renderer/bin/

#from colorinc import si

import fujiyama

si = fujiyama.SceneInterface()

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

#Camera
si.NewCamera('cam1', 'PerspectiveCamera')

#Calculate python fujicam.py -3 4 5 0 1.3 0
si.SetSampleProperty3('cam1', 'rotate', -24.85, -30.96, 0, 0)
si.SetSampleProperty3('cam1', 'translate', -3, 4, 5, 0)
#si.SetSampleProperty3('cam1', 'translate', 0, 1, 5, 0)

si.SetProperty1('cam1', 'fov', 30)

#Light
si.NewLight('light1', 'SphereLight')
si.SetProperty3('light1', 'translate', 10, 10, 10)
si.SetProperty3('light1', 'scale', .5, .5, .5)
si.SetProperty1('light1', 'intensity', 1.5)
si.SetProperty1('light1', 'sample_count', 16)

si.NewLight('light2', 'SphereLight')
si.SetProperty3('light2', 'translate', -5, 10, 10)
si.SetProperty3('light2', 'scale', .5, .5, .5)
si.SetProperty1('light2', 'intensity', 1.5)
si.SetProperty1('light2', 'sample_count', 16)

#Texture
si.NewTexture('tex1', '../mip/pisa.mip')

#Shader
si.NewShader('dome_shader', 'ConstantShader')
si.AssignTexture('dome_shader', 'texture', 'tex1')

si.NewShader('floor_shader', 'PlasticShader')
si.SetProperty3('floor_shader', 'diffuse', .9, .2, .2)
si.SetProperty1('floor_shader', 'ior', 4)

intensity = 0
si.NewShader('sphere_shader', 'PlasticShader')
si.SetProperty3('sphere_shader', 'diffuse', intensity, intensity, intensity)
si.SetProperty1('sphere_shader', 'ior', 40)

si.NewShader('obj_shader', 'PlasticShader')
si.SetProperty3('obj_shader', 'diffuse', 0.2, 0.4, 0.6)
si.SetProperty3('obj_shader', 'reflect', 0.9, 0.9, 0.9)
si.SetProperty1('obj_shader', 'ior', 4)

si.NewShader('obj2_shader', 'PlasticShader')
si.SetProperty3('obj2_shader', 'diffuse', 1, 1, 0.1)
si.SetProperty1('obj2_shader', 'ior', 8)
#Mesh
si.NewMesh('dome_mesh', '../mesh/dome.mesh')
si.NewMesh('floor_mesh', '../mesh/floor.mesh')
si.NewMesh('senpuuki_mesh', '../mesh/senpuuki.mesh')

#ObjectInstance
si.NewObjectInstance('dome1', 'dome_mesh')
si.SetProperty3('dome1', 'rotate', 0, 0, 0)

#ObjectInstance
si.NewObjectInstance('sen1', 'senpuuki_mesh')
si.AssignShader('sen1', 'obj_shader')
si.SetProperty3('sen1', 'scale',1,1,1)
si.SetProperty3('sen1', 'translate',0,0.1,0)
si.SetProperty3('sen1', 'rotate',-90,0,0)

#si.SetProperty3('dome1', 'scale', -.5, .5, .5)
si.SetProperty3('dome1', 'scale', -2, 2, 2)
si.AssignShader('dome1', 'dome_shader')

si.NewObjectInstance('floor1', 'floor_mesh')
si.SetProperty3('floor1', 'scale', 50, 50, 50)
si.SetProperty3('floor1', 'translate', 0, 0, 0)
si.AssignShader('floor1', 'floor_shader')

#ObjectGroup
si.NewObjectGroup('group1')
si.AddObjectToGroup('group1', 'sen1')
si.AssignObjectGroup('sen1', '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', 512, 384)
#si.SetProperty2('ren1', 'resolution', 160, 120)
si.SetProperty2('ren1', 'pixelsamples', 4, 4)

#Rendering
si.RenderScene('ren1')

#Output
si.SaveFrameBuffer('fb1', '../mekas2.fb')

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


Fujiyama Renderer | - | -

はじめてのFujiyama Renderer その26

七葉3DCG保管庫にあるメカサワくんモデルを変換してFujiyama Rendererでレンダリングしてみた。
元データは3dsフォーマットであり、Blenderで3dsインポートし、部品ごとにplyエクスポートして、Fujiyama Rendererでれんだりんぐしてみたが、shaderのカラーが真っ黒で変更しても変わらないことがわかる。原因は、元データの面の向きが裏返しになっていた。Blenderで部品を選択しEdit modeでflip directionを行い、ply出力した。
今回部品は、次のように分けた。すべて法線フリップしてPly出力している。
ボディ、mekabody
目、mekame
手、mekate
と分けた。
mekas1.jpg

mekas2.jpg

mekas3.jpg
以下はPythonサンプル


#!/usr/bin/env python
from math import *
#export PYTHONPATH=$PYTHONPATH:/usr/lib/python2.6/site-packages/:$HOME/Fujiyama-Renderer/bin/

#from colorinc import si

import fujiyama

si = fujiyama.SceneInterface()

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

#Camera
si.NewCamera('cam1', 'PerspectiveCamera')

#Calculate python fujicam.py 3 4 5 0 1 0
si.SetSampleProperty3('cam1', 'rotate', -27.23, 30.96, 0, 0)
si.SetSampleProperty3('cam1', 'translate', 3, 4, 5, 0)
#si.SetSampleProperty3('cam1', 'translate', 0, 1, 5, 0)

si.SetProperty1('cam1', 'fov', 25)

#Light
si.NewLight('light1', 'SphereLight')
si.SetProperty3('light1', 'translate', 10, 10, 10)
si.SetProperty3('light1', 'scale', .5, .5, .5)
si.SetProperty1('light1', 'intensity', 1.5)
si.SetProperty1('light1', 'sample_count', 16)

si.NewLight('light2', 'SphereLight')
si.SetProperty3('light2', 'translate', -5, 10, 10)
si.SetProperty3('light2', 'scale', .5, .5, .5)
si.SetProperty1('light2', 'intensity', 1.5)
si.SetProperty1('light2', 'sample_count', 16)

#Texture
si.NewTexture('tex1', '../mip/pisa.mip')

#Shader
si.NewShader('dome_shader', 'ConstantShader')
si.AssignTexture('dome_shader', 'texture', 'tex1')

si.NewShader('floor_shader', 'PlasticShader')
si.SetProperty3('floor_shader', 'diffuse', .9, .2, .2)
si.SetProperty1('floor_shader', 'ior', 4)

intensity = 0
si.NewShader('sphere_shader', 'PlasticShader')
si.SetProperty3('sphere_shader', 'diffuse', intensity, intensity, intensity)
si.SetProperty1('sphere_shader', 'ior', 40)

si.NewShader('obj_shader', 'PlasticShader')
si.SetProperty3('obj_shader', 'diffuse', 0.2, 0.4, 0.6)
si.SetProperty3('obj_shader', 'reflect', 0.9, 0.9, 0.9)
si.SetProperty1('obj_shader', 'ior', 4)

si.NewShader('obj2_shader', 'PlasticShader')
si.SetProperty3('obj2_shader', 'diffuse', 1, 1, 0.1)
si.SetProperty1('obj2_shader', 'ior', 8)
#Mesh
si.NewMesh('dome_mesh', '../mesh/dome.mesh')
si.NewMesh('floor_mesh', '../mesh/floor.mesh')
si.NewMesh('mekaeye_mesh', '../mesh/mekame.mesh')
si.NewMesh('mekabody_mesh', '../mesh/mekabody.mesh')
si.NewMesh('mekate_mesh', '../mesh/mekate.mesh')


#ObjectInstance
si.NewObjectInstance('dome1', 'dome_mesh')
si.SetProperty3('dome1', 'rotate', 0, 0, 0)

#ObjectInstance
si.NewObjectInstance('mekae1', 'mekaeye_mesh')
#si.SetProperty1('mekae1', 'transform_order', 'ORDER_STR')
si.AssignShader('mekae1', 'obj2_shader')
si.SetProperty3('mekae1', 'scale',1,1,1)
si.SetProperty3('mekae1', 'translate',0,0.1,0)
si.SetProperty3('mekae1', 'rotate',-90,0,0)


si.NewObjectInstance('mekab1', 'mekabody_mesh')
#si.SetProperty1('mekab1', 'transform_order', 'ORDER_STR')
si.AssignShader('mekab1', 'obj_shader' )
si.SetProperty3('mekab1', 'scale',1,1,1)
si.SetProperty3('mekab1', 'translate',0,0.1,0)
si.SetProperty3('mekab1', 'rotate',-90,0,0)


si.NewObjectInstance('mekat1', 'mekate_mesh')
#si.SetProperty1('mekab1', 'transform_order', 'ORDER_STR')
si.AssignShader('mekat1', 'obj_shader' )
si.SetProperty3('mekat1', 'scale',1,1,1)
si.SetProperty3('mekat1', 'translate',0,0.1,0)
si.SetProperty3('mekat1', 'rotate',-90,0,0)

#si.SetProperty3('dome1', 'scale', -.5, .5, .5)
si.SetProperty3('dome1', 'scale', -2, 2, 2)
si.AssignShader('dome1', 'dome_shader')

si.NewObjectInstance('floor1', 'floor_mesh')
si.SetProperty3('floor1', 'scale', 50, 50, 50)
si.SetProperty3('floor1', 'translate', 0, 0, 0)
si.AssignShader('floor1', 'floor_shader')

#ObjectGroup
si.NewObjectGroup('group1')
si.AddObjectToGroup('group1', 'mekae1')
si.AddObjectToGroup('group1', 'mekat1')
si.AddObjectToGroup('group1', 'mekab1')
si.AssignObjectGroup('mekae1', 'shadow_target', 'group1')
si.AssignObjectGroup('mekat1', 'shadow_target', 'group1')
si.AssignObjectGroup('mekab1', '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', 512, 384)
#si.SetProperty2('ren1', 'resolution', 160, 120)
si.SetProperty2('ren1', 'pixelsamples', 4, 4)

#Rendering
si.RenderScene('ren1')

#Output
si.SaveFrameBuffer('fb1', '../mekas1.fb')

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


Fujiyama Renderer | - | -

はじめてのFujiyama Renderer その25

POV-Ray記事を参考に積み木をつくってみた。
参考サイト
http://monge.tec.fukuoka-u.ac.jp/cg_PovRay/box06A+6B.html

povsp8.jpg

以下はPythonサンプル例です。


#!/usr/bin/env python
from math import *
#export PYTHONPATH=$PYTHONPATH:/usr/lib/python2.6/site-packages/:$HOME/Fujiyama-Renderer/bin/

from colorinc import si

import fujiyama

#si = fujiyama.SceneInterface()

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

#Camera
si.NewCamera('cam1', 'PerspectiveCamera')

#Calculate python fujicam.py 0 20 20 0 0 0
si.SetSampleProperty3('cam1', 'rotate', -45, 0, 0, 0)
si.SetSampleProperty3('cam1', 'translate', 0, 20, 20, 0)
#si.SetSampleProperty3('cam1', 'translate', 0, 1, 10, 0)

si.SetProperty1('cam1', 'fov', 42)

#Light
si.NewLight('light1', 'SphereLight')
si.SetProperty3('light1', 'translate', 10, 10, 10)
si.SetProperty3('light1', 'scale', .5, .5, .5)
si.SetProperty1('light1', 'intensity', 1.5)
si.SetProperty1('light1', 'sample_count', 16)

si.NewLight('light2', 'SphereLight')
si.SetProperty3('light2', 'translate', -5, 10, 10)
si.SetProperty3('light2', 'scale', .5, .5, .5)
si.SetProperty1('light2', 'intensity', 1.5)
si.SetProperty1('light2', 'sample_count', 16)

#Texture
si.NewTexture('tex1', '../mip/pisa.mip')

#Shader
si.NewShader('dome_shader', 'ConstantShader')
si.AssignTexture('dome_shader', 'texture', 'tex1')

si.NewShader('floor_shader', 'PlasticShader')
si.SetProperty3('floor_shader', 'diffuse', .9, .2, .2)
si.SetProperty1('floor_shader', 'ior', 4)

intensity = 0
si.NewShader('sphere_shader', 'PlasticShader')
si.SetProperty3('sphere_shader', 'diffuse', intensity, intensity, intensity)
si.SetProperty1('sphere_shader', 'ior', 40)

#Mesh
si.NewMesh('dome_mesh', '../mesh/dome.mesh')
si.NewMesh('floor_mesh', '../mesh/floor.mesh')
si.NewMesh('sphere_mesh', '../mesh/sphere.mesh')
si.NewMesh('cube_mesh', '../mesh/cube.mesh')


#ObjectInstance
si.NewObjectInstance('dome1', 'dome_mesh')
si.SetProperty3('dome1', 'rotate', 0, 0, 0)

#ObjectInstance
j=1
K=-5
bxname=[]
while(K<5):
bxname.append('cube'+str(j))
si.NewObjectInstance('cube'+str(j), 'cube_mesh')
si.SetProperty1('cube'+str(j), 'transform_order', 'ORDER_STR')
si.AssignShader('cube'+str(j), 'Blue_shader' )
si.SetProperty3('cube'+str(j), 'scale',1,3,1)
si.SetProperty3('cube'+str(j), 'translate',K,1.6,3)

K=K+1.75
j+=1

j=7
K=-3
while(K<5):
bxname.append('cube'+str(j))
si.NewObjectInstance('cube'+str(j), 'cube_mesh')
si.SetProperty1('cube'+str(j), 'transform_order', 'ORDER_STR')
si.AssignShader('cube'+str(j), 'ForestGreen_shader' )
si.SetProperty3('cube'+str(j), 'scale',1,3,1)
si.SetProperty3('cube'+str(j), 'translate',K-1,4.6,3)

K=K+1.75
j+=1

j=12
K=-2
while(K<5):
bxname.append('cube'+str(j))
si.NewObjectInstance('cube'+str(j), 'cube_mesh')
si.SetProperty1('cube'+str(j), 'transform_order', 'ORDER_STR')
si.AssignShader('cube'+str(j), 'Orange_shader' )
si.SetProperty3('cube'+str(j), 'scale',1,3,1)
si.SetProperty3('cube'+str(j), 'translate',K-1,7.6,3)

K=K+1.75
j+=1

j=16
K=-1
while(K<4):
bxname.append('cube'+str(j))
si.NewObjectInstance('cube'+str(j), 'cube_mesh')
si.SetProperty1('cube'+str(j), 'transform_order', 'ORDER_STR')
si.AssignShader('cube'+str(j), 'Coral_shader' )
si.SetProperty3('cube'+str(j), 'scale',1,3,1)
si.SetProperty3('cube'+str(j), 'translate',K-1,10.6,3)

K=K+1.75
j+=1


#si.SetProperty3('dome1', 'scale', -.5, .5, .5)
si.SetProperty3('dome1', 'scale', -2, 2, 2)
si.AssignShader('dome1', 'dome_shader')

si.NewObjectInstance('floor1', 'floor_mesh')
si.SetProperty3('floor1', 'scale', 50, 50, 50)
si.SetProperty3('floor1', 'translate', 0, 0, 0)
si.AssignShader('floor1', 'floor_shader')

#ObjectGroup
si.NewObjectGroup('group1')
for i in bxname:
si.AddObjectToGroup('group1', i)

for i in bxname:
si.AssignObjectGroup(i, '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', 512, 384)
#si.SetProperty2('ren1', 'resolution', 160, 120)
si.SetProperty2('ren1', 'pixelsamples', 2, 2)

#Rendering
si.RenderScene('ren1')

#Output
si.SaveFrameBuffer('fb1', '../povsp8.fb')

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


Fujiyama Renderer | - | -

はじめてのFujiyama Renderer その24

球体を5つ並べてみました。くりかえし処理を使います。
sphereの X座標を変えていくことで、横に並びます。
povsp7.jpg
以下はPythonサンプルです。


#!/usr/bin/env python
from math import *
#export PYTHONPATH=$PYTHONPATH:/usr/lib/python2.6/site-packages/:$HOME/Fujiyama-Renderer/bin/
import fujiyama

si = fujiyama.SceneInterface()

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

#Camera
si.NewCamera('cam1', 'PerspectiveCamera')

#Calculate python fujicam.py 0 10 10 0 0 0
si.SetSampleProperty3('cam1', 'rotate', -45, 0, 0, 0)
si.SetSampleProperty3('cam1', 'translate', 0, 10, 10, 0)
#si.SetSampleProperty3('cam1', 'translate', 0, 1, 10, 0)

si.SetProperty1('cam1', 'fov', 45)

#Light
si.NewLight('light1', 'SphereLight')
si.SetProperty3('light1', 'translate', 10, 10, 10)
si.SetProperty3('light1', 'scale', .5, .5, .5)
si.SetProperty1('light1', 'intensity', 1.5)
si.SetProperty1('light1', 'sample_count', 16)

si.NewLight('light2', 'SphereLight')
si.SetProperty3('light2', 'translate', -5, 10, 10)
si.SetProperty3('light2', 'scale', .5, .5, .5)
si.SetProperty1('light2', 'intensity', 1.5)
si.SetProperty1('light2', 'sample_count', 16)

#Texture
si.NewTexture('tex1', '../mip/pisa.mip')

#Shader
si.NewShader('dome_shader', 'ConstantShader')
si.AssignTexture('dome_shader', 'texture', 'tex1')

si.NewShader('floor_shader', 'PlasticShader')
si.SetProperty3('floor_shader', 'diffuse', .9, .2, .2)
si.SetProperty1('floor_shader', 'ior', 4)

intensity = 0
si.NewShader('sphere_shader', 'PlasticShader')
si.SetProperty3('sphere_shader', 'diffuse', intensity, intensity, intensity)
si.SetProperty1('sphere_shader', 'ior', 40)

#Mesh
si.NewMesh('dome_mesh', '../mesh/dome.mesh')
si.NewMesh('floor_mesh', '../mesh/floor.mesh')
si.NewMesh('sphere_mesh', '../mesh/sphere.mesh')


#ObjectInstance
si.NewObjectInstance('dome1', 'dome_mesh')
si.SetProperty3('dome1', 'rotate', 0, 0, 0)

j=0
X=-5
spname=[]

while (X<5):
spname.append('sphere'+str(j))
si.NewObjectInstance('sphere'+str(j), 'sphere_mesh')
si.SetProperty1('sphere'+str(j), 'transform_order', 'ORDER_STR')
si.AssignShader('sphere'+str(j), 'sphere_shader' )
si.SetProperty3('sphere'+str(j), 'scale',0.75,0.75,0.75)
si.SetProperty3('sphere'+str(j), 'translate',X,0.75,0)
X=X+2
j+=1


#si.SetProperty3('dome1', 'scale', -.5, .5, .5)
si.SetProperty3('dome1', 'scale', -2, 2, 2)
si.AssignShader('dome1', 'dome_shader')

si.NewObjectInstance('floor1', 'floor_mesh')
si.SetProperty3('floor1', 'scale', 50, 50, 50)
si.SetProperty3('floor1', 'translate', 0, 0, 0)
si.AssignShader('floor1', 'floor_shader')

#ObjectGroup
si.NewObjectGroup('group1')
for i in spname:
si.AddObjectToGroup('group1', i)

for i in spname:
si.AssignObjectGroup(i, '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', 512, 384)
#si.SetProperty2('ren1', 'resolution', 160, 120)
si.SetProperty2('ren1', 'pixelsamples', 2, 2)

#Rendering
si.RenderScene('ren1')

#Output
si.SaveFrameBuffer('fb1', '../povsp7.fb')

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


Fujiyama Renderer | - | -

はじめてのFujiyama Renderer その23

Fujiyama Rendererで物体の回転を検討します。今回は「3DCGをはじめようPOV-Ray入門」の繰り返し処理を参考にPythonサンプルを組んでみました。

変換の順序を変更できるFujiyama Rendererは便利です。
si.SetProperty1('sphere'+str(j), 'transform_order', 'ORDER_STR')
を記述しておきます。

以下はカメラ位置
si.SetSampleProperty3('cam1', 'translate', 0, 1, 10, 0)
から見たところです。
povsp60.jpg

繰り返しの記述は以下のようにしました。


j=0
Count=0
spname=[]
while (Count<10):
spname.append('sphere'+str(j))
si.NewObjectInstance('sphere'+str(j), 'sphere_mesh')
si.SetProperty1('sphere'+str(j), 'transform_order', 'ORDER_STR')
si.AssignShader('sphere'+str(j), 'sphere_shader' )
si.SetProperty3('sphere'+str(j), 'scale',0.75,0.75,0.75)
si.SetProperty3('sphere'+str(j), 'translate',3.5,0.75,0)
si.SetProperty3('sphere'+str(j), 'rotate', 0,36*Count,0)
Count=Count+1
j+=1



影を表示するため
以下の記述でグループにまとめています。


#ObjectGroup
si.NewObjectGroup('group1')
for i in spname:
si.AddObjectToGroup('group1', i)

for i in spname:
si.AssignObjectGroup(i, 'shadow_target', 'group1')
si.AssignObjectGroup('floor1', 'shadow_target', 'group1')



povsp6.jpg

以下はPythonサンプルです。ありがとうございます。
floor_shaderのiorは2くらいに下げてください。


#!/usr/bin/env python
from math import *
#export PYTHONPATH=$PYTHONPATH:/usr/lib/python2.6/site-packages/:$HOME/Fujiyama-Renderer/bin/
import fujiyama

si = fujiyama.SceneInterface()

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

#Camera
si.NewCamera('cam1', 'PerspectiveCamera')

#Calculate python fujicam.py 0 10 10 0 0 0
si.SetSampleProperty3('cam1', 'rotate', -45, 0, 0, 0)
si.SetSampleProperty3('cam1', 'translate', 0, 10, 10, 0)
#si.SetSampleProperty3('cam1', 'translate', 0, 1, 10, 0)

si.SetProperty1('cam1', 'fov', 35)

#Light
si.NewLight('light1', 'SphereLight')
si.SetProperty3('light1', 'translate', 10, 10, 10)
si.SetProperty3('light1', 'scale', .5, .5, .5)
si.SetProperty1('light1', 'intensity', 1.5)
si.SetProperty1('light1', 'sample_count', 16)

si.NewLight('light2', 'SphereLight')
si.SetProperty3('light2', 'translate', -5, 10, 10)
si.SetProperty3('light2', 'scale', .5, .5, .5)
si.SetProperty1('light2', 'intensity', 1.5)
si.SetProperty1('light2', 'sample_count', 16)

#Texture
si.NewTexture('tex1', '../mip/pisa.mip')

#Shader
si.NewShader('dome_shader', 'ConstantShader')
si.AssignTexture('dome_shader', 'texture', 'tex1')

si.NewShader('floor_shader', 'PlasticShader')
si.SetProperty3('floor_shader', 'diffuse', .9, .2, .2)
si.SetProperty1('floor_shader', 'ior', 8)

intensity = 0
si.NewShader('sphere_shader', 'PlasticShader')
si.SetProperty3('sphere_shader', 'diffuse', intensity, intensity, intensity)
si.SetProperty1('sphere_shader', 'ior', 40)

#Mesh
si.NewMesh('dome_mesh', '../mesh/dome.mesh')
si.NewMesh('floor_mesh', '../mesh/floor.mesh')
si.NewMesh('sphere_mesh', '../mesh/sphere.mesh')


#ObjectInstance
si.NewObjectInstance('dome1', 'dome_mesh')
si.SetProperty3('dome1', 'rotate', 0, 0, 0)

j=0
Count=0

spname=[]

while (Count<10):
spname.append('sphere'+str(j))
si.NewObjectInstance('sphere'+str(j), 'sphere_mesh')
si.SetProperty1('sphere'+str(j), 'transform_order', 'ORDER_STR')
si.AssignShader('sphere'+str(j), 'sphere_shader' )
si.SetProperty3('sphere'+str(j), 'scale',0.75,0.75,0.75)
si.SetProperty3('sphere'+str(j), 'translate',3.5,0.75,0)
si.SetProperty3('sphere'+str(j), 'rotate', 0,36*Count,0)

Count=Count+1
j+=1




#si.SetProperty3('dome1', 'scale', -.5, .5, .5)
si.SetProperty3('dome1', 'scale', -2, 2, 2)
si.AssignShader('dome1', 'dome_shader')

si.NewObjectInstance('floor1', 'floor_mesh')
si.SetProperty3('floor1', 'scale', 50, 50, 50)
si.SetProperty3('floor1', 'translate', 0, 0, 0)
si.AssignShader('floor1', 'floor_shader')

#ObjectGroup
si.NewObjectGroup('group1')
for i in spname:
si.AddObjectToGroup('group1', i)

for i in spname:
si.AssignObjectGroup(i, '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', 512, 384)
#si.SetProperty2('ren1', 'resolution', 160, 120)
si.SetProperty2('ren1', 'pixelsamples', 2, 2)

#Rendering
si.RenderScene('ren1')

#Output
si.SaveFrameBuffer('fb1', '../povsp6.fb')

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


Fujiyama Renderer | - | -
1/4 >>