264ed7796e006b39593c82d4c80ea6dc445e5cf4
[occt.git] / samples / tcl / pathtrace_cube.tcl
1 # Script demonstrating Global illumination effects using non-interactive 
2 # path tracing rendering engine in 3d view
3
4 #Category: Visualization
5 #Title: Path tracing - Cube
6
7 pload MODELING VISUALIZATION
8
9 # setup 3D viewer content
10 vclear
11 vinit name=View1 w=512 h=512
12 vglinfo
13
14 # setup light sources
15 vlight del 0
16 vlight del 1
17 vlight add positional head 0 pos 0.5 0.5 0.85
18 vlight change 0 sm 0.06
19 vlight change 0 int 30.0
20
21 vvbo 0
22 vsetdispmode 1
23 vcamera -persp
24
25 # setup outer box
26 box b 1 1 1 
27 explode b FACE 
28 vdisplay -noupdate b_1 b_2 b_3 b_5 b_6
29 vlocation -noupdate b_1 -setLocation  1  0  0
30 vlocation -noupdate b_2 -setLocation -1  0  0
31 vlocation -noupdate b_3 -setLocation  0  1  0
32 vlocation -noupdate b_5 -setLocation  0  0  1
33 vlocation -noupdate b_6 -setLocation  0  0 -1
34
35 vsetmaterial -noupdate b_1 plastic
36 vsetmaterial -noupdate b_2 plastic
37 vsetmaterial -noupdate b_3 plastic
38 vsetmaterial -noupdate b_5 plastic
39 vsetmaterial -noupdate b_6 plastic
40 vbsdf b_1 -kd 1 0.3 0.3 -ks 0
41 vbsdf b_2 -kd 0.3 0.5 1 -ks 0
42 vbsdf b_3 -kd 1 -ks 0
43 vbsdf b_5 -kd 1 -ks 0
44 vbsdf b_6 -kd 1 -ks 0
45
46 vfront
47 vfit
48
49 # setup first inner sphere
50 psphere s 0.2
51 vdisplay     -noupdate s
52 vlocation    -noupdate s -setLocation 0.21 0.3 0.2
53 vsetmaterial -noupdate s glass
54 vbsdf s -absorpcolor 0.8 0.8 1.0
55 vbsdf s -absorpcoeff 6
56
57 # setup first inner box
58 box c 0.3 0.3 0.2
59 vdisplay     -noupdate c
60 vlocation    -noupdate c -setLocation 0.55 0.3 0.0
61 vlocation    -noupdate c -rotate 0 0 0 0 0 1 -30
62 vsetmaterial -noupdate c plastic
63 vbsdf c -kd 1.0 0.8 0.2 -ks 0.3 -n
64
65 # setup second inner box
66 box g 0.15 0.15 0.3
67 vdisplay     -noupdate g
68 vlocation    -noupdate g -setLocation 0.7 0.25 0.2
69 vlocation    -noupdate g -rotate 0 0 0 0 0 1 10
70 vsetmaterial -noupdate g glass
71 vbsdf g -absorpcolor 0.8 1.0 0.8
72 vbsdf g -absorpcoeff 6
73
74 # setup second inner sphere
75 psphere r 0.1
76 vdisplay -noupdate r
77 vsetmaterial -noupdate r plastic
78 vbsdf r -kd 0.5 0.9 0.3 -ks 0.0 -kr 0.3 -n
79 vbsdf r -fresnel Constant 1.0
80 vlocation r -setLocation 0.5 0.65 0.1
81
82 puts "Trying path tracing mode..."
83 vrenderparams -ray -gi -rayDepth 8
84
85 puts "Make several path tracing iterations to refine the picture, please wait..."
86 vfps 100
87 puts "Done. To improve the image further, or after view manipulations, give command:"
88 puts "vfps \[nb_iteratons\]"