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