Rendering学習日記

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

Bodhi Linux and Pixie Renderer install under gnome boxes

Ubuntu系のLinux 64bitでPixie Rendererを動かしました。
RIBが使える唯一のRenderMan互換rendererになるかもしれません。
Dispersion.jpg
Fedora28のgnome boxesにBodhi Linux5.0 64bitをインストールしました。
ダウンロードしたのは、bodhi-5.0.0-apppack-64.iso (1.5GB)
Pixie Rendererをビルドしました。
Pixie Rendererをダウンロードしてきます。
https://sourceforge.net/projects/pixie/

解凍します。
$ tar xvf Pixie-src-2.2.6.tgz
$ cd Pixie/
$ ./configure
...
ellipsis (省略)
...
errorが出ますので、以下、いくつかインストールします。
管理者権限で、
$ sudo -i

~# apt install update

~# apt install bison
~# apt install flex
~# apt install build-essential

~# apt install libtiff-dev
~# apt install libpng-dev
~# apt install libopenexr-dev
~# apt install fluid
~# apt install libcairo2-dev libxft-dev libxinerama-dev

*****************************************
次に、以下のpatchをあてます。https://sourceforge.net/projects/pixie/のticketにあります。
ファイル名pixie-2.2.6-gcc6.patchをダウンロードします。
https://sourceforge.net/p/pixie/patches/23/
上記から入手してください。
上のパッチを解凍したPixie/src/commonに保存します。
以下を実行します。

$ cd src/common
$ patch < pixie-2.2.6-gcc6.patch
patching file global.h

パッチをあてないでmakeすると以下のようなエラーが出ます。

In file included from ../common/algebra.h:188,
from file.cpp:33:
../common/mathSpec.h: 関数 ‘void fresnel(const float*, const float*, float, float&, float&, float*, float*)’ 内:
../common/mathSpec.h:548:30: エラー: ‘max’ was not declared in this scope
const SCALAR_TYPE g = SQRT(max(t,0));
^~~
../common/mathSpec.h:548:30: 備考: suggested alternative: ‘fmax’
const SCALAR_TYPE g = SQRT(max(t,0));
^~~
fmax
../common/mathSpec.h:553:9: エラー: ‘min’ was not declared in this scope
Kr = min(Kr,1);
^~~
../common/mathSpec.h:553:9: 備考: suggested alternative: ‘sin’
Kr = min(Kr,1);
^~~
sin
In file included from ../common/algebra.h:199,
from file.cpp:33:
../common/mathSpec.h: 関数 ‘void fresnel(const double*, const double*, double, double&, double&, double*, double*)’ 内:
../common/mathSpec.h:548:30: エラー: ‘max’ was not declared in this scope
const SCALAR_TYPE g = SQRT(max(t,0));
^~~
../common/mathSpec.h:548:30: 備考: suggested alternative: ‘fmax’
const SCALAR_TYPE g = SQRT(max(t,0));
^~~
fmax
../common/mathSpec.h:553:9: エラー: ‘min’ was not declared in this scope
Kr = min(Kr,1);
^~~
../common/mathSpec.h:553:9: 備考: suggested alternative: ‘sin’
Kr = min(Kr,1);
^~~
sin
make[3]: *** [Makefile:317: file.lo] エラー 1


*************************************************
$ cd ../../ でPixieフォルダに戻ります。
$ ./configure を実行します。
------------------------------------------------
---> FLTK not found.
---> You can download it from www.fltk.org
---> show will not be built.
------------------------------------------------
Installation info:
PIXIEHOME: /opt/pixie
Documentation: /opt/pixie/doc
Shaders: /opt/pixie/shaders
RIBs: /opt/pixie/ribs
Textures: /opt/pixie/textures
Displays: /opt/pixie/displays
Procedurals: /opt/pixie/procedurals
Modules: /opt/pixie/modules
------------------------------------------------
To build Pixie:
>make
>make install
Terminus Est

FLTK not found.は無視します。他にエラーがなければいよいよmakeです。

$ make

エラーがいくつか出てきます。テキストエディタで(gzFile)を記入していきます。

