レイトレーシング入門 -...

119
レイトレーシング入門 放送大学 面接授業 担当講師鈴木一史 (放送大学・教育支援センター・准教授) V.2015‐10 改6 担当講師の電子メールアドレス [email protected]

Transcript of レイトレーシング入門 -...

Page 1: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

レイトレーシング入門放送大学 面接授業

担当講師: 鈴木一史 (放送大学・教育支援センター・准教授)

V.2015‐10 改6

担当講師の電子メールアドレス

[email protected]

Page 2: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

レイトレーシング入門 放送大学

専門科目: 情報

参考サイト http://goo.gl/6GZJL

(土)

1 レイトレーシングの仕組み、POV‐RAYの操作

2 基本形状、テクスチャ、材質、空、地面

3 金属、ガラス、拡大縮小、回転、平行移動

4 様々な光源、CSGとブーリアン演算、作品発表(数分の簡単な説明。希望者のみ)

(日)

5 カメラ、光源、虹、霧、フォント

6 ハイトフィールド、ポリゴン、ボリュームデータ

7 アニメーション化、プログラミング

8 作品制作、作品発表(数分の簡単な説明。希望者のみ)

Page 3: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

PCの準備

Page 4: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

ファイルをUSBメモリーにコピー

右クリックメニューの「コピー」を使う方法

1. ファイルを右クリックし、「コピー」をクリックする。

2. コピー先のフォルダで、右クリックし「貼り付け」をクリックする。コピー先のフォルダにファイルがコピーされます。

ドラッグ&ドロップでコピーする方法

1. USBメモリーは、ファイルやフォルダをドラッグ&ドロップするだけでコピーできます。例としてUSBメモリーにファイルをコピーする方法を説明します。

2. USBメモリーをUSBコネクターに差し込む。USBメモリーのフォルダが開きます。

3. データを保存しているフォルダを開き、USBメモリーのフォルダにファイルをドラッグ&ドロップする。

Page 5: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

USBメモリーの取り外し

USBメモリなどを安全に取り外すには、以下の操作手順を行ってください。

1. 「Windows」キーを押しながら「D」キーを押して「デスクトップ」を表示します。2. デスクトップのタスクバーの通知領域に表示されている「 」をクリックします。

3. 表示された一覧から「ハードウェアを安全に取り外してメディアを取り出す」アイコンをクリックします。

4. 表示された一覧から取り外す周辺機器の項目をクリックします。ここでは例として、「USB Flash Diskの取り出し」をクリックします。

Page 6: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

Page 7: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

Windows、Mac OS X、Linux等をはじめ、様々なオペレーティングシステム上で動作

Windows、Mac OS X、Linux等をはじめ、様々なオペレーティングシステム上で動作

POV-Ray (ポブレイ)POV-Ray (ポブレイ)

レイトレーシングによる非常に美しいコンピューターグラフィックス画像を生成できる

レイトレーシングによる非常に美しいコンピューターグラフィックス画像を生成できる

POV-Ray(ポブレイ)は、Persistence of Vision Raytracerの略 POV-Ray(ポブレイ)は、Persistence of Vision Raytracerの略

フリーウェア。C++言語によって書かれたソースコードも公開 フリーウェア。C++言語によって書かれたソースコードも公開

その歴史は古く1980年代から開発が始まる その歴史は古く1980年代から開発が始まる

The POV-Teamという開発者達によって現在も開発が進む The POV-Teamという開発者達によって現在も開発が進む

Persistence:存続(すること)、持続性 Vision:画像、映像、視力、視覚 Persistence:存続(すること)、持続性 Vision:画像、映像、視力、視覚

Page 8: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

POV-Rayの情報POV-Rayの情報

http://www.povray.org/ http://www.povray.org/

様々なOSで利用が可能 Windows Mac Linux

様々なOSで利用が可能 Windows Mac Linux

バージョン3.6と3.7がある バージョン3.6と3.7がある

Page 9: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

POV-Rayの画面 (MS-Windows版)POV-Rayの画面 (MS-Windows版)

ワープロソフトウェアと似ているシーン記述言語を入力してレンダリングを実行ワープロソフトウェアと似ているシーン記述言語を入力してレンダリングを実行

Page 10: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

授業で利用するソースプログラムファイル準備授業で利用するソースプログラムファイル準備

1. ZIPファイル(ソースプログラム)の取得1. ZIPファイル(ソースプログラム)の取得

2. ZIPファイルを保存2. ZIPファイルを保存

3. ZIPファイルの解凍 ファイル選択し、右クリックして「すべて展開」

3. ZIPファイルの解凍 ファイル選択し、右クリックして「すべて展開」

http://goo.gl/w3NGy0 ダブリュー、サン、エヌ、ジー、ワイ、ゼロ 大文字と小文字も区別

解凍には時間がかかる(2-3分程度)

Page 11: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

POV-RayのメニューPOV-Rayのメニュー

出力画像のサイズ変更出力画像のサイズ変更

新ファイル作成新ファイル作成 レンダリング実行レンダリング実行ファイルを開くファイルを開く

よく利用するボタンの例よく利用するボタンの例

Page 12: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

POV-Rayとシーン記述言語POV-Rayとシーン記述言語

シーン記述言語(xxxxxx.pov)シーン記述言語(xxxxxx.pov) 画像の出力(xxxxxx.bmp)画像の出力(xxxxxx.bmp)

Windows標準では、povファイルと画像は以下のディレクトリに保存される

ドキュメント → Pov-Ray → v3.6 → scenes Windows標準では、povファイルと画像は以下のディレクトリに保存される

ドキュメント → Pov-Ray → v3.6 → scenes

Page 13: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

POV-Rayの設定POV-Rayの設定

PNG(Portable Network Graphics)利用が便利(Win7等)

→ レンダリングオプションに"+FN"を付け加える

PNG(Portable Network Graphics)利用が便利(Win7等)

→ レンダリングオプションに"+FN"を付け加える

標準設定での出力

Windows → bmpMac → pictLinux → tga

標準設定での出力

Windows → bmpMac → pictLinux → tga

画質は良いがファイルのサイズが非常に大きい画質は良いがファイルのサイズが非常に大きい

Page 14: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

POV-Rayを動かしてみようPOV-Rayを動かしてみよう

シーン記述ファイルを開く 01-sample.pov 読み込む Runボタンで実行

シーン記述ファイルを開く 01-sample.pov 読み込む Runボタンで実行

//  2013camera{ location <0.0, 0.0, ‐10.0> look_at <0.0, 0.0, 0.0>} light_source { <5.0,5.0,‐5.0> color rgb <1.0, 1.0, 1.0>} sphere { <0.0, 0.0 ,0.0>, 2.0 pigment { rgb <0.0, 1.0, 0.0> }} 

//  2013camera{ location <0.0, 0.0, ‐10.0> look_at <0.0, 0.0, 0.0>} light_source { <5.0,5.0,‐5.0> color rgb <1.0, 1.0, 1.0>} sphere { <0.0, 0.0 ,0.0>, 2.0 pigment { rgb <0.0, 1.0, 0.0> }} 

画像のサイズを変更してみましょう 画像ファイルができたフォルダを開

いてみましょう

画像のサイズを変更してみましょう 画像ファイルができたフォルダを開

いてみましょう

Page 15: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

3次元空間3次元空間

+X+X

+Z+Z+Y+Y

-X-X

-Z-Z-Y-Y

(0,0,0)(0,0,0)

3次元空間に物体が置かれる3次元空間に物体が置かれる

Page 16: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

RGBカラーモデルRGBカラーモデル

カラー画像(Color Image)カラー画像(Color Image)

グレースケール画像(Grayscale Image)グレースケール画像(Grayscale Image)

白から黒に至る中間色(濃度の異なる灰色)白から黒に至る中間色(濃度の異なる灰色)

RGBカラーモデルRGBカラーモデル

+ +++ ++==

■■■■■■■■■■■■■■■■■■■■

(加法混色)(加法混色)

Page 17: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

RGBカラーモデルRGBカラーモデル

• 赤色(Red) → シアン(Cyan)• 緑色(Green)→ マジェンタ(Magenta)• 青色(Blue) → 黄色(Yellow)

• 赤色(Red) → シアン(Cyan)• 緑色(Green)→ マジェンタ(Magenta)• 青色(Blue) → 黄色(Yellow)

■RGB=(1,0,0) → ■RGB=(0,1,1)■RGB=(0,1,0) → ■RGB=(1,0,1)■RGB=(0,0,1) → ■RGB=(1,1,0)

■RGB=(1,0,0) → ■RGB=(0,1,1)■RGB=(0,1,0) → ■RGB=(1,0,1)■RGB=(0,0,1) → ■RGB=(1,1,0)

加法混色(Additive Color Mixing)

加法混色(Additive Color Mixing)

POV-rayの場合• 0.0 最小値• 1.0 最大値

POV-rayの場合• 0.0 最小値• 1.0 最大値

Page 18: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

シーン記述言語シーン記述言語

← カメラ← カメラ

//  2013camera{ location <0.0, 0.0, ‐10.0> look_at <0.0, 0.0, 0.0>} 

light_source { <5.0,5.0,‐5.0> color rgb <1.0, 1.0, 1.0>} 

sphere { <0.0, 0.0 ,0.0>, 2.0 pigment { rgb <0.0, 1.0, 0.0> }} 

//  2013camera{ location <0.0, 0.0, ‐10.0> look_at <0.0, 0.0, 0.0>} 

light_source { <5.0,5.0,‐5.0> color rgb <1.0, 1.0, 1.0>} 

sphere { <0.0, 0.0 ,0.0>, 2.0 pigment { rgb <0.0, 1.0, 0.0> }} 

← 物体← 物体

← 照明← 照明

カメラの位置 カメラが向いている方向 カメラの位置 カメラが向いている方向

照明の位置 照明の色 (RGB値) 照明の位置 照明の色 (RGB値)

球の位置、球の半径 球の色 (RGB値) 球の位置、球の半径 球の色 (RGB値)

Page 19: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

物体の色を変える物体の色を変える

球の色を変えてみようrgb <1.0, 0.0, 0.0>

球の色を変えてみようrgb <1.0, 0.0, 0.0>

//  01‐sphere01.povcamera{ location <0.0, 0.0, ‐10.0> look_at <0.0, 0.0, 0.0>} light_source { <5.0,5.0,‐5.0> color rgb <1.0, 1.0, 1.0>} sphere { <0.0, 0.0 ,0.0>, 3.0 pigment { rgb <1.0, 0.0, 0.0> }} 

//  01‐sphere01.povcamera{ location <0.0, 0.0, ‐10.0> look_at <0.0, 0.0, 0.0>} light_source { <5.0,5.0,‐5.0> color rgb <1.0, 1.0, 1.0>} sphere { <0.0, 0.0 ,0.0>, 3.0 pigment { rgb <1.0, 0.0, 0.0> }} 

球の大きさを変えてみよう<0.0, 0.0 ,0.0>, 3.0

球の大きさを変えてみよう<0.0, 0.0 ,0.0>, 3.0

← 球の色← 球の色

← 球の大きさ← 球の大きさ

