<< Lightflow質感設定その6 拡散量 戻る Lightflowでリングをつくる >>

Lightflowのカラーサンプル

POV-Rayではcolor.incというカラーサンプルが定義されている。Lightflowで似たようなことができないか使い方を検討やってみた。
まず、Pythonで読めるように、ファイルをEditorを使って整えた。
ファイル名はcolorinc.py
以下のように記述した。


#! /usr/bin/env python
#colorinc.py
from lightflowPM import *

Blue=vector3(0, 0.6, 1)
Red=vector3(1, 0, 0)
Green=vector3(0, 1, 0.5)
Violet=vector3(1, 0.2, 1)
Orange=vector3(1, 0.6, 0.2)
Yellow =vector3(1,1,0)
Cyan =vector3(0, 1, 1)
Magenta =vector3(1, 0, 1)
White =vector3(1, 1, 1)
Black =vector3(0, 0, 0)

DimGray=vector3(0.329412,0.329412,0.329412)
Gray=vector3(0.752941,0.752941,0.752941)
LightGray=vector3(0.658824,0.658824,0.658824)
VLightGray=vector3(0.80,0.80,0.80)

Aquamarine=vector3(0.439216,0.858824,0.576471)
BlueViolet=vector3(0.62352,0.372549,0.623529)
Brown=vector3(0.647059,0.164706,0.164706)
CadetBlue=vector3(0.372549,0.623529,0.623529)
Coral=vector3(1.0,0.498039,0.0)
CornflowerBlue=vector3(0.258824,0.258824,0.435294)
DarkGreen=vector3(0.184314,0.309804,0.184314)
DarkOliveGreen=vector3(0.309804,0.309804,0.184314)
DarkOrchid=vector3(0.6,0.196078,0.8)
DarkSlateBlue=vector3(0.119608,0.137255,0.556863)
DarkSlateGray=vector3(0.184314,0.309804,0.309804)
DarkTurquoise=vector3(0.439216,0.576471,0.858824)
Firebrick=vector3(0.556863,0.137255,0.137255)
ForestGreen=vector3(0.137255,0.556863,0.137255)
Gold=vector3(0.8,0.498039,0.196078)
Goldenrod=vector3(0.858824,0.858824,0.439216)
GreenYellow=vector3(0.576471,0.858824,0.439216)
IndianRed=vector3(0.309804,0.184314,0.184314)
Khaki=vector3(0.623529,0.623529,0.372549)
LightBlue=vector3(0.74902,0.847059,0.847059)
LightSteelBlue=vector3(0.560784,0.560784,0.737255)
LimeGreen=vector3(0.196078,0.8,0.196078)
Maroon=vector3(0.556863,0.137255,0.419608)
MediumAquamarine=vector3(0.196078,0.8,0.6)
MediumBlue=vector3(0.196078,0.196078,0.8)
MediumForestGreen=vector3(0.419608,0.556863,0.137255)
MediumGoldenrod=vector3(0.917647,0.917647,0.678431)
MediumOrchid=vector3(0.576471,0.439216,0.858824)
MediumSeaGreen=vector3(0.258824,0.435294,0.258824)
MediumTurquoise=vector3(0.439216,0.858824,0.858824)
MediumVioletRed=vector3(0.858824,0.439216,0.576471)
MidnightBlue=vector3(0.184314,0.184314,0.309804)
Navy=vector3(0.137255,0.137255,0.556863)
NavyBlue=vector3(0.137255,0.137255,0.556863)
Orange=vector3(1,0.5,0.0)
Orchid=vector3(0.858824,0.439216,0.858824)
PaleGreen=vector3(0.560784,0.737255,0.560784)
Pink=vector3(0.737255,0.560784,0.560784)
Plum=vector3(0.917647,0.678431,0.917647)
Salmon=vector3(0.435294,0.258824,0.258824)
SeaGreen=vector3(0.137255,0.556863,0.419608)
Sienna=vector3(0.556863,0.419608,0.137255)
SkyBlue=vector3(0.196078,0.6,0.8)

SteelBlue=vector3(0.137255,0.419608,0.556863)
Tan=vector3(0.858824,0.576471,0.439216)
Thistle=vector3(0.847059,0.74902,0.847059)
Turquoise=vector3(0.678431,0.917647,0.917647)
Violet=vector3(0.309804,0.184314,0.309804)
VioletRed=vector3(0.8,0.196078,0.6)
Wheat=vector3(0.847059,0.847059,0.74902)
YellowGreen=vector3(0.6,0.8,0.196078)
SummerSky=vector3(0.22,0.69,0.87)
RichBlue=vector3(0.35,0.35,0.67)
Brass=vector3( 0.71,0.65,0.26)
Copper=vector3(0.72,0.45,0.20)
Bronze=vector3(0.55,0.47,0.14)
Bronze2=vector3(0.65,0.49,0.24)
Silver=vector3(0.90,0.91,0.98)
BrightGold=vector3(0.85,0.85,0.10)
OldGold=vector3( 0.81,0.71,0.23)
Feldspar=vector3(0.82,0.57,0.46)
Quartz=vector3(0.85,0.85,0.95)
NeonPink=vector3(1.00,0.43,0.78)
DarkPurple=vector3(0.53,0.12,0.47)
NeonBlue=vector3(0.30,0.30,1.00)
CoolCopper=vector3(0.85,0.53,0.10)
MandarinOrange=vector3(0.89,0.47,0.20)
LightWood=vector3(0.91,0.76,0.65)
MediumWood=vector3(0.65,0.50,0.39)
DarkWood=vector3(0.52,0.37,0.26)
SpicyPink=vector3(1.00,0.11,0.68)
SemiSweetChoc=vector3(0.42,0.26,0.15)
BakersChoc=vector3(0.36,0.20,0.09)
Flesh=vector3(0.96,0.80,0.69)
NewTan=vector3(0.92,0.78,0.62)
NewMidnightBlue=vector3(0.00,0.00,0.61)
VeryDarkBrown=vector3(0.35,0.16,0.14)
DarkBrown=vector3(0.36,0.25,0.20)
DarkTan=vector3(0.59,0.41,0.31)
GreenCopper=vector3(0.32,0.49,0.46)
DkGreenCopper=vector3(0.29,0.46,0.43)
DustyRose=vector3(0.52,0.39,0.39)
HuntersGreen=vector3(0.13,0.37,0.31)
Scarlet=vector3(0.55,0.09,0.09)
Med_Purple=vector3( 0.73,0.16,0.96)
Light_Purple=vector3(0.87,0.58,0.98)
Very_Light_Purple=vector3(0.94,0.81,0.99)