In file included from rendererContext.cpp:77:0:
ribOut.h: In member function ‘void CRibOut::vout(const char*, __va_list_tag*)’:
ribOut.h:240:61: error: cannot convert ‘FILE* {aka _IO_FILE*}’ to ‘gzFile {aka gzFile_s*}’ for argument ‘1’ to ‘int gzwrite(gzFile, voidpc, unsigned int)’
if (outputCompressed) gzwrite(outFile,scratch,l);
^
ribOut.h: In member function ‘void CRibOut::out(const char*, ...)’:
ribOut.h:261:61: error: cannot convert ‘FILE* {aka _IO_FILE*}’ to ‘gzFile {aka gzFile_s*}’ for argument ‘1’ to ‘int gzwrite(gzFile, voidpc, unsigned int)’
if (outputCompressed) gzwrite(outFile,scratch,l);
^
rendererContext.cpp: In member function ‘virtual void CRendererContext::RiError(int, int, const char*)’:
rendererContext.cpp:4706:20: warning: format not a string literal and no format arguments [-Wformat-security]
fprintf(out,tmp);
^
Makefile:485: recipe for target 'rendererContext.lo' failed
make[4]: *** [rendererContext.lo] Error 1
make[4]: Leaving directory '/home/yokamak/Download/Pixie/src/ri'


ファイルribOut.h
240行目
if (outputCompressed) gzwrite((gzFile)outFile,scratch,l);240
261行目
if (outputCompressed) gzwrite((gzFile)outFile,scratch,l);261
(gzFile)を追記します。

$ makeします。


rib.l: In function ‘int riblex(YYSTYPE*)’:
rib.l:211:5: error: ‘riblval’ was not declared in this scope
\"[^\"]*\" { riblval->string = rstrdup(ribtext+1,CRenderer::globalMemory); riblval->string[strlen(riblval->string)-1] = '\0'; return RIB_TEXT;}
^~~~~~~
rib.l:211:5: note: suggested alternative: ‘ribval’
\"[^\"]*\" { riblval->string = rstrdup(ribtext+1,CRenderer::globalMemory); riblval->string[strlen(riblval->string)-1] = '\0'; return RIB_TEXT;}
^~~~~~~
ribval
In file included from rib.y:2835:0:
rib.l:212:44: error: ‘riblval’ was not declared in this scope
[+-]?([0-9]+|([0-9]*(\.[0-9]+)?)([eE][+-]?[0-9]+)?) { /*sscanf(ribtext,"%f",&riblval->real);*/ riblval->real = (float) atof(ribtext); return RIB_FLOAT; }
^~~~~~~
rib.l:212:44: note: suggested alternative: ‘ribval’
[+-]?([0-9]+|([0-9]*(\.[0-9]+)?)([eE][+-]?[0-9]+)?) { /*sscanf(ribtext,"%f",&riblval->real);*/ riblval->real = (float) atof(ribtext); return RIB_FLOAT; }
^~~~~~~
ribval
In file included from rib.y:2835:0:
rib.l:213:44: error: ‘riblval’ was not declared in this scope
[+-]?([0-9]+|([0-9]+(\.[0-9]*)?)([eE][+-]?[0-9]+)?) { /*sscanf(ribtext,"%f",&riblval->real);*/ riblval->real = (float) atof(ribtext); return RIB_FLOAT; }
^~~~~~~
rib.l:213:44: note: suggested alternative: ‘ribval’
[+-]?([0-9]+|([0-9]+(\.[0-9]*)?)([eE][+-]?[0-9]+)?) { /*sscanf(ribtext,"%f",&riblval->real);*/ riblval->real = (float) atof(ribtext); return RIB_FLOAT; }
^~~~~~~
ribval
In file included from rib.y:2835:0:
rib.l:216:3: error: ‘riblval’ was not declared in this scope
#\!.* { riblval->string = rstrdup(ribtext+2,CRenderer::globalMemory); return RIB_STRUCTURE_COMMENT; }
^~~~~~~
rib.l:216:3: note: suggested alternative: ‘ribval’
#\!.* { riblval->string = rstrdup(ribtext+2,CRenderer::globalMemory); return RIB_STRUCTURE_COMMENT; }
^~~~~~~
ribval
In file included from rib.y:2835:0:
rib.l:226:29: error: cannot convert ‘FILE* {aka _IO_FILE*}’ to ‘gzFile {aka gzFile_s*}’ for argument ‘1’ to ‘int gzclose(gzFile)’
gzclose(ribin);
^
In file included from rib.y:2835:0:
rib.l:246:29: error: cannot convert ‘FILE* {aka _IO_FILE*}’ to ‘gzFile {aka gzFile_s*}’ for argument ‘1’ to ‘int gzclose(gzFile)’
gzclose(ribin);
^
In file included from rib.y:2835:0:
lex.rib.cpp: In function ‘int yy_get_next_buffer()’:
rib.l:20:77: error: cannot convert ‘FILE* {aka _IO_FILE*}’ to ‘gzFile {aka gzFile_s*}’ for argument ‘1’ to ‘int gzread(gzFile, voidp, unsigned int)’
YY_INPUT(buf, retval, maxlen) if ( (retval = gzread(ribin,buf,maxlen)) < 0) \
^
lex.rib.cpp:2636:3: note: in expansion of macro ‘YY_INPUT’
YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
^~~~~~~~
rib.y: In function ‘void ribParse(const char*, void (*)(const char*, ...))’:
rib.y:2943:17: error: cannot convert ‘FILE* {aka _IO_FILE*}’ to ‘gzFile {aka gzFile_s*}’ for argument ‘1’ to ‘int gzclose(gzFile)’
gzclose(ribin);
^
Makefile:485: recipe for target 'rib.lo' failed
make[4]: *** [rib.lo] Error 1