Page 20: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

物体の位置物体の位置

//  01‐sphere02.povcamera{ location <0.0, 0.0, ‐10.0> look_at <0.0, 0.0, 0.0>} light_source { <5.0,5.0,‐5.0> color rgb <1.0, 1.0, 1.0>} sphere { <3.0, 0.0 ,0.0>, 2.0 pigment { rgb <0.0, 1.0, 0.0> }} 

//  01‐sphere02.povcamera{ location <0.0, 0.0, ‐10.0> look_at <0.0, 0.0, 0.0>} light_source { <5.0,5.0,‐5.0> color rgb <1.0, 1.0, 1.0>} sphere { <3.0, 0.0 ,0.0>, 2.0 pigment { rgb <0.0, 1.0, 0.0> }} 

球の位置を変えてみようsphere { <3.0, 0.0 ,0.0>, 2.0 } 球の位置を変えてみよう

sphere { <3.0, 0.0 ,0.0>, 2.0 }

← 球の3次元座標← 球の3次元座標

Page 21: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

複数の物体複数の物体

//  01‐sphere03.povsphere { <0.0, 0.0 ,0.0>, 2.0 pigment { rgb <1.0, 0.0, 0.0> }}    sphere { <‐4.0, 0.0 ,0.0>, 2.0  pigment { rgb <0.0, 1.0, 0.0> }} sphere { <4.0, 0.0 ,0.0>, 2.0  pigment { rgb <0.0, 0.0, 1.0> }} 

//  01‐sphere03.povsphere { <0.0, 0.0 ,0.0>, 2.0 pigment { rgb <1.0, 0.0, 0.0> }}    sphere { <‐4.0, 0.0 ,0.0>, 2.0  pigment { rgb <0.0, 1.0, 0.0> }} sphere { <4.0, 0.0 ,0.0>, 2.0  pigment { rgb <0.0, 0.0, 1.0> }} 

球を増やしてみよう 球を増やしてみよう

← 球(赤)← 球(赤)

← 球(緑)← 球(緑)

← 球(青)← 球(青)

Page 22: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

様々な形状の物体(三角錐・コーン)様々な形状の物体(三角錐・コーン)

//  01‐cone01.povcamera{ location <0.0, 0.0, ‐10.0> look_at <0.0, 0.0, 0.0>} light_source { <5.0,5.0,‐5.0> color rgb <1.0, 1.0, 1.0>} cone {  <0, 3, 0>, 0.0   <0, 0, 0>, 1.0  open          pigment {color rgb <0.0, 1.0, 0.0>}}

//  01‐cone01.povcamera{ location <0.0, 0.0, ‐10.0> look_at <0.0, 0.0, 0.0>} light_source { <5.0,5.0,‐5.0> color rgb <1.0, 1.0, 1.0>} cone {  <0, 3, 0>, 0.0   <0, 0, 0>, 1.0  open          pigment {color rgb <0.0, 1.0, 0.0>}}

Openを指定すると蓋が無くなる。

Openを指定すると蓋が無くなる。

円の中心座標と半径

円の中心座標と半径

円の中心座標と半径

円の中心座標と半径

Page 23: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

様々な形状の物体(直方体、ボックス)様々な形状の物体(直方体、ボックス)

//  01‐box01.povcamera{ location <0.0, 0.0, ‐10.0> look_at <0.0, 0.0, 0.0>} light_source { <5.0,5.0,‐5.0> color rgb <1.0, 1.0, 1.0>} box {<‐1.0, ‐1.0, ‐1.0> < 1.0,  1.0,  1.0>  pigment {color rgb <0.0, 1.0, 0.0>}}

//  01‐box01.povcamera{ location <0.0, 0.0, ‐10.0> look_at <0.0, 0.0, 0.0>} light_source { <5.0,5.0,‐5.0> color rgb <1.0, 1.0, 1.0>} box {<‐1.0, ‐1.0, ‐1.0> < 1.0,  1.0,  1.0>  pigment {color rgb <0.0, 1.0, 0.0>}}

点の座標1 点の座標1

点の座標2 点の座標2

Page 24: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

様々な形状の物体(円柱、シリンダー)様々な形状の物体(円柱、シリンダー)

//  01‐cylinder01.povcamera{ location <0.0, 0.0, ‐10.0> look_at <0.0, 0.0, 0.0>} light_source { <5.0,5.0,‐5.0> color rgb <1.0, 1.0, 1.0>} cylinder { <0, 0, 0>, <3, 3, 3>, 1 pigment {color rgb <0.0, 1.0, 0.0>}} 

//  01‐cylinder01.povcamera{ location <0.0, 0.0, ‐10.0> look_at <0.0, 0.0, 0.0>} light_source { <5.0,5.0,‐5.0> color rgb <1.0, 1.0, 1.0>} cylinder { <0, 0, 0>, <3, 3, 3>, 1 pigment {color rgb <0.0, 1.0, 0.0>}} 

円の中心座標 円の中心座標

円の中心座標 円の中心座標

円半径 円半径

Page 25: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

様々な形状の物体(トーラス)様々な形状の物体(トーラス)

//  01‐torus01.povcamera{ location <0.0, 3.0, ‐3.0> look_at <0.0, 0.0, 0.0>} light_source { <5.0,5.0,‐5.0> color rgb <1.0, 1.0, 1.0>} torus {0.8,0.6pigment {color rgb <0.0, 1.0, 0.0>}}

//  01‐torus01.povcamera{ location <0.0, 3.0, ‐3.0> look_at <0.0, 0.0, 0.0>} light_source { <5.0,5.0,‐5.0> color rgb <1.0, 1.0, 1.0>} torus {0.8,0.6pigment {color rgb <0.0, 1.0, 0.0>}}

X-Z平面の原点がドーナツの中心になる X-Z平面の原点がドーナツの中心になる

マイナー半径

メジャー半径

中心線

Page 26: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

様々な形状の例様々な形状の例 Blob Box Cone Cylinder Height Field Julia Fractal Lathe Prism Sphere Sphere Sweep Superquadric Ellipsoid Surface of Revolution Text Torus

Blob Box Cone Cylinder Height Field Julia Fractal Lathe Prism Sphere Sphere Sweep Superquadric Ellipsoid Surface of Revolution Text Torus

Insert / Shapesに様々な形状がある 手で文字入力しなくても良い ?ヘルプに書式の説明あり

Insert / Shapesに様々な形状がある 手で文字入力しなくても良い ?ヘルプに書式の説明あり

Page 27: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

エディターのフォントの大きさを変える Options | Editor Window | Editor Preferences |

Color/Font | Font

エディターのフォントの大きさを変える Options | Editor Window | Editor Preferences |

Color/Font | Font

POV-Rayの設定POV-Rayの設定

レンダリング完了時の音を消す Render | Sound Settings…

Render Complete のチェックをオフにする

レンダリング完了時の音を消す Render | Sound Settings…

Render Complete のチェックをオフにする

Page 28: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

chocolate (0.82, 0.41, 0.12)

firebrick (0.70, 0.13, 0.13)brown (0.65, 0.16, 0.16)DarkSalmon (0.91, 0.59, 0.48)salmon (0.98, 0.50, 0.45)LightSalmon (1.00, 0.63, 0.48)orange (1.00, 0.65, 0.00)DarkOrange (1.00, 0.55, 0.00)coral (1.00, 0.50, 0.31)LightCoral (0.94, 0.50, 0.50)tomato (1.00, 0.39, 0.28)OrangeRed (1.00, 0.27, 0.00)red (1.00, 0.00, 0.00)HotPink (1.00, 0.41, 0.71)DeepPink (1.00, 0.08, 0.58)pink (1.00, 0.75, 0.80)LightPink (1.00, 0.71, 0.76)PaleVioletRed (0.86, 0.44, 0.58)maroon (0.69, 0.19, 0.38)MediumVioletRed (0.78, 0.08, 0.52)VioletRed (0.82, 0.13, 0.56)magenta (1.00, 0.00, 1.00)violet (0.93, 0.51, 0.93)plum (0.87, 0.63, 0.87)orchid (0.85, 0.44, 0.84)MediumOrchid (0.73, 0.33, 0.83)DarkOrchid (0.60, 0.20, 0.80)

Page 29: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

LightBlue (0.68, 0.85, 0.90)PowderBlue (0.69, 0.88, 0.90)PaleTurquoise (0.69, 0.93, 0.93)DarkTurquoise (0.00, 0.81, 0.82)MediumTurquoise (0.28, 0.82, 0.80)turquoise (0.25, 0.88, 0.82)cyan (0.00, 1.00, 1.00)LightCyan (0.88, 1.00, 1.00)CadetBlue (0.37, 0.62, 0.63)MediumAquamarine (0.40, 0.80, 0.67)aquamarine (0.50, 1.00, 0.83)DarkGreen (0.00, 0.39, 0.00)DarkOliveGreen (0.33, 0.42, 0.18)DarkSeaGreen (0.56, 0.74, 0.56)SeaGreen (0.18, 0.55, 0.34)MediumSeaGreen (0.24, 0.70, 0.44)LightSeaGreen (0.13, 0.70, 0.67)PaleGreen (0.60, 0.98, 0.60)SpringGreen (0.00, 1.00, 0.50)LawnGreen (0.49, 0.99, 0.00)green (0.00, 1.00, 0.00)chartreuse (0.50, 1.00, 0.00)MediumSpringGreen (0.00, 0.98, 0.60)GreenYellow (0.68, 1.00, 0.18)LimeGreen (0.20, 0.80, 0.20)

Page 30: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

OldLace (0.99, 0.96, 0.90)linen (0.98, 0.94, 0.90)AntiqueWhite (0.98, 0.92, 0.84)PapayaWhip (1.00, 0.94, 0.84)BlanchedAlmond (1.00, 0.92, 0.80)bisque (1.00, 0.89, 0.77)PeachPuff (1.00, 0.85, 0.73)NavajoWhite (1.00, 0.87, 0.68)moccasin (1.00, 0.89, 0.71)cornsilk (1.00, 0.97, 0.86)ivory (1.00, 1.00, 0.94)LemonChiffon (1.00, 0.98, 0.80)seashell (1.00, 0.96, 0.93)honeydew (0.94, 1.00, 0.94)MintCream (0.96, 1.00, 0.98)azure (0.94, 1.00, 1.00)AliceBlue (0.94, 0.97, 1.00)lavender (0.90, 0.90, 0.98)LavenderBlush (1.00, 0.94, 0.96)MistyRose (1.00, 0.89, 0.88)white (1.00, 1.00, 1.00)

Page 31: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

ファイルの保存ファイルの保存

こまめにバックアップを! こまめにバックアップを!

FileメニューからSave As … で別名をつけて保存できるFileメニューからSave As … で別名をつけて保存できる

Sphere001.povSphere002.povSphere003.povSphere004.pov

Sphere001.povSphere002.povSphere003.povSphere004.pov

例えば:例えば:

学習センターでは、マイドキュメントフォルダ以外に保存するとデータが消える(PC起動時にデータが初期化される)

重要なファイルはUSBメモリーへコピーするかメールに添付して保存する

