0031999: Tests - request Core Profile on macOS for Ray-Tracing tests
[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
ba562b2b 10# Ray-Tracing doesn't work with Compatible Profile on macOS
11if { $::tcl_platform(os) == "Darwin" } { vcaps -core }
6e728f3b 12
13# Setup 3D viewer
14vclear
15vinit name=View1 w=512 h=512
16vglinfo
17vvbo 0
18vsetdispmode 1
19
20# Setup view parameters
21vcamera -persp
22vviewparams -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
25puts "Importing shape..."
26restore $aBallPath ball
27
28# Tessellate the model
29incmesh ball 0.01
30
31# Display the model and assign material
32vdisplay -noupdate ball
33vsetmaterial -noupdate ball glass
34
35# Create a sphere inside the model
36psphere s 8
37incmesh s 0.01
38vdisplay -noupdate s
39vsetlocation -noupdate s 0 0 13
40vsetmaterial -noupdate s plaster
41
42# Create chessboard-style floor
43box tile 10 10 0.1
44eval compound [lrepeat 144 tile] tiles
45explode tiles
46for {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
89d855ba 62vlight -change 0 -head 0
63vlight -change 0 -direction -0.25 -1 -1
64vlight -change 0 -sm 0.3
65vlight -change 0 -int 10.0
6e728f3b 66
67# Load environment map
68vtextureenv on 1
69
70puts "Trying path tracing mode..."
71vrenderparams -ray -gi -rayDepth 10
72
73# Start progressive refinement mode
74#vprogressive
75
76puts "Make several path tracing iterations to refine the picture, please wait..."
77vfps 100
78puts "Done. To improve the image further, or after view manipulations, give command:"
9196ea9d 79puts "vfps \[nb_iteratons\] or vrepaint -continuous"