Rendering学習日記

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

<< Linux設定メモ | main | python cgkit has been installed on my Zorin-OS-12.4-Core-64 >>

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します。

In file included from rib.y:2835:0:
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
RenderMan | - | -