学習センターでは、マイドキュメントフォルダ以外に保存するとデータが消える(PC起動時にデータが初期化される)

重要なファイルはUSBメモリーへコピーするかメールに添付して保存する

Page 32: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

練習課題 ①練習課題 ①

球 立方体 三角錐 円柱 トーラス

球 立方体 三角錐 円柱 トーラス

1. 様々な物体を配置してみよう(最低3個の物体)2. 各物体の色を変えてみよう3. 各物体の大きさを変えてみよう

1. 様々な物体を配置してみよう(最低3個の物体)2. 各物体の色を変えてみよう3. 各物体の大きさを変えてみよう

01-assignment01.pov を参考に・・・01-assignment01.pov を参考に・・・

Page 33: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

Page 34: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

レイトレーシングの仕組みレイトレーシングの仕組み 影付け、屈折、反射などの表現でリアルな画像を生成 影付け、屈折、反射などの表現でリアルな画像を生成

光源から発せられた光で目に届く光をすべて求める レイトレーシングでは、光源から光を追わず視点から光を追跡 可視点の輝度を計算する(拡散反射輝度+鏡面反射輝度+物体反射+物体透過)

光源から発せられた光で目に届く光をすべて求める レイトレーシングでは、光源から光を追わず視点から光を追跡 可視点の輝度を計算する(拡散反射輝度+鏡面反射輝度+物体反射+物体透過)

光源光源

物体物体

視点視点画素画素 可視点可視点

Page 35: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

“colors.inc”を使う“colors.inc”を使う

//  02‐sphere01.pov#include "colors.inc"camera{ location <0.0, 0.0, ‐5.0> look_at <0.0, 0.0, 0.0>} light_source { <5.0,5.0,‐5.0> color rgb <1.0, 1.0, 1.0>} sphere {<0, 0, 0>  0.5      pigment {color Green}}                             

//  02‐sphere01.pov#include "colors.inc"camera{ location <0.0, 0.0, ‐5.0> look_at <0.0, 0.0, 0.0>} light_source { <5.0,5.0,‐5.0> color rgb <1.0, 1.0, 1.0>} sphere {<0, 0, 0>  0.5      pigment {color Green}}                             

#include “colors.inc“ を使うとpigment {color Green} のような宣言が可能になる

#include “colors.inc“ を使うとpigment {color Green} のような宣言が可能になる

http://www.povray.org/documentation/view/3.6.1/433/ http://www.povray.org/documentation/view/3.6.1/433/

Red Green Blue Yellow Cyan Magenta Clear White Black Gray05 Gray10 Gray15 Gray20 Gray25 Gray30 Gray35 Gray40 Gray45 Gray50 Gray55 Gray60 Gray65 Gray70 Gray75 Gray80 Gray85 Gray90 Gray95 DimGray DimGrey Gray Grey LightGray LightGrey VLightGray VLightGreyAquamarine BlueViolet Brown CadetBlue Coral CornflowerBlue DarkGreen DarkOliveGreenDarkOrchid DarkSlateBlue DarkSlateGray DarkSlateGrey DarkTurquoise Firebrick ForestGreenGold Goldenrod GreenYellow IndianRed Khaki LightBlue LightSteelBlue LimeGreen Maroon MediumAquamarine MediumBlueMediumForestGreen MediumGoldenrod MediumOrchid MediumSeaGreen MediumSlateBlueMediumSpringGreen MediumTurquoise MediumVioletRed MidnightBlue Navy NavyBlue Orange OrangeRed Orchid PaleGreen Pink Plum Salmon SeaGreen Sienna SkyBlue SlateBlueSpringGreen SteelBlue Tan Thistle Turquoise Violet VioletRed Wheat Yellow Green SummerSkyRichBlue Brass Copper Bronze Bronze2 Silver BrightGold OldGold Feldspar Quartz Mica NeonPink DarkPurple NeonBlue CoolCopperMandarinOrange LightWood MediumWood DarkWood SpicyPink SemiSweetChoc BakersChocFlesh NewTan NewMidnightBlue VeryDarkBrown DarkBrown DarkTan GreenCopperDkGreenCopper DustyRose HuntersGreen Scarlet Med_Purple Light_Purple Very_Light_Purple

Page 36: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

背景を変える背景を変える

// 02‐sphere02.pov#include “colors.inc“Camera{ location <0.0, 0.0, ‐5.0> look_at <0.0, 0.0, 0.0>} Light_source { <5.0,5.0,‐5.0> color rgb <1.0, 1.0, 1.0>} background{ color SkyBlue }        sphere {<0, 0, 0>  0.5      pigment {color Green}}                 

// 02‐sphere02.pov#include “colors.inc“Camera{ location <0.0, 0.0, ‐5.0> look_at <0.0, 0.0, 0.0>} Light_source { <5.0,5.0,‐5.0> color rgb <1.0, 1.0, 1.0>} background{ color SkyBlue }        sphere {<0, 0, 0>  0.5      pigment {color Green}}                 

background { color SkyBlue } background { color SkyBlue }

Page 37: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

空と地面空と地面

// 02‐sphere03.pov#include "colors.inc"  #include "skies.inc"

camera{ location <0.0, 0.0, ‐5.0> look_at <0.0, 0.0, 0.0>} light_source { <5.0,5.0,‐5.0> color rgb <1.0, 1.0, 1.0>} sky_sphere {S_Cloud1}

// 02‐sphere03.pov#include "colors.inc"  #include "skies.inc"

camera{ location <0.0, 0.0, ‐5.0> look_at <0.0, 0.0, 0.0>} light_source { <5.0,5.0,‐5.0> color rgb <1.0, 1.0, 1.0>} sky_sphere {S_Cloud1}

plane {y, ‐1pigment { color rgb <0.7,0.5,0.3> }}         sphere {<0, 0, 0>  0.5      pigment {color Green}}     

plane {y, ‐1pigment { color rgb <0.7,0.5,0.3> }}         sphere {<0, 0, 0>  0.5      pigment {color Green}}     

空と地面があると見た目が良い!?空と地面があると見た目が良い!?

Page 38: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

空と地面の例空と地面の例

S_Cloud1S_Cloud1 S_Cloud2S_Cloud2 S_Cloud3S_Cloud3

S_Cloud4S_Cloud4 S_Cloud5S_Cloud5

#include "skies.inc"sky sphere {S_Cloud1}

#include "skies.inc"sky sphere {S_Cloud1}

Page 39: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

物体のテクスチャを変える ①物体のテクスチャを変える ①

// 02‐texture01.pov#include "colors.inc"  #include "skies.inc"  #include "textures.inc"         camera{ location <0.0, 0.0, ‐5.0> look_at <0.0, 0.0, 0.0>} light_source { <5.0,5.0,‐5.0> color rgb <1.0, 1.0, 1.0>} sky_sphere {S_Cloud1}

// 02‐texture01.pov#include "colors.inc"  #include "skies.inc"  #include "textures.inc"         camera{ location <0.0, 0.0, ‐5.0> look_at <0.0, 0.0, 0.0>} light_source { <5.0,5.0,‐5.0> color rgb <1.0, 1.0, 1.0>} sky_sphere {S_Cloud1}

plane {y, ‐1pigment { color rgb <0.7,0.5,0.3> }}       

sphere {<0, 0, 0>  1.0     texture {pigment { White_Marble } finish { Shiny }scale 0.5}   }

plane {y, ‐1pigment { color rgb <0.7,0.5,0.3> }}       

sphere {<0, 0, 0>  1.0     texture {pigment { White_Marble } finish { Shiny }scale 0.5}   }

大理石の テクスチャ(模様)大理石の テクスチャ(模様)

Page 40: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

物体のテクスチャを変える ②物体のテクスチャを変える ②

sphere {<0, 0, 0>  1.0     texture {pigment { White_Marble } finish { phong 0.5 }scale 0.5}   }

sphere {<0, 0, 0>  1.0     texture {pigment { White_Marble } finish { phong 0.5 }scale 0.5}   }

Finishは、物体の表面の光の屈折、ハイライトなどを記述

Finishは、物体の表面の光の屈折、ハイライトなどを記述

ライブラリーとして、すでにあるテクスチャを利用できる

ライブラリーとして、すでにあるテクスチャを利用できる

Scaleは、テクスチャのスケールを変える

Scaleは、テクスチャのスケールを変える

Page 41: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

sphere {<0, 0, 0>  1.0     texture {

pigment { White_Marble } }   }

sphere {<0, 0, 0>  1.0     texture {

PinkAlabaster}   }

※ texture{ }を使うとき、pigmentをつけるとエラーになるものがある。

pigment{ }をつけない!

41

テクスチャを使用するために#include文を忘れずに!#include "colors.inc"#include "shapes.inc"#include "textures.inc"#include "Woods.inc"#include "stones.inc"#include "glass.inc"#include "metals.inc"

例1

例2

物体のテクスチャを変える ③物体のテクスチャを変える ③

Page 42: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

// 02‐texture‐list‐1.pov・・・省略sphere {<‐3.0, +3.0, 0>  0.45     texture {

pigment { Jade } }   }・・・省略

42

テクスチャのリスト 「石」テクスチャのリスト 「石」

http://texlib.povray.org/allcategories.html http://texlib.povray.org/allcategories.html

※ Agate(アゲット;めのう), Granite(グラニィト;花崗岩), Jade(ジェイド;ひすい)※ Agate(アゲット;めのう), Granite(グラニィト;花崗岩), Jade(ジェイド;ひすい)

Page 43: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

// ‐‐‐‐‐‐ GLASSES‐‐‐‐‐‐‐

