0027974: Visualization, ray tracing - Improve ray tracing engine
[occt.git] / samples / tcl / pathtrace_ball.tcl
CommitLineData
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
7set aBallPath [locate_data_file occ/Ball.brep]
8
9pload MODELING VISUALIZATION
10
11# Setup 3D viewer
12vclear
13vinit name=View1 w=512 h=512
14vglinfo
15vvbo 0
16vsetdispmode 1
17
18# Setup view parameters
19vcamera -persp
20vviewparams -scale 18 -eye 44.49 -0.15 33.93 -at -14.20 -0.15 1.87 -up -0.48 0.00 0.88
21
22# Load the model from disk
23puts "Importing shape..."
24restore $aBallPath ball
25
26# Tessellate the model
27incmesh ball 0.01
28
29# Display the model and assign material
30vdisplay -noupdate ball
31vsetmaterial -noupdate ball glass
32
33# Create a sphere inside the model
34psphere s 8
35incmesh s 0.01
36vdisplay -noupdate s
37vsetlocation -noupdate s 0 0 13
38vsetmaterial -noupdate s plaster
39
40# Create chessboard-style floor
41box tile 10 10 0.1
42eval compound [lrepeat 144 tile] tiles
43explode tiles
44for {set i 0} {$i < 12} {incr i} {
45 for {set j 1} {$j <= 12} {incr j} {
46 ttranslate tiles_[expr 12 * $i + $j] [expr $i * 10 - 90] [expr $j * 10 - 70] -0.15
47 vdisplay -noupdate tiles_[expr 12 * $i + $j]
48
49 vsetmaterial -noupdate tiles_[expr 12 * $i + $j] plaster
50
51 if {($i + $j) % 2 == 0} {
52 vbsdf tiles_[expr 12 * $i + $j] -kd 0.85
53 } else {
54 vbsdf tiles_[expr 12 * $i + $j] -kd 0.45
55 }
56 }
57}
58
59# Configure light sources
60vlight del 1
61vlight change 0 head 0
62vlight change 0 direction -0.25 -1 -1
63vlight change 0 sm 0.3
64vlight change 0 int 10
65
66# Load environment map
67vtextureenv on 1
68
69puts "Trying path tracing mode..."
70vrenderparams -ray -gi -rayDepth 10
71
72# Start progressive refinement mode
73#vprogressive
74
75puts "Make several path tracing iterations to refine the picture, please wait..."
76vfps 100
77puts "Done. To improve the image further, or after view manipulations, give command:"
78puts "vfps \[nb_iteratons\]"