pathtrace_cube.tcl 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. # Script demonstrating Global illumination effects using non-interactive
  2. # path tracing rendering engine in 3d view
  3. #Category: Visualization
  4. #Title: Path tracing - Cube
  5. pload MODELING VISUALIZATION
  6. # Ray-Tracing doesn't work with Compatible Profile on macOS
  7. if { $::tcl_platform(os) == "Darwin" } { vcaps -core }
  8. # setup 3D viewer content
  9. vclear
  10. vinit name=View1 w=512 h=512
  11. vglinfo
  12. # setup light sources
  13. vlight -clear
  14. vlight -add POSITIONAL -headLight 0 -pos 0.5 0.5 0.85 -smoothRadius 0.06 -intensity 30.0 -name pntlight
  15. vvbo 0
  16. vsetdispmode 1
  17. vcamera -persp
  18. # setup outer box
  19. box b 1 1 1
  20. explode b FACE
  21. vdisplay -noupdate b_1 b_2 b_3 b_5 b_6
  22. vlocation -noupdate b_1 -setLocation 1 0 0
  23. vlocation -noupdate b_2 -setLocation -1 0 0
  24. vlocation -noupdate b_3 -setLocation 0 1 0
  25. vlocation -noupdate b_5 -setLocation 0 0 1
  26. vlocation -noupdate b_6 -setLocation 0 0 -1
  27. vsetmaterial -noupdate b_1 plastic
  28. vsetmaterial -noupdate b_2 plastic
  29. vsetmaterial -noupdate b_3 plastic
  30. vsetmaterial -noupdate b_5 plastic
  31. vsetmaterial -noupdate b_6 plastic
  32. vbsdf b_1 -kd 1 0.3 0.3 -ks 0
  33. vbsdf b_2 -kd 0.3 0.5 1 -ks 0
  34. vbsdf b_3 -kd 1 -ks 0
  35. vbsdf b_5 -kd 1 -ks 0
  36. vbsdf b_6 -kd 1 -ks 0
  37. vfront
  38. vfit
  39. # setup first inner sphere
  40. psphere s 0.2
  41. vdisplay -noupdate s
  42. vlocation -noupdate s -setLocation 0.21 0.3 0.2
  43. vsetmaterial -noupdate s glass
  44. vbsdf s -absorpColor 0.8 0.8 1.0
  45. vbsdf s -absorpCoeff 6
  46. # setup first inner box
  47. box c 0.3 0.3 0.2
  48. vdisplay -noupdate c
  49. vlocation -noupdate c -reset -rotate 0 0 0 0 0 1 -30 -translate 0.55 0.3 0.0
  50. vsetmaterial -noupdate c plastic
  51. vbsdf c -kd 1.0 0.8 0.2 -ks 0.3 -n
  52. # setup second inner box
  53. box g 0.15 0.15 0.3
  54. vdisplay -noupdate g
  55. vlocation -noupdate g -reset -rotate 0 0 0 0 0 1 10 -translate 0.7 0.25 0.2
  56. vsetmaterial -noupdate g glass
  57. vbsdf g -absorpColor 0.8 1.0 0.8
  58. vbsdf g -absorpCoeff 6
  59. # setup second inner sphere
  60. psphere r 0.1
  61. vdisplay -noupdate r
  62. vsetmaterial -noupdate r plastic
  63. vbsdf r -kd 0.5 0.9 0.3 -ks 0.3 -baseRoughness 0.0 -n
  64. vbsdf r -baseFresnel Constant 1.0
  65. vlocation r -setLocation 0.5 0.65 0.1
  66. puts "Trying path tracing mode..."
  67. vrenderparams -ray -gi -rayDepth 8
  68. puts "Make several path tracing iterations to refine the picture, please wait..."
  69. vfps 100
  70. puts "Done. To improve the image further, or after view manipulations, give command:"
  71. puts "vfps \[nb_iteratons\] or vrepaint -continuous"