texture {GlassGlass2 //"Plexiglas"Glass3 //"Bleiglas"Green_GlassNBglassNBoldglassNBwinebottleNBbeerbottleRuby_GlassDark_Green_GlassVicks_Bottle_GlassYellow_GlassOrange_Glass

43

ガラス// SPECIAL EFFECTS 

pigment {Candy_CaneY_GradientX_Gradient

texture {PeelWaterCorkLightening1Lightening2Starfield

効果// ‐‐‐SKIES and CLOUDS ‐‐‐pigment {Blue_SkyBright_Blue_SkyBlue_Sky2Blue_Sky3Blood_SkyApocalypseCloudsFBM_Clouds

texture { // ‐‐‐‐‐‐‐SkyShadow_Clouds

空・雲

※ texture{ }を使うとき、pigmentをつけるとエラーになるものがある。

Page 44: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

// ‐‐‐‐‐‐‐‐ WOODS ‐‐‐‐‐‐‐‐pigment {CorkCherry_WoodPine_WoodDark_WoodTan_WoodWhite_WoodTom_WoodDMFWood1DMFWood2DMFWood3DMFWood4DMFWood5DMFLightOakDMFDarkOak

texture { // ‐‐‐‐‐‐ WOODDMFWood6EMBWood1Yellow_PineRosewoodSandalwood

// ‐‐‐‐‐‐ METALS ‐‐‐‐‐‐‐‐texture {Chrome_MetalBrass_MetalBronze_MetalGold_MetalSilver_MetalCopper_MetalPolished_ChromePolished_BrassNew_BrassSpun_BrassBrushed_AluminumSilver1 Silver2 Silver3Brass_ValleyRustRusty_IronSoft_SilverNew_PennyTinny_BrassGold_NuggetAluminumBright_Bronze

44

木 金属

☆ texture{ }を使うとき、pigmentをつけるとエラーになるものがある。

Page 45: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

物体のテクスチャを変える (木と石)物体のテクスチャを変える (木と石)

// 02‐texture02.pov・・・省略sphere {<2, 2, 2>  1.0     texture { T_Wood1 }   }cylinder { <‐1, ‐1, ‐1>, <1, 1, 1>,  0.5 texture {pigment { Jade } finish { Shiny }scale 1.0}   } 

// 02‐texture02.pov・・・省略sphere {<2, 2, 2>  1.0     texture { T_Wood1 }   }cylinder { <‐1, ‐1, ‐1>, <1, 1, 1>,  0.5 texture {pigment { Jade } finish { Shiny }scale 1.0}   } 

#include "colors.inc"#include "shapes.inc"#include "skies.inc“

#include "textures.inc"#include “Woods.inc"#include "stones.inc"                                        #include "glass.inc"#include "metals.inc "

Page 46: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

物体のテクスチャSCALEを変える物体のテクスチャSCALEを変える

// 02‐texture03.povsphere {<0, 0, 0>  1.0     texture {pigment { Red_Marble } finish { Shiny }scale 0.5}   } ・・・省略

// 02‐texture03.povsphere {<0, 0, 0>  1.0     texture {pigment { Red_Marble } finish { Shiny }scale 0.5}   } ・・・省略

1.00, 0.75, 0.50, 0.25, 0.011.00, 0.75, 0.50, 0.25, 0.01

scaleの違いscaleの違い 同じテクスチャでもscaleを変えると

見た目が変化する 同じテクスチャでもscaleを変えると

見た目が変化する

Page 47: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

物体のテクスチャ finish物体のテクスチャ finish

// 02‐texture04.povsphere {<0, 0, 0>  1.0     texture {pigment { Red_Marble } finish { Shiny }scale 0.5}   } ・・・省略

// 02‐texture04.povsphere {<0, 0, 0>  1.0     texture {pigment { Red_Marble } finish { Shiny }scale 0.5}   } ・・・省略

上段:Phong_Shiny, Phong_Dull, Phong_Glossy, 下段:Shiny, Dull, Glossy, Luminous, Mirror上段:Phong_Shiny, Phong_Dull, Phong_Glossy, 下段:Shiny, Dull, Glossy, Luminous, Mirror

表面反射の指定 表面反射の指定

ぴかぴか、くすんだ、つやつやした、光を発する、鏡ぴかぴか、くすんだ、つやつやした、光を発する、鏡

Page 48: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

練習課題 ②練習課題 ②

球 立方体 三角錐 円錐

球 立方体 三角錐 円錐

1. 様々な物体を配置してみよう(最低3個の物体)2. 空または地面を追加してみよう3. 各物体のテクスチャを変えてみよう

1. 様々な物体を配置してみよう(最低3個の物体)2. 空または地面を追加してみよう3. 各物体のテクスチャを変えてみよう

練習課題①を拡張、または、02-assignment01.pov を参考に・・・練習課題①を拡張、または、02-assignment01.pov を参考に・・・

#include "colors.inc"#include "shapes.inc"#include "skies.inc“

#include "textures.inc"#include “Woods.inc"#include "stones.inc"                                        #include "glass.inc"#include "metals.inc "

Page 49: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

Page 50: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

物体のテクスチャを変える (金属)物体のテクスチャを変える (金属)

// 03‐texture01.pov・・・省略sphere {<0, 0, 0>  0.4     texture { Gold_Texture}}  sphere {<+1, 0, 0>  0.4     texture { Silver_Texture}}  sphere {<+2, 0, 0>  0.4     texture { Copper_Texture}

・・・省略} 

// 03‐texture01.pov・・・省略sphere {<0, 0, 0>  0.4     texture { Gold_Texture}}  sphere {<+1, 0, 0>  0.4     texture { Silver_Texture}}  sphere {<+2, 0, 0>  0.4     texture { Copper_Texture}

・・・省略}  #include "metals.inc "

Page 51: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

物体のテクスチャを変える (ガラス)物体のテクスチャを変える (ガラス)

// 03‐texture02.pov・・・省略sphere {<‐2, 0, 0>  0.4     material{M_Glass}}  sphere {<‐1, 0, 0>  0.4     material{M_Glass2}}sphere {<0, 0, 0>  0.4     material{M_Glass3}} 

// 03‐texture02.pov・・・省略sphere {<‐2, 0, 0>  0.4     material{M_Glass}}  sphere {<‐1, 0, 0>  0.4     material{M_Glass2}}sphere {<0, 0, 0>  0.4     material{M_Glass3}} 

ガラスではtextureではなくmaterialを使用する ガラスではtextureではなくmaterialを使用する

{M_Dark_Green_Glass} {M_Yellow_Glass} {M_Orange_Glass} {M_Vicks_Bottle_Glass} {F_Glass1} 

{M_Glass} {M_Glass2} {M_Glass3} {M_Green_Glass} {M_Ruby_Glass} 

#include "glass.inc"

※ ガラスでは透過光が綺麗に表現される。レイトレーシングならではの画像!※ ガラスでは透過光が綺麗に表現される。レイトレーシングならではの画像!

Page 52: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

物体の移動・拡大縮小・回転物体の移動・拡大縮小・回転

移動 (translation) 移動 (translation)

回転 (rotation) 回転 (rotation)

拡大縮小 (scaling) 拡大縮小 (scaling)

アフィン変換(Affine transformation) 図形等を回転、引き延ばしたりする変換はアフィン変換とよばれる 平行移動+線形変換(拡大縮小、回転、剪断)の組み合わせで表

現される

アフィン変換(Affine transformation) 図形等を回転、引き延ばしたりする変換はアフィン変換とよばれる 平行移動+線形変換(拡大縮小、回転、剪断)の組み合わせで表

現される

• Affineは英語の発音ではアファインに近い• 剪断(せんだん)あるいはシア (shear)は、はさみなどを使って挟み切るように、

物体の面に対して平行方向に力が作用すること

Page 53: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

物体の移動物体の移動

// 03‐sphere01.pov・・・省略plane {y, ‐1pigment { color rgb <0.8,0.6,0.4> }}  sphere { <0, 0, 0>, 1pigment { Red }}            sphere { <0, 0, 0>, 1pigment { Green }translate <3,0,0>}

// 03‐sphere01.pov・・・省略plane {y, ‐1pigment { color rgb <0.8,0.6,0.4> }}  sphere { <0, 0, 0>, 1pigment { Red }}            sphere { <0, 0, 0>, 1pigment { Green }translate <3,0,0>}

Page 54: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

物体の拡大縮小物体の拡大縮小

// 03‐sphere02.pov#include "colors.inc"  #include "skies.inc"  sky_sphere {S_Cloud2}plane {y, ‐1pigment { color rgb <0.8,0.6,0.4> }}  

sphere { <0, 0, 0>, 1pigment { Green }scale <3,1,1>}

// 03‐sphere02.pov#include "colors.inc"  #include "skies.inc"  sky_sphere {S_Cloud2}plane {y, ‐1pigment { color rgb <0.8,0.6,0.4> }}  

sphere { <0, 0, 0>, 1pigment { Green }scale <3,1,1>}

Page 55: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

物体の回転物体の回転

// 03‐cyliner01.povsky_sphere {S_Cloud2}plane {y, ‐1pigment { color rgb <0.8,0.6,0.4> }}  cylinder {  <0, 0, 0>, <0, 3, 0>, 1 pigment { Green }rotate <0,0,45>}

// 03‐cyliner01.povsky_sphere {S_Cloud2}plane {y, ‐1pigment { color rgb <0.8,0.6,0.4> }}  cylinder {  <0, 0, 0>, <0, 3, 0>, 1 pigment { Green }rotate <0,0,45>}

Page 56: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

移動、拡大・縮小、回転の順番移動、拡大・縮小、回転の順番

回転、拡大縮小は原点を中心に行われる 回転、拡大縮小を行った後に移動を行う 回転、拡大縮小は原点を中心に行われる 回転、拡大縮小を行った後に移動を行う

// 03‐sphere03.povsphere { <0, 0, 0>, 0.5pigment { Blue }   }sphere { <6, 0, 0>, 0.5pigment { Red }   }        sphere { <0, 0, 0>, 1pigment { Green }    scale  <1.5, 1.5, 1.5> translate <3,0,0> }

// 03‐sphere03.povsphere { <0, 0, 0>, 0.5pigment { Blue }   }sphere { <6, 0, 0>, 0.5pigment { Red }   }        sphere { <0, 0, 0>, 1pigment { Green }    scale  <1.5, 1.5, 1.5> translate <3,0,0> }

// 03‐sphere04.povsphere { <0, 0, 0>, 0.5pigment { Blue }   }sphere { <6, 0, 0>, 0.5pigment { Red }   }         sphere { <0, 0, 0>, 1pigment { Green }   translate <3,0,0> scale  <1.5, 1.5, 1.5>}

// 03‐sphere04.povsphere { <0, 0, 0>, 0.5pigment { Blue }   }sphere { <6, 0, 0>, 0.5pigment { Red }   }         sphere { <0, 0, 0>, 1pigment { Green }   translate <3,0,0> scale  <1.5, 1.5, 1.5>}

緑球の中心のX座標は 3×1.5=4.5緑球の中心のX座標は 3×1.5=4.5

緑球の中心のX座標は 3.0緑球の中心のX座標は 3.0

Page 57: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

練習課題 ③練習課題 ③

球 立方体 三角錐 円錐

球 立方体 三角錐 円錐

1. 様々な物体を配置してみよう(最低3個の物体)2. 空または地面を追加してみよう3. 各物体のテクスチャを変えてみよう

1. 様々な物体を配置してみよう(最低3個の物体)2. 空または地面を追加してみよう3. 各物体のテクスチャを変えてみよう

練習課題②を拡張、または、03-assignment01.pov を参考に・・・練習課題②を拡張、または、03-assignment01.pov を参考に・・・

#include "colors.inc"#include "shapes.inc"#include "skies.inc“

#include "textures.inc"#include “Woods.inc"#include "stones.inc"                                        #include "glass.inc"#include "metals.inc "

Page 58: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

Page 59: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

光源の種類光源の種類

点光源: 全方向に放射 スポットライト: 円錐形に収束した光が放射 円柱光源: 円柱形に収束した光が放射 面光源: 長方形の領域に点光源が複数あり放射

点光源: 全方向に放射 スポットライト: 円錐形に収束した光が放射 円柱光源: 円柱形に収束した光が放射 面光源: 長方形の領域に点光源が複数あり放射

light_source {<光源の座標>color 光源の色と明るさ光源の種類属性

}

light_source {<光源の座標>color 光源の色と明るさ光源の種類属性

}

Page 60: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

点光源点光源//  04‐light01.povcamera{ location <0.0, ‐20.0, 0.0> look_at <0.0, 0.0, 0.0>} light_source { <0.0,0.0,‐10.0> color rgb <1.0, 1.0, 1.0>} sphere { <0.0, 0.0 ,0.0>, 3.0  pigment { rgb <1.0, 0.0, 0.0> }}       plane {<0.0,0.0,1.0>, 10pigment {  rgb <1.0, 1.0, 1.0> }}

//  04‐light01.povcamera{ location <0.0, ‐20.0, 0.0> look_at <0.0, 0.0, 0.0>} light_source { <0.0,0.0,‐10.0> color rgb <1.0, 1.0, 1.0>} sphere { <0.0, 0.0 ,0.0>, 3.0  pigment { rgb <1.0, 0.0, 0.0> }}       plane {<0.0,0.0,1.0>, 10pigment {  rgb <1.0, 1.0, 1.0> }}

点光源:全方向に照射点光源:全方向に照射

Page 61: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

スポットライトスポットライト//  04‐light02.povcamera{ location <0.0, ‐20.0, 0.0> look_at <0.0, 0.0, 0.0>} light_source { <0.0,‐20.0,‐20.0> color rgb <1.0, 1.0, 1.0>spotlightpoint_at<0.0, 0.0, 0.0>radius 3falloff 15} sphere { <0.0, 0.0 ,0.0>, 3.0  pigment { rgb <1.0, 0.0, 0.0> }} 

//  04‐light02.povcamera{ location <0.0, ‐20.0, 0.0> look_at <0.0, 0.0, 0.0>} light_source { <0.0,‐20.0,‐20.0> color rgb <1.0, 1.0, 1.0>spotlightpoint_at<0.0, 0.0, 0.0>radius 3falloff 15} sphere { <0.0, 0.0 ,0.0>, 3.0  pigment { rgb <1.0, 0.0, 0.0> }} 

Radius Radius

FalloffFalloff

point_at

※中心線からの角度の数値内側:光減衰なし外側:光減衰する範囲

※中心線からの角度の数値内側:光減衰なし外側:光減衰する範囲

Page 62: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

スポットライト (光減衰範囲の比較)スポットライト (光減衰範囲の比較)//  04‐light02.povcamera{ location <0.0, ‐20.0, 0.0> look_at <0.0, 0.0, 0.0>} light_source { <0.0,‐20.0,‐20.0> color rgb <1.0, 1.0, 1.0>spotlightpoint_at<0.0, 0.0, 0.0>radius 3falloff 15} sphere { <0.0, 0.0 ,0.0>, 3.0  pigment { rgb <1.0, 0.0, 0.0> }} 

//  04‐light02.povcamera{ location <0.0, ‐20.0, 0.0> look_at <0.0, 0.0, 0.0>} light_source { <0.0,‐20.0,‐20.0> color rgb <1.0, 1.0, 1.0>spotlightpoint_at<0.0, 0.0, 0.0>radius 3falloff 15} sphere { <0.0, 0.0 ,0.0>, 3.0  pigment { rgb <1.0, 0.0, 0.0> }} 

Falloff 15Falloff 15 Falloff 30Falloff 30

Page 63: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

円柱光源円柱光源//  04‐light03.povcamera{ location <0.0, ‐20.0, 0.0> look_at <0.0, 0.0, 0.0>} light_source { <0.0,‐20.0,‐20.0> color rgb <1.0, 1.0, 1.0>cylinderpoint_at<0.0, 0.0, 0.0>radius 0.50falloff 1.00} sphere { <0.0, 0.0 ,0.0>, 3.0  pigment { rgb <1.0, 0.0, 0.0> }} 

//  04‐light03.povcamera{ location <0.0, ‐20.0, 0.0> look_at <0.0, 0.0, 0.0>} light_source { <0.0,‐20.0,‐20.0> color rgb <1.0, 1.0, 1.0>cylinderpoint_at<0.0, 0.0, 0.0>radius 0.50falloff 1.00} sphere { <0.0, 0.0 ,0.0>, 3.0  pigment { rgb <1.0, 0.0, 0.0> }} 

光の束が円錐形ではなく円柱形で制限 スポットライトは光源から遠ざかると光の半径が

大きくなるが、円柱光源は半径がほぼ一定 レーザー光線のような効果!

光の束が円錐形ではなく円柱形で制限 スポットライトは光源から遠ざかると光の半径が

大きくなるが、円柱光源は半径がほぼ一定 レーザー光線のような効果!

Page 64: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

面光源面光源//  04‐light04.povcamera{ location <0.0, ‐20.0, 0.0> look_at <0.0, 0.0, 0.0>} light_source { <0.0,‐20.0,‐20.0> color rgb <1.0, 1.0, 1.0>area_light<1,0,0>, <0,1,0>30,30} sphere { <0.0, 0.0 ,0.0>, 3.0  pigment { rgb <1.0, 0.0, 0.0> }} 

//  04‐light04.povcamera{ location <0.0, ‐20.0, 0.0> look_at <0.0, 0.0, 0.0>} light_source { <0.0,‐20.0,‐20.0> color rgb <1.0, 1.0, 1.0>area_light<1,0,0>, <0,1,0>30,30} sphere { <0.0, 0.0 ,0.0>, 3.0  pigment { rgb <1.0, 0.0, 0.0> }} 

X軸に沿って1ユニット Y軸に沿って1ユニット 30x30個のライト

影がソフトになる レンダリングに時間がかかる

X軸に沿って1ユニット Y軸に沿って1ユニット 30x30個のライト

影がソフトになる レンダリングに時間がかかる

Page 65: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

光源の位置の表示光源の位置の表示//  04‐light05.povcamera{ location <0.0, ‐20.0, 0.0> look_at <0.0, 0.0, 0.0>} light_source { <0.0,‐5.0,‐5.0> color rgb <1.0, 1.0, 1.0>     looks_like {sphere{ <0,0,0>, 0.5pigment { rgb <1.0, 1.0, 1.0> }finish {ambient 1}

}}   }sphere { <0.0, 0.0 ,0.0>, 3.0  pigment { rgb <1.0, 0.0, 0.0> }} 

