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