Rendering学習日記

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

はじめてのFujiyama Renderer その5

毛並表現わかりました。
curvegen hoge.mesh hoge.crvでファーを生成する。
ありがとうございます。
furbunny.jpg
Fujiyama Renderer | - | -

はじめてのFujiyama Renderer その4

Stanford Happy buddhaをレンダリングする。
jpegに変換するとねむくなるのでgimpでトーンカーブ調整する。
bd04.jpeg

Glass shaderを利用
bd05.jpeg
ありがとうございます。
Fujiyama Renderer | - | -

はじめてのFujiyama Renderer その3

地道に試してみる。si.Print()はシーンファイルの出力です。


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

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

si = fujiyama.SceneInterface()

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

#Camera
si.NewCamera('cam1', 'PerspectiveCamera')
si.SetProperty3('cam1', 'translate', 0, 2, 6)
si.SetProperty3('cam1', 'rotate', -11.309932474020213, 0, 0)

#Light
si.NewLight('light1', 'PointLight')
si.SetProperty3('light1', 'position', 10, 12, 10)

#Shader
si.NewShader('floor_shader', 'PlasticShader')
si.SetProperty3('floor_shader', 'diffuse', .2, .25, .3)
si.SetProperty1('floor_shader', 'ior', 2)

si.NewShader('cube_shader', 'PlasticShader')
si.SetProperty3('cube_shader', 'diffuse', .9, .2, .2)

#si.NewShader('cube_shader3', 'PlasticShader')
#si.SetProperty3('cube_shader3', 'diffuse', .1, .2, .8)

#si.NewShader('cube_shader2', 'PlasticShader')
#si.SetProperty3('cube_shader2', 'diffuse', .1, .95, .1)

si.NewShader('dome_shader', 'ConstantShader')
si.SetProperty3('dome_shader', 'diffuse', .8, .8, .8)


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

#ObjectInstance
N1=16
J=1
while J<=N1:
si.NewShader('cube_shader'+str(J), 'PlasticShader')
si.SetProperty3('cube_shader'+str(J), 'diffuse', 0.5*(1+sin(2*pi/N1*J)),0.5, 0.5*(1+cos(2*pi/N1*J)))
si.NewObjectInstance('cube'+str(J), 'cube_mesh')
si.AssignShader('cube'+str(J), 'cube_shader'+str(J))
si.SetProperty3('cube'+str(J), 'translate', 1.7*sin(2*pi/N1*J),.4, 1.7*cos(2*pi/N1*J))
si.SetProperty3('cube'+str(J), 'rotate', 0,360/N1*J, 0)
si.SetProperty3('cube'+str(J), 'scale', .5,.5, .5)
J+=1



si.NewObjectInstance('floor1', 'floor_mesh')
si.AssignShader('floor1', 'floor_shader')

si.NewObjectInstance('dome1', 'dome_mesh')
si.AssignShader('dome1', 'dome_shader')

#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', '../cube04.fb')

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


cube04.jpeg
Thank you for your support.
ありがとうございます。
Fujiyama Renderer | - | -

はじめてのFujiyama Renderer その2

Python API fujiyama.pyを利用。


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

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

si = fujiyama.SceneInterface()

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

#Camera
si.NewCamera('cam1', 'PerspectiveCamera')
si.SetProperty3('cam1', 'translate', 0, 2, 6)
si.SetProperty3('cam1', 'rotate', -11.309932474020213, 0, 0)

#Light
si.NewLight('light1', 'PointLight')
si.SetProperty3('light1', 'position', 10, 12, 10)

#Shader
si.NewShader('floor_shader', 'PlasticShader')
si.SetProperty3('floor_shader', 'diffuse', .2, .25, .3)
si.SetProperty1('floor_shader', 'ior', 2)

si.NewShader('cube_shader', 'PlasticShader')
si.SetProperty3('cube_shader', 'diffuse', .9, .2, .2)