上記のエラーは、https://sourceforge.net/projects/pixie/のticketに書いてあります。

--- gentoo/media-gfx/pixie/pixie-2.2.6-r1.ebuild 2012-03-10 10:19:20.000000000 +0100
+++ myrep/media-gfx/pixie/pixie-2.2.6-r1.ebuild 2015-01-26 04:47:00.000000000 +0100
@@ -55,6 +55,9 @@
# parallelism can break the regeneration process, with resulting
# missing shaders.
rm "${S}"/shaders/*.sdr
+
+ # FIX: flex does not translate variable name in custom YY_DECL
+ sed -i -e '/define YY_DECL/ s/yylval/riblval/' src/ri/rib.l
}

src_configure() {


以下を実行します。
$ sed -i -e '/define YY_DECL/ s/yylval/riblval/' src/ri/rib.l


続けて
$ makeします。

rib.l: In function ‘int riblex(YYSTYPE*)’:
rib.l:226:29: error: cannot convert ‘FILE* {aka _IO_FILE*}’ to ‘gzFile {aka gzFile_s*}’ for argument ‘1’ to ‘int gzclose(gzFile)’
gzclose(ribin);
^
In file included from rib.y:2835:0:
rib.l:246:29: error: cannot convert ‘FILE* {aka _IO_FILE*}’ to ‘gzFile {aka gzFile_s*}’ for argument ‘1’ to ‘int gzclose(gzFile)’
gzclose(ribin);
^
In file included from rib.y:2835:0:
lex.rib.cpp: In function ‘int yy_get_next_buffer()’:
rib.l:20:77: error: cannot convert ‘FILE* {aka _IO_FILE*}’ to ‘gzFile {aka gzFile_s*}’ for argument ‘1’ to ‘int gzread(gzFile, voidp, unsigned int)’
YY_INPUT(buf, retval, maxlen) if ( (retval = gzread(ribin,buf,maxlen)) < 0) \
^
lex.rib.cpp:2636:3: note: in expansion of macro ‘YY_INPUT’
YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
^~~~~~~~
rib.y: In function ‘void ribParse(const char*, void (*)(const char*, ...))’:
rib.y:2943:17: error: cannot convert ‘FILE* {aka _IO_FILE*}’ to ‘gzFile {aka gzFile_s*}’ for argument ‘1’ to ‘int gzclose(gzFile)’
gzclose(ribin);
^
Makefile:485: recipe for target 'rib.lo' failed
make[4]: *** [rib.lo] Error 1
make[4]: Leaving directory '/home/yokamak/Download/Pixie/src/ri'
Makefile:328: recipe for target 'all' failed
make[3]: *** [all] Error 2


ファイルrib.l :20行目
#define YY_INPUT(buf, retval, maxlen) if ( (retval = gzread((gzFile)ribin,buf,maxlen)) < 0)

:226行目と :246行目
gzclose((gzFile)ribin);

続けて
$ makeします。

rib.y: In function ‘void ribParse(const char*, void (*)(const char*, ...))’:
rib.y:2943:17: error: cannot convert ‘FILE* {aka _IO_FILE*}’ to ‘gzFile {aka gzFile_s*}’ for argument ‘1’ to ‘int gzclose(gzFile)’
gzclose(ribin);
^
Makefile:485: recipe for target 'rib.lo' failed
make[4]: *** [rib.lo] Error 1

ファイルrib.y
:2943行目
#ifdef HAVE_ZLIB
gzclose((gzFile)ribin);
#else

続けて
$ makeします。

ribOut.cpp: In destructor ‘virtual CRibOut::~CRibOut()’:
ribOut.cpp:165:20: error: cannot convert ‘FILE* {aka _IO_FILE*}’ to ‘gzFile {aka gzFile_s*}’ for argument ‘1’ to ‘int gzclose(gzFile)’
gzclose(outFile);
^
Makefile:485: recipe for target 'ribOut.lo' failed

ファイルribOut.cpp
:165行目
gzclose((gzFile)outFile);

続けて
$ makeします。

make[3]: Leaving directory '/home/yokamak/Download/Pixie/src/sdrinfo'
Making all in show
make[3]: Entering directory '/home/yokamak/Download/Pixie/src/show'
make[3]: Nothing to be done for 'all'.
make[3]: Leaving directory '/home/yokamak/Download/Pixie/src/show'
make[3]: Entering directory '/home/yokamak/Download/Pixie/src'
make[3]: Nothing to be done for 'all-am'.
make[3]: Leaving directory '/home/yokamak/Download/Pixie/src'
make[2]: Leaving directory '/home/yokamak/Download/Pixie/src'
Making all in doc
make[2]: Entering directory '/home/yokamak/Download/Pixie/doc'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/home/yokamak/Download/Pixie/doc'
make[2]: Entering directory '/home/yokamak/Download/Pixie'
make[2]: Leaving directory '/home/yokamak/Download/Pixie'
make[1]: Leaving directory '/home/yokamak/Download/Pixie'

make完了!!!
管理者権限で、
$ sudo -i
# make install

これで/opt/pixie/にインストールされました。shaderをコンパイルしなおします。

root@bodhi:/home/yokamak/Download/Pixie# cd /opt/pixie/shaders/
root@bodhi:/opt/pixie/shaders# /opt/pixie/bin/sdrc *.sl
Compiling ambientindirect.sl
Compiling ambientlight.sl
Compiling ambientocclusion.sl
Compiling arealight.sl
Compiling constant.sl
Compiling distantlight.sl
Compiling fog.sl
Compiling glass.sl
Compiling matte.sl
Compiling metal.sl
Compiling mirror.sl
Compiling mtorDirectionalLight.sl
Compiling mtorLambert.sl
Compiling mtorPhong.sl
Compiling normdir.sl
Compiling paintedmatte.sl
Compiling paintedplastic.sl
Compiling plastic.sl
Compiling pointlight.sl
Compiling rayarea.sl
Compiling raydistant.sl
Compiling raypoint.sl
Compiling shadowarea.sl
Compiling shadowdistant.sl
Compiling shadowpoint.sl
Compiling shadowspot.sl
Compiling spotlight.sl
root@bodhi:/opt/pixie/shaders# logout (ctrl+dで)

最後にPixie RendererのPATHを編集します。
yokamak@bodhi:~/Download/Pixie$ cd ~
yokamak@bodhi:~$ nano .profile
以下を記入
export PIXIEHOME=/opt/pixie/
export PATH=$PATH:$PIXIEHOME/bin
export SHADERS=$PIXIEHOME/shaders

$ source .profileを実行。
以下のaqsis rendererのsimple.ribを実行してみます。
$ rndr -d simple.rib
##RenderMan RIB-Structure 1.0
FrameBegin 1
Display "simple.tif" "framebuffer" "rgba"
Format 640 480 -1
ShadingRate 1
Projection "perspective" "fov" [30]
FrameAspectRatio 1.33
Identity
# Default distant headlight
LightSource "distantlight" 1
# Camera transformation
Translate 0 0 5
WorldBegin
Identity
AttributeBegin
Color [1.0 0.6 0.0] # A nice orange color
Surface "plastic" "Ka" [1] "Kd" [0.5] "Ks" 1 "roughness" 0.1
TransformBegin
Rotate 90 1 0 0 # Rotate +z to +y. "Up" in default camera coordinates is +y,
Sphere 1 -1 1 360 # but the Sphere primitive has its poles on the z axis.
TransformEnd
AttributeEnd
WorldEnd
FrameEnd

simple.jpg
  • -
  • -

Linux設定メモ

2018/10/23
■Linux設定メモ

ホームディレクトリのフォルダ名を日本語から英語に変更する
$ LANG=C xdg-user-dirs-gtk-update

nautilus-open-terminal
フォルダ内右クリックで[端末の中に開く]

cannot restore segment prot after reloc permission denied
SELinuxのライブラリに対するセキュリティ属性が適切に設定されていない……lightflowPM.soなどのセキュリティ属性を変更する。
rootユーザで
chcon -c -v -R -u system_u -r object_r -t textrel_shlib_t xxx.so


バッテリー確認
$ upower -d

実行形式
$ chmod -R 755 simplescene*

フォルダ削除 一つ上の場所で
# sudo rm -rf gcc-2.95/

Virtualbox dvd-r読み書き用に元ユーザを参加させる
$ sudo gpasswd -a mac vboxusers

フォルダのコピー
$ cp -r gcc-2.95 ~/Documents/
$ sudo cp -r gcc-2.95 /usr/local

Linuxバージョン確認
$ cat /proc/version

/lib/x86_64-linux-gnu/libc.so.6

削除
sudo rpm -e VirtualBox-5.2-5.2.18_124319_fedora26-1.x86_64
インストール
sudo rpm -ivh VirtualBox-5.2-5.2.20_125813_fedora26-1.x86_64.rpm


DVD書込み
growisofs -Z /dev/cdrom -R -J /home/mac/Downloads/isodata/

ありがとうございます。
最初の書込み(R/RW共通),上書きの場合(RWのみ)
growisofs -Z /dev/dvd -R -J ファイル and/or ディレクトリ(群)

追加書込みの場合(R/RW共通)
growisofs -M /dev/dvd -R -J ファイル and/or ディレクトリ(群)

gcc
http://ftp.tsukuba.wide.ad.jp/software/gcc/

glibc確認、下記のコマンドを実行する。
ls -l /lib/libc-*

dnf -v grouplist

http://ftp.jaist.ac.jp/pub/Linux/

Macでisoイメージの作成。
ディスクユーティリティーのコマンドは以下の通り。 isoにしたいディレクトリをDIRの部分に指定する。
hdiutil makehybrid -iso -joliet -o sample.iso DIR

Fedora8 virtualbox guestaddインストール後、起動しない。
unable to load Selinux カーネルパニック 起動しない。
シングルモード起動時 selinux=0 singleで起動。
/etc/selinux/configを編集。
SELINUX=disabledに変更
再起動、guest addition toolが動きました。ありがとうございます。

ロック画面のまま、ログインウィンドウが表示されない場合は、
Ctrl + Alt + F1 でコマンドラインを表示

■共有フォルダ設定、VirtualboxのゲストOS上で
# gpasswd --add {ユーザ名} vboxsf
ユーザをvboxsfグループに追加します。

■VirtualBox共有フォルダ
ubuntu系
sudo nano /etc/modules
cat /etc/modules
# /etc/modules: kernel modules to load at boot time.
#
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with "#" are ignored.
vboxsf
--------------

ゲストOSに$mkdir <マウントポイント名>
フォルダを作る。

$sudo mount.vboxsf <設定したホストOSでの共有ファイル名> /home/<ログインに使う名前>/<マウントポイント名>

■その他
tkinter確認
$ python -m Tkinter

iv install
$ sudo apt install openimageio-tools

■論理cpu数 確認
$ grep processor /proc/cpuinfo | wc -l

##ISO ファイル(CDイメージ)を作成する方法##
ファイルやフォルダからisoファイルを作成する場合
# mkisofs -r -J -V <ラベル> -o <ディレクトリ名>
(例)# mkisofs -r -J -V "Mydata" -o imagecd.iso /home/hoge/
  • -
  • -

Lightflow C API sample cornell box

main8.cpp
#includeの両側に半角スペースが入っています。


#include < Lightflow/LfLocalSceneProxy.h >

int main()
{
LfLocalSceneProxy* s = new LfLocalSceneProxy();
LfArgList list;
LfTransform trs;

list.Reset();
list << "trace-depth" << LfInt( 6 );
list << "radiosity-samples" << LfInt( 400 );
list << "radiosity-threshold" << 0.1;
list << "radiosity-reuse-distance" << 0.25, 0.4, 0.01;
list << "photon-count" << LfInt( 300000 );
list << "photon-clustering-count" << LfInt( 2000 ) << LfInt( 100 );
s->NewInterface( "default", list );

// the "trace-depth" attribute controls the maximal number of ray-traced
// light bounces.
// the "radiosity-depth" attribute controls the maximal number of
// radiosity iterations, that is to say the number of bounces of the indirect
// illumination.
// the "radiosity-samples" attribute sets the amount of rays that are
// used to sample the light space at every surface location. Normally
// values between 200 and 500 produce good results. Note that this parameter
// is very influent on the rendering time, since light sampling is one
// of the most time consuming tasks.
// "radiosity-threshold" sets the maximal error bound in the radiosity
// estimation. A value of 0.1 means that the error is allowed to be 10%
// of the real value.
// "radiosity-reuse-distance" sets the screen, maximum and minimum distance
// from different sampling locations. This parameter is the only one that
// must be set accordingly to the scene size. The smaller these values are,
// the better the result will be, but usually a good value for the
// screen distance is from 0.2 to 0.5, while a good value for the
// maximum distance is everything greater than one fifth of the length
// of the visible surfaces.
// In this case we are modeling a room with sides 2 unities long, hence
// a value of 0.4 will prove to be good enough. The minimum distance
// should be an order of magnitude less.
// should be an order of magnitude less.
// The "photon-count" parameter controls the amount of photons that are
// spread into the scene to compute the global illumination. Obviously
// more photons means better approximations and longer times.


list.Reset();
list << "position" << LfPoint( 0, 0, 0.98 );
list << "direction" << LfVector3( 0, 0, -1 );
list << "angle" << 0.0 << PI / 2.0;
list << "radius" << 0.05;
list << "samples" << LfInt( 7 );
list << "color" << LfColor( 8, 8, 8 );
s->LightOn( s->NewLight( "soft-conic", list ) );

// We simulate an area light with a conic light that produces soft
// shadows. The spreading angle of the light is set to 90 degrees
// (PI / 2 in radians) to obtain the same light distribution of a patch
// light source. We could also put a real "patch" light, with a well
// defined surface, but the computation times would have been longer.
// Check the class documentation to see how area lights work, and how
// fake soft shadows may be obtained with the "soft" and "soft-conic" types.


list.Reset();
list << "kc" << LfColor( 3, 3, 3 );
list << "shadowing" << 0.0;
LfInt neon = s->NewMaterial( "matte", list );

list.Reset();
list << "kdr" << LfColor( 0.9, 0.9, 0.9 );
list << "ksr" << LfColor( 0.5, 0.5, 0.5 );
list << "km" << 0.07;
list << "shinyness" << 1.0;
list << "radiosity" << LfInt( 1 );
list << "caustics" << LfInt( 0 ) << LfInt( 0 );
LfInt whitewash = s->NewMaterial( "generic", list );

list.Reset();
list << "kdr" << LfColor( 0.8, 0.1, 0.1 );
list << "ksr" << LfColor( 0.5, 0.5, 0.5 );
list << "km" << 0.07;
list << "shinyness" << 1.0;
list << "radiosity" << LfInt( 1 );
list << "caustics" << LfInt( 0 ) << LfInt( 0 );
LfInt redwash = s->NewMaterial( "generic", list );

list.Reset();
list << "kdr" << LfColor( 0.2, 0.3, 0.8 );
list << "ksr" << LfColor( 0.5, 0.5, 0.5 );
list << "km" << 0.07;
list << "shinyness" << 1.0;
list << "radiosity" << LfInt( 1 );
list << "caustics" << LfInt( 0 ) << LfInt( 0 );
LfInt bluewash = s->NewMaterial( "generic", list );

list.Reset();
list << "kdr" << LfColor( 0.9, 0.9, 0.9 );
list << "ksr" << LfColor( 0.5, 0.5, 0.5 );
list << "km" << 0.07;
list << "shinyness" << 1.0;
list << "radiosity" << LfInt( 1 );
list << "caustics" << LfInt( 0 ) << LfInt( 0 );
list << "visibility" << LfInt( 1 );
LfInt trnswash = s->NewMaterial( "generic", list );

list.Reset();
list << "fresnel" << LfInt( 1 );
list << "IOR" << 9.0;
list << "kr" << LfColor( 1, 1, 1 );
list << "kt" << LfColor( 1, 1, 1 );
list << "kd" << 0.0;
list << "km" << 0.02;
list << "shinyness" << 1.0;
list << "radiosity" << LfInt( 0 );
list << "caustics" << LfInt( 2 ) << LfInt( 2 );
LfInt metal = s->NewMaterial( "physical", list );

list.Reset();
list << "fresnel" << LfInt( 1 );
list << "IOR" << 1.57;
list << "kdr" << LfColor( 0, 0, 0 );
list << "kdt" << LfColor( 0, 0, 0 );
list << "ksr" << LfColor( 1, 1, 1 ) << LfColor( 0.5, 0.8, 1 );
list << "kst" << LfColor( 1, 1, 1 ) << LfColor( 1, 0.6, 0.2 );
list << "kr" << LfColor( 1, 1, 1 );
list << "kt" << LfColor( 1, 1, 1 );
list << "km" << 0.02;
list << "shinyness" << 1.0;
list << "radiosity" << LfInt( 0 );
list << "caustics" << LfInt( 2 ) << LfInt( 2 );
LfInt glass = s->NewMaterial( "generic", list );


s->MaterialBegin( whitewash );

list.Reset();
list << "points"
<< LfVector3( -0.25, -0.25, 0.995 ) << LfVector3( 0.25, -0.25, 0.995 )
<< LfVector3( -0.25, 0.25, 0.995 ) << LfVector3( 0.25, 0.25, 0.995 );
s->AddObject( s->NewObject( "patch", list ));

list.Reset();
list << "points"
<< LfVector3( -0.25, 0.25, 0.99 ) << LfVector3( 0.25, 0.25, 0.99 )
<< LfVector3( -0.25, 0.25, 1.00 ) << LfVector3( 0.25, 0.25, 1.00 );
s->AddObject( s->NewObject( "patch", list ));

list.Reset();
list << "points"
<< LfVector3( -0.25, -0.25, 0.99 ) << LfVector3( -0.25, -0.25, 1.00 )
<< LfVector3( 0.25, -0.25, 0.99 ) << LfVector3( 0.25, -0.25, 1.00 );
s->AddObject( s->NewObject( "patch", list ));

list.Reset();
list << "points"
<< LfVector3( 0.25, -0.25, 0.99 ) << LfVector3( 0.25, -0.25, 1.00 )
<< LfVector3( 0.25, 0.25, 0.99 ) << LfVector3( 0.25, 0.25, 1.00 );
s->AddObject( s->NewObject( "patch", list ));

list.Reset();
list << "points"
<< LfVector3( -0.25, -0.25, 0.99 ) << LfVector3( -0.25, 0.25,
0.99 )
<< LfVector3( -0.25, -0.25, 1.00 ) << LfVector3( -0.25, 0.25, 1.00 );
s->AddObject( s->NewObject( "patch", list ));

s->MaterialEnd();

s->MaterialBegin( neon );

list.Reset();
list << "points"
<< LfVector3( -0.25, -0.25, 0.99 ) << LfVector3( 0.25, -0.25, 0.99 )
<< LfVector3( -0.25, 0.25, 0.99 ) << LfVector3( 0.25, 0.25, 0.99 );
s->AddObject( s->NewObject( "patch", list ));

s->MaterialEnd();

s->MaterialBegin( trnswash );

list.Reset();
list << "points"
<< LfVector3( -1, -1, -1 ) << LfVector3( 1, -1, -1 )
<< LfVector3( -1, -1, 1 ) << LfVector3( 1, -1, 1 );
s->AddObject( s->NewObject( "patch", list ));

s->MaterialEnd();

s->MaterialBegin( whitewash );

list.Reset();
list << "points"
<< LfVector3( -1, -1, -1 ) << LfVector3( -1, 1, -1 )
<< LfVector3( 1, -1, -1 ) << LfVector3( 1, 1, -1 );
s->AddObject( s->NewObject( "patch", list ));

list.Reset();
list << "points"
<< LfVector3( -1, -1, 1 ) << LfVector3( 1, -1, 1 )
<< LfVector3( -1, 1, 1 ) << LfVector3( 1, 1, 1 );
s->AddObject( s->NewObject( "patch", list ));

list.Reset();
list << "points"
<< LfVector3( -1, 1, -1 ) << LfVector3( -1, 1, 1 )
<< LfVector3( 1, 1, -1 ) << LfVector3( 1, 1, 1 );
s->AddObject( s->NewObject( "patch", list ));

s->MaterialEnd();

s->MaterialBegin( redwash );

list.Reset();
list << "points"
<< LfVector3( -1, -1, -1 ) << LfVector3( -1, -1, 1 )
<< LfVector3( -1, 1, -1 ) << LfVector3( -1, 1, 1 );
s->AddObject( s->NewObject( "patch", list ));

s->MaterialEnd();

s->MaterialBegin( bluewash );

list.Reset();
list << "points"
<< LfVector3( 1, -1, -1 ) << LfVector3( 1, 1, -1 )
<< LfVector3( 1, -1, 1 ) << LfVector3( 1, 1, 1 );
s->AddObject( s->NewObject( "patch", list ));

s->MaterialEnd();


s->MaterialBegin( glass );

s->TransformBegin( trs.Translation( LfVector3( -0.45, 0, -0.1 ) ) );

list.Reset();
list << "radius" << 0.35;
s->AddObject( s->NewObject( "sphere", list ) );

s->TransformEnd();

s->MaterialEnd();


s->MaterialBegin( metal );

s->TransformBegin( trs.Translation( LfVector3( 0.45, 0.4, -0.65 ) )
);

list.Reset();
list << "radius" << 0.35;
s->AddObject( s->NewObject( "sphere", list ) );

s->TransformEnd();

s->MaterialEnd();


list.Reset();
list << "file" << "cornell.tga";
LfInt saver = s->NewImager( "tga-saver", list );

s->ImagerBegin( saver );

list.Reset();
list << "eye" << LfPoint( 0, -2.99, 0 );
list << "aim" << LfPoint( 0, 0, 0 );
LfInt camera = s->NewCamera( "pinhole", list );

s->ImagerEnd();

s->Render( camera, 300, 300 );

delete s;
}


$ /usr/local/gcc-2.95/bin/g++ -I ./include -lLightflow main8.cpp -o simplescene8
$ ./simplescene8
$ convert cornell.tga cornell.jpg
$ eog cornell.jpg
cornell.jpg
  • -
  • -
<< 10/184 >>