raytrace.tcl 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. # Script demonstrating ray tracing in 3d view
  2. #Category: Visualization
  3. #Title: Ray tracing
  4. # Ray-Tracing doesn't work with Compatible Profile on macOS
  5. pload VISUALIZATION
  6. if { $::tcl_platform(os) == "Darwin" } { vcaps -core }
  7. # make bottle by calling another script
  8. source [file join [file dirname [info script]] bottle.tcl]
  9. # make table and a glass
  10. box table -50 -50 -10 100 100 10
  11. pcone glass_out 7 9 25
  12. pcone glass_in 7 9 25
  13. ttranslate glass_in 0 0 0.2
  14. bcut glass glass_out glass_in
  15. ttranslate glass -30 -30 0
  16. # show table and glass
  17. vinit w=1024 h=1024
  18. vsetmaterial bottle aluminium
  19. vdisplay table
  20. vsetmaterial table bronze
  21. vsetmaterial table plastic
  22. vsetcolor table coral2
  23. vdisplay glass
  24. vsetmaterial glass plastic
  25. vsetcolor glass brown
  26. vsettransparency glass 0.6
  27. # add light source for shadows
  28. vlight spot -type SPOT -pos -100 -100 300
  29. # set white background and fit view
  30. vbackground -color WHITE
  31. vfit
  32. # set ray tracing
  33. puts "Trying raytrace mode..."
  34. if { ! [catch {vrenderparams -raytrace -shadows -reflections -fsaa -rayDepth 5}] } {
  35. vtextureenv on 1
  36. }