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
10 # Ray-Tracing doesn't work with Compatible Profile on macOS
11 if { $::tcl_platform(os) == "Darwin" } { vcaps -core }
15 vinit name=View1 w=512 h=512
20 # Restore exported shapes
21 restore $aBallPath Ball0
22 restore $aBallPath Ball1
23 restore $aBallPath Ball2
24 restore $aBallPath Ball3
25 restore $aBallPath Ball4
26 restore $aBallPath Ball5
27 restore $aBallPath Ball6
28 restore $aBallPath Ball7
29 restore $aBallPath Ball8
31 # Create chessboard-style floor
33 eval compound [lrepeat 144 tile] tiles
35 for {set i 0} {$i < 12} {incr i} {
36 for {set j 1} {$j <= 12} {incr j} {
37 ttranslate tiles_[expr 12 * $i + $j] [expr $i * 10 - 90] [expr $j * 10 - 70] -0.15
38 vdisplay -noupdate tiles_[expr 12 * $i + $j]
40 vsetmaterial -noupdate tiles_[expr 12 * $i + $j] plaster
42 if {($i + $j) % 2 == 0} {
43 vbsdf tiles_[expr 12 * $i + $j] -kd 0.85
45 vbsdf tiles_[expr 12 * $i + $j] -kd 0.45
50 # Setup object 'Ball1'
52 vsetmaterial Ball1 Brass
54 vbsdf Ball1 -Kd 0.272798 0.746262 0.104794
55 vbsdf Ball1 -Ks 0.253738 0.253738 0.253738
57 vbsdf Ball1 -baseRoughness 0.045
58 vbsdf Ball1 -coatRoughness 0
60 vbsdf Ball1 -absorpColor 0 0 0
61 vbsdf Ball1 -absorpCoeff 0
62 vbsdf Ball1 -coatFresnel Constant 0
63 vbsdf Ball1 -baseFresnel Schlick 0.58 0.42 0.2
64 vlocation Ball1 -rotation 0 0 0 1
65 vlocation Ball1 -location 10 0 0
67 # Setup object 'Ball2'
69 vsetmaterial Ball2 Brass
71 vbsdf Ball2 -Kd 0.8 0.8 0.8
74 vbsdf Ball2 -baseRoughness 0
75 vbsdf Ball2 -coatRoughness 0
76 vbsdf Ball2 -Le 2.02 0.171915 0.171915
77 vbsdf Ball2 -absorpColor 0 0 0
78 vbsdf Ball2 -absorpCoeff 0
79 vbsdf Ball2 -coatFresnel Constant 0
80 vbsdf Ball2 -baseFresnel Constant 1
81 vlocation Ball2 -rotation 0 0 0 1
82 vlocation Ball2 -location 10 40 0
84 # Setup object 'Ball3'
86 vsetmaterial Ball3 Glass
91 vbsdf Ball3 -baseRoughness 0
92 vbsdf Ball3 -coatRoughness 0
94 vbsdf Ball3 -absorpColor 0.75 0.95 0.9
95 vbsdf Ball3 -absorpCoeff 0.05
96 vbsdf Ball3 -coatFresnel Dielectric 1.62
97 vbsdf Ball3 -baseFresnel Constant 1
98 vlocation Ball3 -rotation 0 0 0 1
99 vlocation Ball3 -location -30 -40 0
101 # Setup object 'Ball4'
103 vsetmaterial Ball4 Brass
104 vbsdf Ball4 -Kc 0 0 0
105 vbsdf Ball4 -Kd 0 0 0
106 vbsdf Ball4 -Ks 0.985 0.985 0.985
107 vbsdf Ball4 -Kt 0 0 0
108 vbsdf Ball4 -baseRoughness 0
109 vbsdf Ball4 -coatRoughness 0
110 vbsdf Ball4 -Le 0 0 0
111 vbsdf Ball4 -absorpColor 0 0 0
112 vbsdf Ball4 -absorpCoeff 0
113 vbsdf Ball4 -coatFresnel Constant 0
114 vbsdf Ball4 -baseFresnel Schlick 0.58 0.42 0.2
115 vlocation Ball4 -rotation 0 0 0 1
116 vlocation Ball4 -location -70 -40 0
118 # Setup object 'Ball5'
120 vsetmaterial Ball5 Glass
121 vbsdf Ball5 -Kc 1 1 1
122 vbsdf Ball5 -Kd 0 0 0
123 vbsdf Ball5 -Ks 0 0 0
124 vbsdf Ball5 -Kt 1 1 1
125 vbsdf Ball5 -baseRoughness 0
126 vbsdf Ball5 -coatRoughness 0
127 vbsdf Ball5 -Le 0 0 0
128 vbsdf Ball5 -absorpColor 0 0.288061 0.825532
129 vbsdf Ball5 -absorpCoeff 0.3
130 vbsdf Ball5 -coatFresnel Dielectric 1.62
131 vbsdf Ball5 -baseFresnel Constant 1
132 vlocation Ball5 -rotation 0 0 0 1
133 vlocation Ball5 -location -30 0 0
135 # Setup object 'Ball6'
137 vsetmaterial Ball6 Brass
138 vbsdf Ball6 -Kc 1 1 1
139 vbsdf Ball6 -Kd 0 0.716033 0.884507
140 vbsdf Ball6 -Ks 0.115493 0.115493 0.115493
141 vbsdf Ball6 -Kt 0 0 0
142 vbsdf Ball6 -baseRoughness 0.045
143 vbsdf Ball6 -coatRoughness 0
144 vbsdf Ball6 -Le 0 0 0
145 vbsdf Ball6 -absorpColor 0 0 0
146 vbsdf Ball6 -absorpCoeff 0
147 vbsdf Ball6 -coatFresnel Dielectric 1.5
148 vbsdf Ball6 -baseFresnel Schlick 0.58 0.42 0.2
149 vlocation Ball6 -rotation 0 0 0 1
150 vlocation Ball6 -location -30 40 0
152 # Setup object 'Ball7'
154 vsetmaterial Ball7 Brass
155 vbsdf Ball7 -Kc 1 1 1
156 vbsdf Ball7 -Kd 1e-06 9.9999e-07 9.9999e-07
157 vbsdf Ball7 -Ks 0.0479573 0.804998 0
158 vbsdf Ball7 -Kt 0 0 0
159 vbsdf Ball7 -baseRoughness 0.447
160 vbsdf Ball7 -coatRoughness 0
161 vbsdf Ball7 -Le 0 0 0
162 vbsdf Ball7 -absorpColor 0 0 0
163 vbsdf Ball7 -absorpCoeff 0
164 vbsdf Ball7 -coatFresnel Dielectric 1.5
165 vbsdf Ball7 -baseFresnel Schlick 0.58 0.42 0.2
166 vlocation Ball7 -rotation 0 0 0 1
167 vlocation Ball7 -location -70 0 0
169 # Setup object 'Ball8'
171 vsetmaterial Ball8 Aluminium
172 vbsdf Ball8 -Kc 0 0 0
173 vbsdf Ball8 -Kd 0 0 0
174 vbsdf Ball8 -Ks 0.985 0.985 0.985
175 vbsdf Ball8 -Kt 0 0 0
176 vbsdf Ball8 -baseRoughness 0.026
177 vbsdf Ball8 -coatRoughness 0
178 vbsdf Ball8 -Le 0 0 0
179 vbsdf Ball8 -absorpColor 0 0 0
180 vbsdf Ball8 -absorpCoeff 0
181 vbsdf Ball8 -coatFresnel Constant 0
182 vbsdf Ball8 -baseFresnel Schlick 0.913183 0.921494 0.924524
183 vlocation Ball8 -rotation 0 0 0 1
184 vlocation Ball8 -location -70 40 0
186 # Setup object 'Ball0'
188 vsetmaterial Ball0 Glass
189 vbsdf Ball0 -Kc 0 0 0
190 vbsdf Ball0 -Kd 0.723404 0.166229 0.166229
191 vbsdf Ball0 -Ks 0 0 0
192 vbsdf Ball0 -Kt 0 0 0
193 vbsdf Ball0 -baseRoughness 0
194 vbsdf Ball0 -coatRoughness 0
195 vbsdf Ball0 -Le 0 0 0
196 vbsdf Ball0 -absorpColor 0 0 0
197 vbsdf Ball0 -absorpCoeff 0
198 vbsdf Ball0 -coatFresnel Constant 0
199 vbsdf Ball0 -baseFresnel Constant 1
200 vlocation Ball0 -rotation 0 0 0 1
201 vlocation Ball0 -location 10 -40 0
203 # Restore view parameters
204 vcamera -perspective -fovy 25
205 vcamera -distance 238.089
206 vviewparams -proj 0.679219 -0.00724546 0.7339
207 vviewparams -up -0.733931 -0.00311795 0.679217
208 vviewparams -at -22.3025 0.0986351 3.30327
209 vviewparams -eye 139.412 -1.62643 178.037
210 vviewparams -size 170.508
212 # Restore light source parameters
214 vlight -add AMBIENT -name amblight
215 vlight -add DIRECTIONAL -direction -0.303949 -0.434084 -0.848048 -smoothAngle 17 -intensity 12 -name dirlight
217 # Load environment map
220 puts "Trying path tracing mode..."
221 vrenderparams -ray -gi -rayDepth 10
223 # Start progressive refinement mode
226 puts "Make several path tracing iterations to refine the picture, please wait..."
228 puts "Done. To improve the image further, or after view manipulations, give command:"
229 puts "vfps \[nb_iteratons\] or vrepaint -continuous"