//  04‐light05.povcamera{ location <0.0, ‐20.0, 0.0> look_at <0.0, 0.0, 0.0>} light_source { <0.0,‐5.0,‐5.0> color rgb <1.0, 1.0, 1.0>     looks_like {sphere{ <0,0,0>, 0.5pigment { rgb <1.0, 1.0, 1.0> }finish {ambient 1}

}}   }sphere { <0.0, 0.0 ,0.0>, 3.0  pigment { rgb <1.0, 0.0, 0.0> }} 

Looks_likeで光源の位置を表示できる 光源を見せかけ(Looks_like)の形状で表示 Looks_likeで光源の位置を表示できる 光源を見せかけ(Looks_like)の形状で表示

Page 66: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

CSGモデルCSGモデル

Constructive Solid Geometry (CSG) プリミティブ形状を組み合わせより複雑な形状を作る union, intersection, difference, mergeがある

Constructive Solid Geometry (CSG) プリミティブ形状を組み合わせより複雑な形状を作る union, intersection, difference, mergeがある

++

三角錐(コーン)三角錐(コーン) 球(スフェア)球(スフェア)

Page 67: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

CSGモデルの演算CSGモデルの演算

Union和

Union和

Intersection積

Intersection積

Difference差

Difference差

Merge併合Merge併合

Page 68: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

CSGモデル(和と併合の違い)CSGモデル(和と併合の違い)

Union和

Union和

Merge併合Merge併合

透明な物体の場合、重なっている部分の見え方が異なる 透明な物体の場合、重なっている部分の見え方が異なる

Page 69: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

CSGモデルCSGモデル// 04‐csg‐sample.pov・・・省略union {

cone{<‐1.5, ‐1.5,  ‐1.5>, 1.5  <1.5, 1.5, 1.5>, 0.1material { M_Green_Glass }

}sphere{ 

<1.0, 1.0, 1.0> 1.5material { M_Green_Glass }

}} 

// 04‐csg‐sample.pov・・・省略union {

cone{<‐1.5, ‐1.5,  ‐1.5>, 1.5  <1.5, 1.5, 1.5>, 0.1material { M_Green_Glass }

}sphere{ 

<1.0, 1.0, 1.0> 1.5material { M_Green_Glass }

}} 

Page 70: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

物体に名前をつける #declare物体に名前をつける #declare// 04‐object‐01.pov#include "colors.inc"#include "skies.inc"sky_sphere{S_Cloud2 }     plane {  y, ‐1 pigment { color rgb <0.8,0.6,0.4> }}  camera {location  <0.0, 1.0, ‐5.0>look_at <0.0, 0.5,  0.0>}light_source {<150, 150, ‐150>color rgb 1.0}

// 04‐object‐01.pov#include "colors.inc"#include "skies.inc"sky_sphere{S_Cloud2 }     plane {  y, ‐1 pigment { color rgb <0.8,0.6,0.4> }}  camera {location  <0.0, 1.0, ‐5.0>look_at <0.0, 0.5,  0.0>}light_source {<150, 150, ‐150>color rgb 1.0}

#declare MyObj =union {object {sphere { <0, 0, 0>, 0.5 }pigment { Blue }translate <0, 1, 0>}object {cone { <0, ‐0.5, 0>, 0.5, <0, 1, 0>, 0 }pigment { Green }}} 

object { MyObj }  object { MyObj translate <‐1.2, 0, 0> }object { MyObj translate < 1.2, 0, 0> }

#declare MyObj =union {object {sphere { <0, 0, 0>, 0.5 }pigment { Blue }translate <0, 1, 0>}object {cone { <0, ‐0.5, 0>, 0.5, <0, 1, 0>, 0 }pigment { Green }}} 

object { MyObj }  object { MyObj translate <‐1.2, 0, 0> }object { MyObj translate < 1.2, 0, 0> }

#declareを使って名前を付ける

union等を使いオブジェクトを

組み合わせたものに名前をつけておくと便利!!

Page 71: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

POV-Rayに関する情報POV-Rayに関する情報

http://www.povray.org/download/ http://www.povray.org/download/

様々なOSで利用が可能 Windows Mac Linux

様々なOSで利用が可能 Windows Mac Linux

家のコンピューターにインストールしてみよう 家のコンピューターにインストールしてみよう

Page 72: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

課題④ 自由なテーマで作品を制作課題④ 自由なテーマで作品を制作

作品制作 複数の物体を入れる テクスチャを物体につける 拡大縮小、回転、移動などを利用する CSGモデルを利用する

これまでに使った練習課題を拡張・変更しても良い 紙に各物体、照明、カメラの座標を書くとわかりやすい 作品発表(数分の簡単な説明。希望者のみ)

作品制作 複数の物体を入れる テクスチャを物体につける 拡大縮小、回転、移動などを利用する CSGモデルを利用する

これまでに使った練習課題を拡張・変更しても良い 紙に各物体、照明、カメラの座標を書くとわかりやすい 作品発表(数分の簡単な説明。希望者のみ)

練習課題③を拡張、または、04-assignment01.pov を参考に・・・練習課題③を拡張、または、04-assignment01.pov を参考に・・・

Page 73: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

Page 74: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