#si.NewShader('cube_shader3', 'PlasticShader')
#si.SetProperty3('cube_shader3', 'diffuse', .1, .2, .8)

#si.NewShader('cube_shader2', 'PlasticShader')
#si.SetProperty3('cube_shader2', 'diffuse', .1, .95, .1)

si.NewShader('dome_shader', 'ConstantShader')
si.SetProperty3('dome_shader', 'diffuse', .8, .8, .8)


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

#ObjectInstance
N1=5
J=1
for i in range(5):
si.NewShader('cube_shader'+str(i), 'PlasticShader')
si.SetProperty3('cube_shader'+str(i), 'diffuse', 0.5*(1+sin(2*pi/N1*J)),0.5, 0.5*(1+cos(2*pi/N1*J)))
si.NewObjectInstance('cube'+str(i), 'cube_mesh')
si.AssignShader('cube'+str(i), 'cube_shader'+str(i))
si.SetProperty3('cube'+str(i), 'translate', i-2,.6, 0)
si.SetProperty3('cube'+str(i), 'scale', .8,.8, .8)
J+=1



si.NewObjectInstance('floor1', 'floor_mesh')
si.AssignShader('floor1', 'floor_shader')

si.NewObjectInstance('dome1', 'dome_mesh')
si.AssignShader('dome1', 'dome_shader')

#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', '../cube03.fb')

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


cube03.jpeg
Fujiyama Renderer | - | -

はじめてのFujiyama Renderer

Fujiyama Rendererをさわる。
CentOS6.3 x86_64でビルドした。

Python APIを利用する。
fujiyama.pyはbinフォルダに置いた。
座標空間は右手系 Y up。

fujiyama.pyを利用するには
$ export PYTHONPATH=$PYTHONPATH:/usr/lib/python2.6/site-packages/:$HOME/Fujiyama-Renderer/bin/

レンダリングはscenesフォルダから
scenes]$ python cube01.py

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

#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')
si.OpenPlugin('GlassShader')

#Camera
si.NewCamera('cam1', 'PerspectiveCamera')
si.SetProperty3('cam1', 'translate', 0, 2, 6)
si.SetProperty3('cam1', 'rotate', -11.309932474020213, 0, 0)

#Light
si.NewLight('light1', 'PointLight')
si.SetProperty3('light1', 'translate', 10, 12, 10)

#Shader
si.NewShader('floor_shader', 'PlasticShader')
si.SetProperty3('floor_shader', 'diffuse', .2, .25, .3)
si.SetProperty1('floor_shader', 'ior', 2)

si.NewShader('cube_shader', 'PlasticShader')
si.SetProperty3('cube_shader', 'diffuse', .9, .2, .2)

si.NewShader('cube_shader3', 'PlasticShader')
si.SetProperty3('cube_shader3', 'diffuse', .1, .2, .8)

si.NewShader('cube_shader2', 'PlasticShader')
si.SetProperty3('cube_shader2', 'diffuse', .1, .95, .1)

si.NewShader('dome_shader', 'ConstantShader')
si.SetProperty3('dome_shader', 'diffuse', .8, .8, .8)


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

#ObjectInstance
si.NewObjectInstance('cube1', 'cube_mesh')
si.AssignShader('cube1', 'cube_shader3')
si.SetProperty3('cube1', 'translate', 1.2,.6, 0)
si.SetProperty3('cube1', 'scale', .8,.8, .8)

si.NewObjectInstance('cube2', 'cube_mesh')
si.AssignShader('cube2', 'cube_shader2')
si.SetProperty3('cube2', 'translate', 0,.6, 0)

si.NewObjectInstance('cube3', 'cube_mesh')
si.AssignShader('cube3', 'cube_shader')
si.SetProperty3('cube3', 'translate', -1.2,.6, 0)

si.NewObjectInstance('floor1', 'floor_mesh')
si.AssignShader('floor1', 'floor_shader')

