0029559: Samples - wrong copyright statement in FuncDemo
[occt.git] / samples / tcl / pathtrace_materials.tcl
CommitLineData
05aa616d 1# Script demonstrating Global illumination materials
2# using path tracing rendering engine in 3D view
3
4#Category: Visualization
5#Title: Path tracing - Materials
6
7set aBallPath [locate_data_file occ/Ball.brep]
8
9pload MODELING VISUALIZATION
10
11# Setup 3D viewer
12vclear
13vinit name=View1 w=512 h=512
14vglinfo
15vvbo 0
16vsetdispmode 1
17
18# Restore exported shapes
19restore $aBallPath Ball0
20restore $aBallPath Ball1
21restore $aBallPath Ball2
22restore $aBallPath Ball3
23restore $aBallPath Ball4
24restore $aBallPath Ball5
25restore $aBallPath Ball6
26restore $aBallPath Ball7
27restore $aBallPath Ball8
28
29# Create chessboard-style floor
30box tile 10 10 0.1
31eval compound [lrepeat 144 tile] tiles
32explode tiles
33for {set i 0} {$i < 12} {incr i} {
34 for {set j 1} {$j <= 12} {incr j} {
35 ttranslate tiles_[expr 12 * $i + $j] [expr $i * 10 - 90] [expr $j * 10 - 70] -0.15
36 vdisplay -noupdate tiles_[expr 12 * $i + $j]
37
38 vsetmaterial -noupdate tiles_[expr 12 * $i + $j] plaster
39
40 if {($i + $j) % 2 == 0} {
41 vbsdf tiles_[expr 12 * $i + $j] -kd 0.85
42 } else {
43 vbsdf tiles_[expr 12 * $i + $j] -kd 0.45
44 }
45 }
46}
47
48# Setup object 'Ball1'
49vdisplay Ball1
50vsetmaterial Ball1 Brass
51vbsdf Ball1 -Kc 0 0 0
52vbsdf Ball1 -Kd 0.272798 0.746262 0.104794
53vbsdf Ball1 -Ks 0.253738 0.253738 0.253738
54vbsdf Ball1 -Kt 0 0 0
55vbsdf Ball1 -baseRoughness 0.045
56vbsdf Ball1 -coatRoughness 0
57vbsdf Ball1 -Le 0 0 0
58vbsdf Ball1 -absorpColor 0 0 0
59vbsdf Ball1 -absorpCoeff 0
60vbsdf Ball1 -coatFresnel Constant 0
61vbsdf Ball1 -baseFresnel Schlick 0.58 0.42 0.2
62vlocation Ball1 -rotation 0 0 0 1
63vlocation Ball1 -location 10 0 0
64
65# Setup object 'Ball2'
66vdisplay Ball2
67vsetmaterial Ball2 Brass
68vbsdf Ball2 -Kc 0 0 0
69vbsdf Ball2 -Kd 0.8 0.8 0.8
70vbsdf Ball2 -Ks 0 0 0
71vbsdf Ball2 -Kt 0 0 0
72vbsdf Ball2 -baseRoughness 0
73vbsdf Ball2 -coatRoughness 0
74vbsdf Ball2 -Le 2.02 0.171915 0.171915
75vbsdf Ball2 -absorpColor 0 0 0
76vbsdf Ball2 -absorpCoeff 0
77vbsdf Ball2 -coatFresnel Constant 0
78vbsdf Ball2 -baseFresnel Constant 1
79vlocation Ball2 -rotation 0 0 0 1
80vlocation Ball2 -location 10 40 0
81
82# Setup object 'Ball3'
83vdisplay Ball3
84vsetmaterial Ball3 Glass
85vbsdf Ball3 -Kc 1 1 1
86vbsdf Ball3 -Kd 0 0 0
87vbsdf Ball3 -Ks 0 0 0
88vbsdf Ball3 -Kt 1 1 1
89vbsdf Ball3 -baseRoughness 0
90vbsdf Ball3 -coatRoughness 0
91vbsdf Ball3 -Le 0 0 0
92vbsdf Ball3 -absorpColor 0.75 0.95 0.9
93vbsdf Ball3 -absorpCoeff 0.05
94vbsdf Ball3 -coatFresnel Dielectric 1.62
95vbsdf Ball3 -baseFresnel Constant 1
96vlocation Ball3 -rotation 0 0 0 1
97vlocation Ball3 -location -30 -40 0
98
99# Setup object 'Ball4'
100vdisplay Ball4
101vsetmaterial Ball4 Brass
102vbsdf Ball4 -Kc 0 0 0
103vbsdf Ball4 -Kd 0 0 0
104vbsdf Ball4 -Ks 0.985 0.985 0.985
105vbsdf Ball4 -Kt 0 0 0
106vbsdf Ball4 -baseRoughness 0
107vbsdf Ball4 -coatRoughness 0
108vbsdf Ball4 -Le 0 0 0
109vbsdf Ball4 -absorpColor 0 0 0
110vbsdf Ball4 -absorpCoeff 0
111vbsdf Ball4 -coatFresnel Constant 0
112vbsdf Ball4 -baseFresnel Schlick 0.58 0.42 0.2
113vlocation Ball4 -rotation 0 0 0 1
114vlocation Ball4 -location -70 -40 0
115
116# Setup object 'Ball5'
117vdisplay Ball5
118vsetmaterial Ball5 Glass
119vbsdf Ball5 -Kc 1 1 1
120vbsdf Ball5 -Kd 0 0 0
121vbsdf Ball5 -Ks 0 0 0
122vbsdf Ball5 -Kt 1 1 1
123vbsdf Ball5 -baseRoughness 0
124vbsdf Ball5 -coatRoughness 0
125vbsdf Ball5 -Le 0 0 0
126vbsdf Ball5 -absorpColor 0 0.288061 0.825532
127vbsdf Ball5 -absorpCoeff 0.3
128vbsdf Ball5 -coatFresnel Dielectric 1.62
129vbsdf Ball5 -baseFresnel Constant 1
130vlocation Ball5 -rotation 0 0 0 1
131vlocation Ball5 -location -30 0 0
132
133# Setup object 'Ball6'
134vdisplay Ball6
135vsetmaterial Ball6 Brass
136vbsdf Ball6 -Kc 1 1 1
137vbsdf Ball6 -Kd 0 0.716033 0.884507
138vbsdf Ball6 -Ks 0.115493 0.115493 0.115493
139vbsdf Ball6 -Kt 0 0 0
140vbsdf Ball6 -baseRoughness 0.045
141vbsdf Ball6 -coatRoughness 0
142vbsdf Ball6 -Le 0 0 0
143vbsdf Ball6 -absorpColor 0 0 0
144vbsdf Ball6 -absorpCoeff 0
145vbsdf Ball6 -coatFresnel Dielectric 1.5
146vbsdf Ball6 -baseFresnel Schlick 0.58 0.42 0.2
147vlocation Ball6 -rotation 0 0 0 1
148vlocation Ball6 -location -30 40 0
149
150# Setup object 'Ball7'
151vdisplay Ball7
152vsetmaterial Ball7 Brass
153vbsdf Ball7 -Kc 1 1 1
154vbsdf Ball7 -Kd 1e-06 9.9999e-07 9.9999e-07
155vbsdf Ball7 -Ks 0.0479573 0.804998 0
156vbsdf Ball7 -Kt 0 0 0
157vbsdf Ball7 -baseRoughness 0.447
158vbsdf Ball7 -coatRoughness 0
159vbsdf Ball7 -Le 0 0 0
160vbsdf Ball7 -absorpColor 0 0 0
161vbsdf Ball7 -absorpCoeff 0
162vbsdf Ball7 -coatFresnel Dielectric 1.5
163vbsdf Ball7 -baseFresnel Schlick 0.58 0.42 0.2
164vlocation Ball7 -rotation 0 0 0 1
165vlocation Ball7 -location -70 0 0
166
167# Setup object 'Ball8'
168vdisplay Ball8
169vsetmaterial Ball8 Aluminium
170vbsdf Ball8 -Kc 0 0 0
171vbsdf Ball8 -Kd 0 0 0
172vbsdf Ball8 -Ks 0.985 0.985 0.985
173vbsdf Ball8 -Kt 0 0 0
174vbsdf Ball8 -baseRoughness 0.026
175vbsdf Ball8 -coatRoughness 0
176vbsdf Ball8 -Le 0 0 0
177vbsdf Ball8 -absorpColor 0 0 0
178vbsdf Ball8 -absorpCoeff 0
179vbsdf Ball8 -coatFresnel Constant 0
180vbsdf Ball8 -baseFresnel Schlick 0.913183 0.921494 0.924524
181vlocation Ball8 -rotation 0 0 0 1
182vlocation Ball8 -location -70 40 0
183
184# Setup object 'Ball0'
185vdisplay Ball0
186vsetmaterial Ball0 Glass
187vbsdf Ball0 -Kc 0 0 0
188vbsdf Ball0 -Kd 0.723404 0.166229 0.166229
189vbsdf Ball0 -Ks 0 0 0
190vbsdf Ball0 -Kt 0 0 0
191vbsdf Ball0 -baseRoughness 0
192vbsdf Ball0 -coatRoughness 0
193vbsdf Ball0 -Le 0 0 0
194vbsdf Ball0 -absorpColor 0 0 0
195vbsdf Ball0 -absorpCoeff 0
196vbsdf Ball0 -coatFresnel Constant 0
197vbsdf Ball0 -baseFresnel Constant 1
198vlocation Ball0 -rotation 0 0 0 1
199vlocation Ball0 -location 10 -40 0
200
201# Restore view parameters
202vcamera -perspective -fovy 25
203vcamera -distance 238.089
204vviewparams -proj 0.679219 -0.00724546 0.7339
205vviewparams -up -0.733931 -0.00311795 0.679217
206vviewparams -at -22.3025 0.0986351 3.30327
207vviewparams -eye 139.412 -1.62643 178.037
208vviewparams -size 170.508
209
210# Restore light source parameters
211vlight clear
212vlight add directional direction -0.303949 -0.434084 -0.848048 smoothness 0.3 intensity 12
213
214# Load environment map
215vtextureenv on 1
216
217puts "Trying path tracing mode..."
218vrenderparams -ray -gi -rayDepth 10
219
220# Start progressive refinement mode
221#vprogressive
222
223puts "Make several path tracing iterations to refine the picture, please wait..."
224vfps 512
225puts "Done. To improve the image further, or after view manipulations, give command:"
226puts "vfps \[nb_iteratons\]"