カメラの位置と方向カメラの位置と方向

camera{ location <0.0, 4.0, 0.0> look_at <0.0, 0.0, 0.0>} 

camera{ location <0.0, 4.0, 0.0> look_at <0.0, 0.0, 0.0>} 

camera{ location <0.0, 1.1, ‐2.1> look_at <0.0, 0.0, 0.0>} 

camera{ location <0.0, 1.1, ‐2.1> look_at <0.0, 0.0, 0.0>} 

camera{ location <0.0, 0.0, ‐3.0>look_at <0.0, 0.0, 0.0>} 

camera{ location <0.0, 0.0, ‐3.0>look_at <0.0, 0.0, 0.0>} 

※ 同じ物体でも観察する位置によって印象が大きく変化する!※ 同じ物体でも観察する位置によって印象が大きく変化する!

Page 75: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

環境光(ambient)環境光(ambient)// 05‐light‐ambient.pov#include "colors.inc"#include "skies.inc" sky_sphere {S_Cloud2}camera{ location <0.0, 0.0, ‐12.0> look_at <0.0, 0.0, 0.0>} light_source { <0.0,3.0,‐3.0> color rgb <1.0, 1.0, 1.0>} plane {  y, ‐1.0pigment {checker Green, White}    }sphere {<‐6,0,0>, 1pigment { Blue }finish {    ambient 1.0 }} 

// 05‐light‐ambient.pov#include "colors.inc"#include "skies.inc" sky_sphere {S_Cloud2}camera{ location <0.0, 0.0, ‐12.0> look_at <0.0, 0.0, 0.0>} light_source { <0.0,3.0,‐3.0> color rgb <1.0, 1.0, 1.0>} plane {  y, ‐1.0pigment {checker Green, White}    }sphere {<‐6,0,0>, 1pigment { Blue }finish {    ambient 1.0 }} 

光源の光が物体などによって散乱された間接光

光源の光が物体などによって散乱された間接光

1.0     0.8     0.6     0.4     0.2

フィニッシュとは仕上げのこと 物体表面の光の反射を指定して物体の質感を表現

Page 76: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

拡散光(diffuse)拡散光(diffuse)// 05‐light‐diffuse.pov#include "colors.inc"#include "skies.inc" sky_sphere {S_Cloud2}camera{ location <0.0, 0.0, ‐12.0> look_at <0.0, 0.0, 0.0>} light_source { <0.0,3.0,‐3.0> color rgb <1.0, 1.0, 1.0>} plane {  y, ‐1.0pigment {checker Green, White}    }sphere {<‐6,0,0>, 1pigment { Blue }finish {    diffuse 1.0 }} 

// 05‐light‐diffuse.pov#include "colors.inc"#include "skies.inc" sky_sphere {S_Cloud2}camera{ location <0.0, 0.0, ‐12.0> look_at <0.0, 0.0, 0.0>} light_source { <0.0,3.0,‐3.0> color rgb <1.0, 1.0, 1.0>} plane {  y, ‐1.0pigment {checker Green, White}    }sphere {<‐6,0,0>, 1pigment { Blue }finish {    diffuse 1.0 }} 

表面の非常に細かい凹凸によって光が散乱される反射

表面の非常に細かい凹凸によって光が散乱される反射

1.0     0.8     0.6     0.4     0.2

Page 77: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

鏡面反射光(specular)鏡面反射光(specular)// 05‐light‐specular.pov#include "colors.inc"#include "skies.inc" sky_sphere {S_Cloud2}camera{ location <0.0, 0.0, ‐12.0> look_at <0.0, 0.0, 0.0>} light_source { <0.0,3.0,‐3.0> color rgb <1.0, 1.0, 1.0>} plane {  y, ‐1.0pigment {checker Green, White}    }sphere {<‐6,0,0>, 1pigment { Blue }finish {    specular 1.0 }} 

// 05‐light‐specular.pov#include "colors.inc"#include "skies.inc" sky_sphere {S_Cloud2}camera{ location <0.0, 0.0, ‐12.0> look_at <0.0, 0.0, 0.0>} light_source { <0.0,3.0,‐3.0> color rgb <1.0, 1.0, 1.0>} plane {  y, ‐1.0pigment {checker Green, White}    }sphere {<‐6,0,0>, 1pigment { Blue }finish {    specular 1.0 }} 

光の入射角と反射角が等しい反射 非常に滑らかな表面で起きる 鏡面反射は 視点に依存

光の入射角と反射角が等しい反射 非常に滑らかな表面で起きる 鏡面反射は 視点に依存

1.0     0.8     0.6     0.4     0.2

Page 78: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

環境光+拡散光+反射光環境光+拡散光+反射光

sphere {<0,0,0>, 1pigment { BrightGold }finish {ambient 0.1diffuse 0.1specular 1.0roughness 0.001reflection {0.75

}}}

sphere {<0,0,0>, 1pigment { BrightGold }finish {ambient 0.1diffuse 0.1specular 1.0roughness 0.001reflection {0.75

}}}

Page 79: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

レインボウ(虹)レインボウ(虹)// 05‐sphere‐rainbow.povrainbow {                      angle 40         width 5        distance 1500direction <0.0,‐0.4,1.0>    jitter 0.01arc_angle 180    falloff_angle 60 color_map {[0.000 color rgbf <1.0, 0.5, 1.0, 1.0> ][0.100 color rgbf <1.0, 0.5, 1.0, 0.8> ][0.214 color rgbf <0.5, 0.5, 1.0, 0.8> ][0.328 color rgbf <0.2, 0.2, 1.0, 0.8> ][0.442 color rgbf <0.2, 1.0, 1.0, 0.8> ][0.556 color rgbf <0.2, 1.0, 0.2, 0.8> ][0.670 color rgbf <1.0, 1.0, 0.2, 0.8> ][0.784 color rgbf <1.0, 0.5, 0.2, 0.8> ][0.900 color rgbf <1.0, 0.2, 0.2, 0.8> ]}

}

// 05‐sphere‐rainbow.povrainbow {                      angle 40         width 5        distance 1500direction <0.0,‐0.4,1.0>    jitter 0.01arc_angle 180    falloff_angle 60 color_map {[0.000 color rgbf <1.0, 0.5, 1.0, 1.0> ][0.100 color rgbf <1.0, 0.5, 1.0, 0.8> ][0.214 color rgbf <0.5, 0.5, 1.0, 0.8> ][0.328 color rgbf <0.2, 0.2, 1.0, 0.8> ][0.442 color rgbf <0.2, 1.0, 1.0, 0.8> ][0.556 color rgbf <0.2, 1.0, 0.2, 0.8> ][0.670 color rgbf <1.0, 1.0, 0.2, 0.8> ][0.784 color rgbf <1.0, 0.5, 0.2, 0.8> ][0.900 color rgbf <1.0, 0.2, 0.2, 0.8> ]}

}

Page 80: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

Fog(霧)Fog(霧)

// 05‐sphere‐fog01.povfog {fog_type 1            distance 10color Gray              }

// 05‐sphere‐fog01.povfog {fog_type 1            distance 10color Gray              }

// 05‐sphere‐fog02.povfog {fog_type 1            distance 20color Gray              }

// 05‐sphere‐fog02.povfog {fog_type 1            distance 20color Gray              }

// 05‐sphere‐fog03.povfog {fog_type 1            distance 30color Gray              }

// 05‐sphere‐fog03.povfog {fog_type 1            distance 30color Gray              }

※ 霧で奥行き感をだすことができる!!※ Colorの指定で様々な色の霧になる※ 霧で奥行き感をだすことができる!!※ Colorの指定で様々な色の霧になる

Page 81: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

フォントフォント

text{ttf “Arial.ttf”, //     フォントファイル名“ABC”,             // 文字列5,                  // 文字の厚さ0                 // 文字間隔

}

text{ttf “Arial.ttf”, //     フォントファイル名“ABC”,             // 文字列5,                  // 文字の厚さ0                 // 文字間隔

}

TrueTypeフォント TrueTypeフォント

アウトラインフォントシステムであるため、拡大・縮小してもジャギーが生じず、解像度によらない精細な出力

アウトラインフォントシステムであるため、拡大・縮小してもジャギーが生じず、解像度によらない精細な出力

Page 82: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

フォントフォント// 05‐font01.pov#include "colors.inc"#include "shapes.inc"camera{ location <0.0, 1.0, ‐3.0> look_at <0.0, 0.0, 0.0>} light_source { <5.0,5.0,‐5.0> color rgb <1.0, 1.0, 1.0>} background{color White}

text{ttf "Arial.ttf",         "ABC",       5,         0        pigment{color rgb<0.0,1.0,0.0>}}

// 05‐font01.pov#include "colors.inc"#include "shapes.inc"camera{ location <0.0, 1.0, ‐3.0> look_at <0.0, 0.0, 0.0>} light_source { <5.0,5.0,‐5.0> color rgb <1.0, 1.0, 1.0>} background{color White}

text{ttf "Arial.ttf",         "ABC",       5,         0        pigment{color rgb<0.0,1.0,0.0>}}

Page 83: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

日本語フォント日本語フォント

日本語フォントを利用する場合 日本語フォントを利用する場合

global_settings { charset utf8 }global_settings { charset utf8 }

POV-Rayのエディタは UTF-8 不可 外部のエディタで編集する必要あり POV-Rayのエディタは UTF-8 不可 外部のエディタで編集する必要あり

※日本語フォントを利用することも可能ですが、処理が複雑なので、本授業では扱いません

※日本語フォントを利用することも可能ですが、処理が複雑なので、本授業では扱いません

Page 84: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

課題 ⑤課題 ⑤

フォントを利用した物体を作成しましょう(1個以上) 様々形状の物体を配置しましょう(3個以上) 物体に照明を3方向から当てましょう(照明3個以上) カメラ位置を変え物体を様々な方向から見てみましょう

フォントを利用した物体を作成しましょう(1個以上) 様々形状の物体を配置しましょう(3個以上) 物体に照明を3方向から当てましょう(照明3個以上) カメラ位置を変え物体を様々な方向から見てみましょう

新規作成、あるいは、これまでの例を拡張、あるいは、05-assignment01.pov を参考に・・・新規作成、あるいは、これまでの例を拡張、あるいは、05-assignment01.pov を参考に・・・

Page 85: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

Page 86: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

ハイトフィールドと画像ハイトフィールドと画像// 06‐height‐field01.pov#include "colors.inc"#include "skies.inc" camera{ location <0.0, 7.0, ‐2.0> look_at <0.0, 0.0, 0.0>} light_source { <5.0,5.0,‐5.0> color rgb <1.0, 1.0, 1.0>}      sky_sphere {S_Cloud2}height_field {sys "tori‐bmp‐bw‐rev.bmp"smoothpigment {Green}translate <‐0.5, ‐1.0, ‐0.5>scale <6, 0.2, 6>}

// 06‐height‐field01.pov#include "colors.inc"#include "skies.inc" camera{ location <0.0, 7.0, ‐2.0> look_at <0.0, 0.0, 0.0>} light_source { <5.0,5.0,‐5.0> color rgb <1.0, 1.0, 1.0>}      sky_sphere {S_Cloud2}height_field {sys "tori‐bmp‐bw‐rev.bmp"smoothpigment {Green}translate <‐0.5, ‐1.0, ‐0.5>scale <6, 0.2, 6>}