si.NewObjectInstance('dome1', 'dome_mesh')
si.AssignShader('dome1', 'dome_shader')

#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', '../cube01.fb')

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

cube01.jpeg
画像を見るには
fbview cube01.fb
OpenEXRに変換は
fb2exr cube01.fb cube01.exr

Light設定が変更
'translate'になった。
Fujiyama Renderer | - | -

LightFlow for linux 64bit その2

前回64bitでうまくいかなかった。やっとできたのでメモする。
CentOS 64bit環境でpython1.5を32bitビルド試みたが、64bitになってしまう。結局Virtualboxに入れたCentOS i686(32bit)版でビルドしたpython1.5をコピーして、LightFlowが起動した。

以下試みる。CentOS 64bitでビルドしても64bit.
export CFLAGS=-m32
export CXXFLAGS=-m32
echo $CFLAGS
echo $CXXFLAGS
yum install glibc-2.12-1.80.el6_3.5.i686
yum install libstdc++*
yum install libstdc++*.i686
./configure --enable-32bit
make ARCH="-m32"

32bit環境の以下をコピー
/usr/local/bin python1.5
/usr/local/lib python1.5/
/usr/local/include python1.5/
64bit環境にインストールする。
sudo cp python1.5 /usr/local/bin

さらに次のファイルをダウンロードします。
compat-libstdc++-6.2-2.9.0.14.i386.rpm
http://rpm.pbone.net/index.php3/stat/4/idpl/14760/com/compat-libstdc++-6.2-2.9.0.14.i386.rpm.html

インストールします。
[root@localhost]# rpm -ivh compat-libstdc++-6.2-2.9.0.14.i386.rpm
Preparing... ########################################### [100%]
1:compat-libstdc++ ########################################### [100%]

その他、.bashrcに記入
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$HOME/Lightflow
PYTHONPATH=$PYTHONPATH:$HOME/Lightflow
LIGHTFLOWPATH=$HOME/Lightflow
LIGHTFLOW_SE_MEMORY=32000
LIGHTFLOW_VE_MEMORY=32000

export LD_LIBRARY_PATH PYTHONPATH LIGHTFLOWPATH LIGHTFLOW_SE_MEMORY LIGHTFLOW_VE_MEMORY

以下を実行するとレンダリングできました。
Examples]$ python1.5 ball1.py

Lightflow Rendering Tools
Copyright (c) 1995-2000 by Jacopo Pantaleoni. All rights reserved


Pinhole Camera On
Objects : 1

Rendering 300 x 300 pixels
00:00:00 - 87.1%
Windowsより速いです。
Lightflow | - | -

ファイル名を大文字から小文字に変換する

Linux CentOSでカレントディレクトリのファイル名を大文字から小文字に変換した。

$ for f in * ; do mv $f `echo $f | tr A-Z a-z`; done

ありがとうございます。
プログラミング | - | -

AL the animation language install under CentOS6.3

Linuxで動くScheme言語をもとに作成された言語ALです。
簡易アニメーションをRenderManに受け渡すことができます。
1998年から2002年まで開発されていたようです。
A1tOFUYCcAA9M6Z.jpg-large.jpeg
http://accad.osu.edu/~smay/AL/index.html
■ダウンロード先
Version 5.2a [3/18/02]
LINUX 2.4 (RH 7.1,BMRT 2.6)
Downloading AL
http://accad.osu.edu/~smay/Download/AL5.2a.linux.tar.gz

Index of /dev/3d/bmrt
http://www.raclot.org/dev/3d/bmrt/

以下はホーム(例:makura)に解凍して.bashrcに以下を追加しました。
---------------------------------------
# BMRT
export BMRT=/home/makura/software/bmrt-2.6beta-linux-i386
export SHADERS=$BMRT/shaders

#ALHOME
export ALHOME=/home/makura/AL5.2a
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ALHOME/lib

export PATH=$PATH:$BMRT/bin:$ALHOME/bin
----------------------------------------

