6e728f3b |
1 | # Script demonstrating Global illumination materials |
2 | # using path tracing rendering engine in 3D view |
3 | |
4 | #Category: Visualization |
5 | #Title: Path tracing - Ball |
6 | |
7 | set aBallPath [locate_data_file occ/Ball.brep] |
8 | |
9 | pload MODELING VISUALIZATION |
ba562b2b |
10 | # Ray-Tracing doesn't work with Compatible Profile on macOS |
11 | if { $::tcl_platform(os) == "Darwin" } { vcaps -core } |
6e728f3b |
12 | |
13 | # Setup 3D viewer |
14 | vclear |
15 | vinit name=View1 w=512 h=512 |
16 | vglinfo |
17 | vvbo 0 |
18 | vsetdispmode 1 |
19 | |
20 | # Setup view parameters |
21 | vcamera -persp |
22 | vviewparams -scale 18 -eye 44.49 -0.15 33.93 -at -14.20 -0.15 1.87 -up -0.48 0.00 0.88 |
23 | |
24 | # Load the model from disk |
25 | puts "Importing shape..." |
26 | restore $aBallPath ball |
27 | |
28 | # Tessellate the model |
29 | incmesh ball 0.01 |
30 | |
31 | # Display the model and assign material |
32 | vdisplay -noupdate ball |
33 | vsetmaterial -noupdate ball glass |
34 | |
35 | # Create a sphere inside the model |
36 | psphere s 8 |
37 | incmesh s 0.01 |
38 | vdisplay -noupdate s |
39 | vsetlocation -noupdate s 0 0 13 |
40 | vsetmaterial -noupdate s plaster |
41 | |
42 | # Create chessboard-style floor |
43 | box tile 10 10 0.1 |
44 | eval compound [lrepeat 144 tile] tiles |
45 | explode tiles |
46 | for {set i 0} {$i < 12} {incr i} { |
47 | for {set j 1} {$j <= 12} {incr j} { |
48 | ttranslate tiles_[expr 12 * $i + $j] [expr $i * 10 - 90] [expr $j * 10 - 70] -0.15 |
49 | vdisplay -noupdate tiles_[expr 12 * $i + $j] |
50 | |
51 | vsetmaterial -noupdate tiles_[expr 12 * $i + $j] plaster |
52 | |
53 | if {($i + $j) % 2 == 0} { |
54 | vbsdf tiles_[expr 12 * $i + $j] -kd 0.85 |
55 | } else { |
56 | vbsdf tiles_[expr 12 * $i + $j] -kd 0.45 |
57 | } |
58 | } |
59 | } |
60 | |
61 | # Configure light sources |
06d40093 |
62 | vlight -change 0 -headLight 0 |
89d855ba |
63 | vlight -change 0 -direction -0.25 -1 -1 |
06d40093 |
64 | vlight -change 0 -smoothAngle 17 |
65 | vlight -change 0 -intensity 10.0 |
6e728f3b |
66 | |
67 | # Load environment map |
68 | vtextureenv on 1 |
69 | |
70 | puts "Trying path tracing mode..." |
71 | vrenderparams -ray -gi -rayDepth 10 |
72 | |
73 | # Start progressive refinement mode |
74 | #vprogressive |
75 | |
76 | puts "Make several path tracing iterations to refine the picture, please wait..." |
77 | vfps 100 |
78 | puts "Done. To improve the image further, or after view manipulations, give command:" |
9196ea9d |
79 | puts "vfps \[nb_iteratons\] or vrepaint -continuous" |