左側の白黒の二値画像を利用して右側の画像をつくることができる。

• 白い部分が高くなる。• 黒い部分が低くなる。

Page 87: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

ハイトフィールドと画像 ①ハイトフィールドと画像 ①// 06‐height‐field02bmp.pov#include "colors.inc"#include "skies.inc" camera{ location <0.0, 0.0, ‐5.0> look_at <0.0, 0.0, 0.0>} light_source { <3.0,3.0,3.0> color rgb <1.0, 1.0, 1.0>} plane {<0,0,1>, 10pigment { wrinklescolor_map {[ 0 0.1*White][ 1 White ] 

}  } }

// 06‐height‐field02bmp.pov#include "colors.inc"#include "skies.inc" camera{ location <0.0, 0.0, ‐5.0> look_at <0.0, 0.0, 0.0>} light_source { <3.0,3.0,3.0> color rgb <1.0, 1.0, 1.0>} plane {<0,0,1>, 10pigment { wrinklescolor_map {[ 0 0.1*White][ 1 White ] 

}  } }

← これを実行すると上のような「しわ」の模様の2次元画像ができあがる。

※wrinkle: リンクル、布などの「しわ」の意味

Page 88: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

ハイトフィールドと画像 ②ハイトフィールドと画像 ②// 06‐height‐field02.pov#include "colors.inc"#include "skies.inc" camera{ location <0.0, 1.0, 3.0> look_at <0.0, 0.0, 0.0>} light_source { <5.0,5.0,‐5.0> color rgb <1.0, 1.0, 1.0>}      sky_sphere {S_Cloud2}height_field {sys "06‐height‐field02bmp.bmp"     smoothpigment {Gold}translate <‐0.5, ‐1.0, ‐0.5>scale <50, 10, 50>}

// 06‐height‐field02.pov#include "colors.inc"#include "skies.inc" camera{ location <0.0, 1.0, 3.0> look_at <0.0, 0.0, 0.0>} light_source { <5.0,5.0,‐5.0> color rgb <1.0, 1.0, 1.0>}      sky_sphere {S_Cloud2}height_field {sys "06‐height‐field02bmp.bmp"     smoothpigment {Gold}translate <‐0.5, ‐1.0, ‐0.5>scale <50, 10, 50>}

山脈?

※ JPGEなどのファイルも指定できる例: jpeg “sample.jpg" 

Page 89: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

ハイトフィールドと画像ハイトフィールドと画像// 06‐height‐field03.pov#include "colors.inc"#include "skies.inc" camera{ location <0.0, 7.0, ‐0.0> look_at <0.0, 0.0, 0.0>} light_source { <5.0,5.0,‐5.0> color rgb <1.0, 1.0, 1.0>}      height_field {sys "neko.bmp"smoothpigment {White}translate <‐0.5, ‐1.0, ‐0.5>scale <10, 0.3, 10>}

// 06‐height‐field03.pov#include "colors.inc"#include "skies.inc" camera{ location <0.0, 7.0, ‐0.0> look_at <0.0, 0.0, 0.0>} light_source { <5.0,5.0,‐5.0> color rgb <1.0, 1.0, 1.0>}      height_field {sys "neko.bmp"smoothpigment {White}translate <‐0.5, ‐1.0, ‐0.5>scale <10, 0.3, 10>}

Page 90: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

ポリゴンモデルポリゴンモデル ポリゴン(Polygon;多角形)で形状を近似する ポリゴンが集まって、多面体(Polyhedron)となる ポリゴン(Polygon;多角形)で形状を近似する ポリゴンが集まって、多面体(Polyhedron)となる

Page 91: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

ポリゴンデータの表現ポリゴンデータの表現

シンプルな形状の例(ピラミッド形状)

シンプルな形状の例(ピラミッド形状)

4つの三角形と1つの四角形からピラミッドをつくることができる4つの三角形と1つの四角形からピラミッドをつくることができる

Page 92: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

ポリゴンデータの表現ポリゴンデータの表現頂点番号 座標(x, y, z)

01234

( 0.0, +1.0, 0.0 ) (-1.0, 0.0, -1.0 ) (-1.0, 0.0, +1.0 )(+1.0, 0.0, +1.0 ) (+1.0, 0.0, -1.0)

面番号 頂点の番号 面の形01234

0 1 20 2 30 3 40 4 14 3 2 1

三角形三角形三角形三角形四角形

yy

xx

zz

11

22 33

44

00

(0,1,0)(0,1,0)

(-1,0,1)(-1,0,1)(1,0,1)(1,0,1)

(1,0,-1)(-1,0,-1)(-1,0,-1)

Page 93: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

3D ポリゴンデータ3D ポリゴンデータ// 06‐polygon01.pov#include "colors.inc"  #include "skies.inc"  camera {  location <0, 0, 10>  look_at <0.4, 0.5, ‐3.0> }light_source {  <5, 5, 5> color rgb <1.0, 1.0, 1.0>  }plane { <0, 1, 0>, ‐3  pigment { color rgb <0.8, 0.9, 0.8> } }sky_sphere {  S_Cloud2}

triangle { <‐0.5, ‐0.5, ‐0.5>, < 2.0,  2.0,  2.0> ,< 2.0, ‐2.0, ‐2.0> pigment { color rgb <0, 1, 0.3> }finish { ambient 0.5 diffuse 0.8 specular 0.8 roughness 0.01 }}

// 06‐polygon01.pov#include "colors.inc"  #include "skies.inc"  camera {  location <0, 0, 10>  look_at <0.4, 0.5, ‐3.0> }light_source {  <5, 5, 5> color rgb <1.0, 1.0, 1.0>  }plane { <0, 1, 0>, ‐3  pigment { color rgb <0.8, 0.9, 0.8> } }sky_sphere {  S_Cloud2}

triangle { <‐0.5, ‐0.5, ‐0.5>, < 2.0,  2.0,  2.0> ,< 2.0, ‐2.0, ‐2.0> pigment { color rgb <0, 1, 0.3> }finish { ambient 0.5 diffuse 0.8 specular 0.8 roughness 0.01 }}

Page 94: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

3D ポリゴンデータ3D ポリゴンデータ

点:453 面:948 ファイル:06_bunny_s.pov

点:453 面:948 ファイル:06_bunny_s.pov

// 06‐polygon01.pov・・・

triangle { <0.022800861312161, 1.3235245682703, 0.69665948084376>, <‐0.19418416608243, 1.3814593542487, 0.54193595981424> ,<‐0.23070168614644, 1.1104768564277, 0.95946447713384>  pigment { color rgb <0, 0, 1> } finish { ambient 0.2 diffuse 0.4 specular 0.4 roughness 0.05 }}

triangle { <‐1.9246127175519, 3.2975042103089, ‐1.7208955352425>, <‐2.2393816256866, 3.261592431099, ‐1.6580715552272> ,<‐1.9393668340706, 3.1576213402059, ‐1.2074868941529>  pigment { color rgb <0, 0, 1> }

finish { ambient 0.2 diffuse 0.4 specular 0.4 roughness 0.05 }}

triangle { <‐0.76037879589012, ‐2.1330490814857, ‐1.1280050406487>, <‐0.7499513997581, ‐2.5080892046076, ‐1.1929491136535> ,<‐1.1208378713087, ‐2.5136706739064, ‐0.92343770076402> pigment { color rgb <0, 0, 1> }

finish { ambient 0.2 diffuse 0.4 specular 0.4 roughness 0.05 }}

・・・

// 06‐polygon01.pov・・・

triangle { <0.022800861312161, 1.3235245682703, 0.69665948084376>, <‐0.19418416608243, 1.3814593542487, 0.54193595981424> ,<‐0.23070168614644, 1.1104768564277, 0.95946447713384>  pigment { color rgb <0, 0, 1> } finish { ambient 0.2 diffuse 0.4 specular 0.4 roughness 0.05 }}

triangle { <‐1.9246127175519, 3.2975042103089, ‐1.7208955352425>, <‐2.2393816256866, 3.261592431099, ‐1.6580715552272> ,<‐1.9393668340706, 3.1576213402059, ‐1.2074868941529>  pigment { color rgb <0, 0, 1> }

finish { ambient 0.2 diffuse 0.4 specular 0.4 roughness 0.05 }}

triangle { <‐0.76037879589012, ‐2.1330490814857, ‐1.1280050406487>, <‐0.7499513997581, ‐2.5080892046076, ‐1.1929491136535> ,<‐1.1208378713087, ‐2.5136706739064, ‐0.92343770076402> pigment { color rgb <0, 0, 1> }

finish { ambient 0.2 diffuse 0.4 specular 0.4 roughness 0.05 }}

・・・ 948個の面のデータが続く 948個の面のデータが続く

Page 95: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

3D ポリゴンデータ3D ポリゴンデータ

点:453 面:948 ファイル:06_bunny_s.pov

点:453 面:948 ファイル:06_bunny_s.pov

点:8171 面:16301 ファイル:06_bunny_m.pov

点:8171 面:16301 ファイル:06_bunny_m.pov

点:35947 面:69451 ファイル:06_bunny_l.pov

点:35947 面:69451 ファイル:06_bunny_l.pov

Page 96: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

3D データと3Dプリンター出力3D データと3Dプリンター出力

Page 97: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

3D ポリゴンデータ3D ポリゴンデータ

点:100250 面:202520 ファイル:06_dragon.pov

点:100250 面:202520 ファイル:06_dragon.pov

面の数が20万件以上ある! 処理に若干時間がかかる。 50MB以上のファイルサイズ 面の数が20万件以上ある! 処理に若干時間がかかる。 50MB以上のファイルサイズ

Page 98: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

ボリューメトリックモデルボリューメトリックモデル

2次元画像データ2次元画像データ

yy

xx

ピクセル(画素)ピクセル(画素) ボクセルボクセルyy

xxzz

3次元ボリュームデータ3次元ボリュームデータ

Page 99: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

ボリュームデータの例1ボリュームデータの例1

ボリュームデータ256×256×256

ボリュームデータ256×256×256

ボリュームデータ一部分をカット

ボリュームデータ一部分をカット

ボリュームデータ一部分をカット

ボリュームデータ一部分をカット

ボリュームビジュアライゼーション ボリュームビジュアライゼーションボクセルの集合によって作成されるボリュームデータの断面画像を表示することや、データ内部を透視する技術ボクセルの集合によって作成されるボリュームデータの断面画像を表示することや、データ内部を透視する技術

Page 100: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

ボリュームデータの例2ボリュームデータの例2

ボリュームデータ128×128×128

ボリュームデータ128×128×128

ボリュームデータ一部分をカット

ボリュームデータ一部分をカット

ボリュームデータ一部分をカット

ボリュームデータ一部分をカット

ポリゴンモデルやパラメトリック曲面モデルと異なり、物体内部にもデータを持っている

ポリゴンモデルやパラメトリック曲面モデルと異なり、物体内部にもデータを持っている