以下は、足りないものをインストールしていった過程を提示します。
参考にどうぞ。

[@localhost ~]$ echo $BMRT
/home/makura/software/bmrt-2.6beta-linux-i386
[@localhost ~]$ echo $LD_LIBRARY_PATH
/home/makura/software//3delight-10.0.50/Linux-x86_64/lib:/home/makura/software//3delight-10.0.50/Linux-x86_64/lib:/home/makura/AL5.2a/lib
[@localhost ~]$ cd software/bmrt-2.6beta-linux-i386/examples/
[@localhost examples]$ rendrib -v
rendrib: error while loading shared libraries: libGL.so.1: cannot open shared object file: No such file or directory
[@localhost examples]$ su
パスワード:
[root@localhost examples]# yum provides libGL.so.1
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
* base: ftp.iij.ad.jp
* extras: ftp.iij.ad.jp
* updates: ftp.iij.ad.jp
mesa-libGL-7.11-5.el6.i686 : Mesa libGL runtime libraries and DRI drivers
Repo : base
Matched from:
Other : libGL.so.1



[root@localhost examples]# yum install mesa-libGL-7.11-5.el6.i686
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
mesa-libGL i686 7.11-5.el6 base 161 k
Installing for dependencies:
libXxf86vm i686 1.1.0-1.el6 base 18 k
libdrm i686 2.4.25-2.el6 base 66 k
mesa-dri-drivers i686 7.11-5.el6 base 12 M

Transaction Summary
================================================================================
Install 4 Package(s)


Installed:
mesa-libGL.i686
0:7.11-5.el6

Dependency Installed:
libXxf86vm.i686
0:1.1.0-1.el6
libdrm.i686
0:2.4.25-2.el6
mesa-dri-drivers.i686
0:7.11-5.el6

Complete!
[root@localhost examples]# exit
exit
[@localhost examples]$ rendrib -v
rendrib: error while loading shared libraries: libGLU.so.1: cannot open shared object file: No such file or directory
[@localhost examples]$ su
パスワード:
[root@localhost examples]# yum provides libGLU.so.1
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
* base: ftp.iij.ad.jp
* extras: ftp.iij.ad.jp
* updates: ftp.iij.ad.jp
mesa-libGLU-7.11-5.el6.i686 : Mesa libGLU runtime library
Repo : base
Matched from:
Other : libGLU.so.1



[root@localhost examples]# yum install mesa-libGLU-7.11-5.el6.i686
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
mesa-libGLU i686 7.11-5.el6 base 199 k

Transaction Summary
================================================================================
Install 1 Package(s)

Installed:
mesa-libGLU.i686 0:7.11-5.el6

Complete!
[root@localhost examples]# exit
exit
[@localhost examples]$ rendrib -help

rendrib - Ray tracing / radiosity renderer for RIB files

Blue Moon Rendering Tools 2.6.0.-18 linux
(c) Copyright 1990-2000 Exluna, Inc. and Larry Gritz. All rights reserved.

Usage: rendrib [options] file1 ... fileN
options: -res x y Specify image resolution (if not in RIB)
-samples x y Specify pixel sampling rate (if not in RIB)
-var v min max Specify pixel sampling variance
-frames f1 f2 Specify frame interval
-radio n Perform radiosity calculation with n steps
-crop x1 x2 y1 y2 Set the crop window (screen space units)
-safe Safety of existing files (no overwrite)
-d [interlace] Display override - show in framebuffer
-pos x y Specify image position (for framebuffer display)
-v Verbose mode
-stats Display rendering statistics
-silent Display only error messages
-rayserver Act as a ray server
-beep Ring the terminal bell when finished
-arch Print out the platform architecture code

[@localhost examples]$ rendrib -d cornell.rib
Rendering "cornell.tif" ...
Done computing image.