後はLightflowでシーン記述したファイルの中で実際に呼び出すために、
import colorincと記述しておき、色呼び出しの際は、
colorinc.DimGray
colorinc.BlueViolet
と記述してあげると、指定の色が呼び出される。
以下、サンプルを参考にしてください。
box_colors4.jpg

#! /usr/bin/env python
#box_colors6.py

from lightflowPM import *
from math import *

import colorinc

s = scene()

s.lightOn( s.newLight( "point", [ "position", vector3( 5.0, -5.0, 4.0 ), "color", vector3( 300.0, 300.0, 300.0 ) ] ) )

s.lightOn( s.newLight( "ambient", [ "color", vector3( 0.3, 0.3, 0.3 ) ] ) ) #環境光を加える。

plastic = s.newMaterial( "standard",[ "kc", colorinc.DarkTurquoise,"kd",0.66 ] ) #

plastic2 = s.newMaterial( "standard",[ "kc", colorinc.Firebrick,"kd",0.66 ] ) #

plastic3 = s.newMaterial( "standard",[ "kc", colorinc.ForestGreen,"kd",0.66 ] ) #

plastic4 = s.newMaterial( "standard",[ "kc", colorinc.Gold,"kd",0.66 ] ) #

plastic5 = s.newMaterial( "standard",[ "kc", colorinc.Goldenrod,"kd",0.66 ] ) #

plastic6 = s.newMaterial( "standard",[ "kc", colorinc.GreenYellow,"kd",0.66 ] ) #


check_ground=s.newPattern("check",["color",vector3( 0.2, 0.4, 0.6 ),"scale",0.025])

ground=s.newMaterial( "standard",[ "kc", check_ground,"kc",vector3( 1.0, 1.0, 1.0 ),"ka",check_ground ] ) #チェック青と白

#DarkTurquoiseのbox
s.materialBegin( plastic )
s.addObject( s.newObject( "box", [ "position",vector3( -1.0, -1.0, -1.0 ),vector3( 1.0, 1.0, 1.0 )] ) )
s.materialEnd()

#Firebrickのbox
s.materialBegin( plastic2 )
s.transformBegin( transform().translation( vector3(-3.0,0,0)))

s.addObject( s.newObject( "box", [ "position",vector3( -1.0, -1.0, -1.0 ),vector3( 1.0, 1.0, 1.0 )] ) )

s.transformEnd()
s.materialEnd()

#ForestGreenのbox z軸中心に45度回転
s.materialBegin( plastic3 )
s.transformBegin( transform().translation( vector3(3.0,0,0)))
s.transformBegin( transform().rotationAroundZ( pi*45.0/180 ))

s.addObject( s.newObject( "box", [ "position",vector3( -1.0, -1.0, -1.0 ),vector3( 1.0, 1.0, 1.0 )] ) )

s.transformEnd()
s.transformEnd()
s.materialEnd()


#Goldのbox
s.materialBegin( plastic4 )
s.transformBegin( transform().translation( vector3(-3.0,-3,0)))

s.addObject( s.newObject( "box", [ "position",vector3( -1.0, -1.0, -1.0 ),vector3( 1.0, 1.0, 1.0 )] ) )

s.transformEnd()
s.materialEnd()


#Goldenrodのbox
s.materialBegin( plastic5 )
s.transformBegin( transform().translation( vector3(0,-3,0)))

s.addObject( s.newObject( "box", [ "position",vector3( -1.0, -1.0, -1.0 ),vector3( 1.0, 1.0, 1.0 )] ) )

s.transformEnd()
s.materialEnd()

#GreenYellowのbox
s.materialBegin( plastic6 )
s.transformBegin( transform().translation( vector3(3.0,-3,0)))

s.addObject( s.newObject( "box", [ "position",vector3( -1.0, -1.0, -1.0 ),vector3( 1.0, 1.0, 1.0 )] ) )

s.transformEnd()
s.materialEnd()



#check模様の地面groundをpatchで作成しています。高さ(z軸)を-1.0にしてぴったり立方体とあわせています。
s.materialBegin( ground )

s.addObject( s.newObject( "patch", [ "points",vector3( -50, -50, -1.0 ),vector3( -50, 50, -1.0 ),vector3( 50, -50, -1.0 ),vector3( 50, 50, -1.0 )] ) )

s.materialEnd()

saver = s.newImager( "tga-saver", [ "file", "box_colors6.tga" ] )

s.imagerBegin( saver )

camera = s.newCamera( "pinhole", [ "eye", vector3( 0, -10, 5 ), "aim", vector3( 0, 0, 0 ) ] )

s.imagerEnd()

s.render( camera, 512, 300 )


box_colors3.jpg

box_colors2.jpg
  • -
  • -

<< Lightflow質感設定その6 拡散量 戻る Lightflowでリングをつくる >>