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