[@localhost ~]$ cd AL5.2a/
[@localhost AL5.2a]$ ox
ox.motif: error while loading shared libraries: libXt.so.6: cannot open shared object file: No such file or directory
[makura@localhost AL5.2a]$ su
パスワード:
[root@localhost AL5.2a]# yum provides libXt.so.6
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
* base: ftp.iij.ad.jp
* extras: ftp.iij.ad.jp
* updates: ftp.iij.ad.jp
libXt-1.0.7-1.el6.i686 : X.Org X11 libXt runtime library
Repo : base
Matched from:
Other : libXt.so.6



[root@localhost AL5.2a]# yum install libXt-1.0.7-1.el6.i686
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
libXt i686 1.0.7-1.el6 base 168 k

Transaction Summary
================================================================================
Install 1 Package(s)

Installed:
libXt.i686 0:1.0.7-1.el6

Complete!
[root@localhost AL5.2a]# exit
exit
[makura@localhost AL5.2a]$ ox
ox.motif: error while loading shared libraries: libXpm.so.4: cannot open shared object file: No such file or directory
[@localhost AL5.2a]$ su
パスワード:
[root@localhost AL5.2a]# yum provides libXpm.so.4
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
* base: ftp.iij.ad.jp
* extras: ftp.iij.ad.jp
* updates: ftp.iij.ad.jp
libXpm-3.5.8-2.el6.i686 : X.Org X11 libXpm runtime library
Repo : base
Matched from:
Other : libXpm.so.4



[root@localhost AL5.2a]# yum install libXpm-3.5.8-2.el6.i686
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
libXpm i686 3.5.8-2.el6 base 58 k

Transaction Summary
================================================================================
Install 1 Package(s)

Installed:
libXpm.i686 0:3.5.8-2.el6

Complete!
[root@localhost AL5.2a]# exit
exit
[@localhost AL5.2a]$ ox
ox.motif: error while loading shared libraries: libstdc++-libc6.2-2.so.3: cannot open shared object file: No such file or directory
[@localhost AL5.2a]$ su
パスワード:
[root@localhost AL5.2a]# yum provides libstdc++-libc6.2-2.so.3
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
* base: ftp.iij.ad.jp
* extras: ftp.iij.ad.jp
* updates: ftp.iij.ad.jp
compat-libstdc++-296-2.96-144.el6.i686 : Compatibility 2.96-RH standard C++
: libraries
Repo : base
Matched from:
Other : libstdc++-libc6.2-2.so.3



[root@localhost AL5.2a]# yum install compat-libstdc++-296-2.96-144.el6.i686
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
compat-libstdc++-296 i686 2.96-144.el6 base 77 k

Transaction Summary
================================================================================
Install 1 Package(s)

Installed:
compat-libstdc++-296.i686 0:2.96-144.el6

Complete!
[root@localhost AL5.2a]# exit
exit
[@localhost AL5.2a]$ ox
Welcome to OX, version 5.2a [3/18/02]
[Xt/Motif][BMRT][OGRE][Chant]
ox --> (ogre)
#(instance ogre-app #[environment 4133324880])
ox --> (world (sphere))

ox --> (render)
rendering frame: "frame" (rgba) to "framebuffer"
generating RIB for world
rendering world
Rendering "frame" ...
Done computing image.
()
ox --> ^Z
[1]+ 停止 ox

■補足
xorg-x11-fonts-75dpi.noarchとxorg-x11-fonts-ISO8859-1-75dpi.noarch、2つのフォントをインストールしておくと、アニメーション・カーブ・エディタchantが動く。

A1uKOOuCYAASeHP.jpg-large.jpeg
RenderMan | - | -

AL the animation language

http://accad.osu.edu/~smay/AL/index.html

Version 5.2a [3/18/02]
LINUX 2.4 (RH 7.1,BMRT 2.6)
Downloading AL
http://accad.osu.edu/~smay/Download/AL5.2a.linux.tar.gz
RenderMan | - | -
1/1