pathtrace_materials.tcl 6.1 KB

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