Page 101: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

32×32×3232×32×32 64×64×6464×64×64 128×128×128128×128×128 256×256×256256×256×256

ボリュームデータの解像度ボリュームデータの解像度 異なる解像度のボリュームデータを比較 異なる解像度のボリュームデータを比較

より多くのボクセルを使用した物体が正確な形状になる より多くのボクセルを使用した物体が正確な形状になる

ボクセルが増えるとデータ容量が爆発的に大きくなる ボクセルが増えるとデータ容量が爆発的に大きくなる

257 Kbytes257 Kbytes 2,049 Kbytes2,049 Kbytes 16,385 Kbytes16,385 Kbytes 131,073 Kbytes131,073 Kbytes

130メガバイト!130メガバイト!

Page 102: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

3D ボリュームデータ3D ボリュームデータ

Page 103: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

3D ボリュームデータとポリゴン3D ボリュームデータとポリゴン

大理石のボリュームデータと3次元ポリゴンデータを組み合わせた複雑な例

Density file (ボリューム密度) Mesh file(ポリゴン形状)

大理石のボリュームデータと3次元ポリゴンデータを組み合わせた複雑な例

Density file (ボリューム密度) Mesh file(ポリゴン形状)

Page 104: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

複雑な応用例:3D ボリュームデータとポリゴン複雑な応用例:3D ボリュームデータとポリゴン// 06‐volume‐01.pov 

global_settings { assumed_gamma 2.2 } 

#include "colors.inc"  #include "skies.inc"

#declare T1= texture{pigment{density_file df3 "06‐volume‐01.df3" interpolate 1color_map{[0.0 Red][1.0 White]}}}camera {location <+0.0, 0.0, ‐1.50>}sky_sphere {S_Cloud2}

// 06‐volume‐01.pov 

global_settings { assumed_gamma 2.2 } 

#include "colors.inc"  #include "skies.inc"

#declare T1= texture{pigment{density_file df3 "06‐volume‐01.df3" interpolate 1color_map{[0.0 Red][1.0 White]}}}camera {location <+0.0, 0.0, ‐1.50>}sky_sphere {S_Cloud2}

plane {y, ‐1.01pigment {checker White, Grey}}

light_source { <300.0, 500.0, ‐500.0> color White} light_source { <‐50.0,  10.0, ‐500.0> color White} 

object {#include "06‐volume‐01‐mesh‐01.inc" 

//   #include "06‐volume‐01‐mesh‐02.inc" //   #include "06‐volume‐01‐mesh‐03.inc" scale 1.0000texture { T1 }translate <‐0.50, ‐0.50, ‐0.50>

rotate <360*clock,360*clock+90,360*clock>}

plane {y, ‐1.01pigment {checker White, Grey}}

light_source { <300.0, 500.0, ‐500.0> color White} light_source { <‐50.0,  10.0, ‐500.0> color White} 

object {#include "06‐volume‐01‐mesh‐01.inc" 

//   #include "06‐volume‐01‐mesh‐02.inc" //   #include "06‐volume‐01‐mesh‐03.inc" scale 1.0000texture { T1 }translate <‐0.50, ‐0.50, ‐0.50>

rotate <360*clock,360*clock+90,360*clock>}

Page 105: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

Page 106: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

アニメーションアニメーション

静止画を連続的に表示する → 動画パラパラ漫画、映画、テレビ など静止画を連続的に表示する → 動画パラパラ漫画、映画、テレビ など

The human eye needs a sequence of about 25 single slightly changing images per second to give us the illusion of a continuous motion.

Page 107: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

アニメーション(回転の例)アニメーション(回転の例)// 07‐animation01.pov#include "colors.inc"        #include "shapes.inc"    #include "stones.inc"background{color White}camera {location <0, 0, ‐5>look_at <0, 0, 0>}light_source {<5,5,‐10>color White}cylinder {<0, 2.0, 0>, <0,‐2.0, 0>, 0.8texture {T_Stone2}rotate <0,0,180*clock>}

// 07‐animation01.pov#include "colors.inc"        #include "shapes.inc"    #include "stones.inc"background{color White}camera {location <0, 0, ‐5>look_at <0, 0, 0>}light_source {<5,5,‐10>color White}cylinder {<0, 2.0, 0>, <0,‐2.0, 0>, 0.8texture {T_Stone2}rotate <0,0,180*clock>}

円柱を回転させる例 Z軸に対して180度回転円柱を回転させる例 Z軸に対して180度回転

Page 108: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

アニメーションアニメーション

Initial_Frame=0 Final_Frame=10Initial_Frame=0 Final_Frame=10

Render | Edit Setting/Render Render | Edit Setting/Render

※ 別の方法としては、animation ini fileを作る方法もある。

Page 109: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

アニメーション(回転の例)アニメーション(回転の例)cylinder {<0, 2.0, 0>, <0,‐2.0, 0>, 0.8texture {T_Stone2}rotate <0, 0, 180*clock>}

cylinder {<0, 2.0, 0>, <0,‐2.0, 0>, 0.8texture {T_Stone2}rotate <0, 0, 180*clock>}

Initial_Frame=0Final_Frame=10Initial_Frame=0Final_Frame=10

clockは0.00から1.00まで増加 11枚の画像が生成される clockは0.00から1.00まで増加 11枚の画像が生成される

Page 110: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

アニメーション(色変化の例)アニメーション(色変化の例)// 07‐animation02.pov#include "colors.inc"        #include "shapes.inc"    #include "stones.inc"background{color White}camera {location <0, 0, ‐5>look_at <0, 0, 0>}light_source {<5,5,‐10>color White}cylinder {<0, 1.0, 0>, <0,‐1.0, 0>, 0.8pigment {color rgb<0.0, 1.0, clock> }}

// 07‐animation02.pov#include "colors.inc"        #include "shapes.inc"    #include "stones.inc"background{color White}camera {location <0, 0, ‐5>look_at <0, 0, 0>}light_source {<5,5,‐10>color White}cylinder {<0, 1.0, 0>, <0,‐1.0, 0>, 0.8pigment {color rgb<0.0, 1.0, clock> }}

色を変化させる緑→水色色を変化させる緑→水色

Page 111: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

アニメーション(色変化の例)アニメーション(色変化の例)cylinder {<0, 1.0, 0>, <0,‐1.0, 0>, 0.8pigment {color rgb<0.0, 1.0, clock> }}

cylinder {<0, 1.0, 0>, <0,‐1.0, 0>, 0.8pigment {color rgb<0.0, 1.0, clock> }}

rgb<0.0, 1.0, 0.0>

rgb<0.0, 1.0, 1.0>

Page 112: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

アニメーション(視点回転の例)アニメーション(視点回転の例)

・・・camera {angle    35location <3.0 , 0.0 ,‐10.0>right    x*image_width/image_heightlook_at <0.0 , 0.0, 0.0>rotate   <0,‐360*(clock+0.10),0>      }・・・

・・・camera {angle    35location <3.0 , 0.0 ,‐10.0>right    x*image_width/image_heightlook_at <0.0 , 0.0, 0.0>rotate   <0,‐360*(clock+0.10),0>      }・・・

07‐animation03.pov

Page 113: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

07‐animation04.pov

アニメーションアニメーション

アニメーションGIF(animated gif)

じふ

http://gifmaker.me/

Page 114: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

アニメーションアニメーション

GIMP等の画像処理ソフトウェアでGIFアニメーション画像を作成することができる

GIMP等の画像処理ソフトウェアでGIFアニメーション画像を作成することができる

複数のレイヤーを作成 → アニメーション 複数のレイヤーを作成 → アニメーション

※ 興味のある方は、やり方を検索してみましょう。検索「GIMP アニメーション」

※ 興味のある方は、やり方を検索してみましょう。検索「GIMP アニメーション」

http://gifmaker.me/

Page 115: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

プログラミングプログラミング// 07‐while‐loop‐01.pov#include "colors.inc"camera {location  <0.0, 1.0, ‐5.0>look_at <0.0, 0.0,  0.0>}     light_source {<150, 150, ‐100>color rgb 1.0}#declare Value = ‐2;#while ( Value <= 2 )object {sphere { <0, 0, 0>, 0.5 }pigment { Blue }translate <Value, 0, 0>}#declare Value = Value + 1;#end

// 07‐while‐loop‐01.pov#include "colors.inc"camera {location  <0.0, 1.0, ‐5.0>look_at <0.0, 0.0,  0.0>}     light_source {<150, 150, ‐100>color rgb 1.0}#declare Value = ‐2;#while ( Value <= 2 )object {sphere { <0, 0, 0>, 0.5 }pigment { Blue }translate <Value, 0, 0>}#declare Value = Value + 1;#end

「#while (...)~#end」は、「(...)」内の条件である間は、「~」の部分の処理をする命令。

プログラミングで、大量の同じオブジェクトを簡単に作成!

1. #declareでValueの値を宣言する(Value = ‐2)2. #whileの行に条件を書く(Value <= 2)3. 必要な部分(translate)にValueを書く4. Valueの値を変更(Value = Value + 1)5. 条件に一致しなくなったら繰り返し処理終了(#end)

Page 116: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

課題⑦ アニメーション課題⑦ アニメーション

POV-Rayのアニメーション機能を使ってみましょう。 例題を参考にして、物体の回転・拡大縮小・移動などの

アニメーション画像を生成してみましょう。

POV-Rayのアニメーション機能を使ってみましょう。 例題を参考にして、物体の回転・拡大縮小・移動などの

アニメーション画像を生成してみましょう。

これまで作成した課題を拡張、または07-assingment01.povを参考にしてもよい

これまで作成した課題を拡張、または07-assingment01.povを参考にしてもよい

Page 117: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

Page 118: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

課題⑧ 自由なテーマで作品を制作課題⑧ 自由なテーマで作品を制作

作品制作 これまでに使った練習課題を拡張・変更しても良い 作品発表(数分の簡単な説明。希望者のみ)

作品制作 これまでに使った練習課題を拡張・変更しても良い 作品発表(数分の簡単な説明。希望者のみ)

Page 119: レイトレーシング入門 - compsci.world.coocan.jpcompsci.world.coocan.jp/OUJ/RT/rt2015a.pdf · レイトレーシング入門 放送大学面接授業 担当講師:鈴木一史(放送大学・教育支援センター・准教授)

作品のWEB掲載作品のWEB掲載

今回の面接授業で作成した作品をWEBに掲載しても良いという方は担当講師に画像ファイルを送付して下さい

次学期の面接授業等で作品を紹介します(ただし、すべての作品ではありません)

今回の面接授業で作成した作品をWEBに掲載しても良いという方は担当講師に画像ファイルを送付して下さい

次学期の面接授業等で作品を紹介します(ただし、すべての作品ではありません)

PNG または JPEG 形式の画像 画像サイズは 1024x768以下を目安に メール件名「面接授業POVRAY」 本名は載せないので、ペンネームを考えてください

PNG または JPEG 形式の画像 画像サイズは 1024x768以下を目安に メール件名「面接授業POVRAY」 本名は載せないので、ペンネームを考えてください

担当講師の電子メールアドレス: [email protected]