File: pathtrace_ball.tcl

package info (click to toggle)
opencascade 7.8.1%2Bdfsg1-3
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 293,924 kB
  • sloc: cpp: 1,249,635; tcl: 15,974; cs: 5,173; java: 1,554; sh: 1,354; ansic: 821; xml: 737; makefile: 26; javascript: 22
file content (79 lines) | stat: -rw-r--r-- 2,013 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# Script demonstrating Global illumination materials
# using path tracing rendering engine in 3D view

#Category: Visualization
#Title: Path tracing - Ball

set aBallPath [locate_data_file occ/Ball.brep]

pload MODELING VISUALIZATION
# Ray-Tracing doesn't work with Compatible Profile on macOS
if { $::tcl_platform(os) == "Darwin" } { vcaps -core }

# Setup 3D viewer
vclear
vinit name=View1 w=512 h=512
vglinfo
vvbo 0
vsetdispmode 1

# Setup view parameters
vcamera -persp
vviewparams -scale 18 -eye 44.49 -0.15 33.93 -at -14.20 -0.15 1.87 -up -0.48 0.00 0.88

# Load the model from disk
puts "Importing shape..."
restore $aBallPath ball

# Tessellate the model
incmesh ball 0.01

# Display the model and assign material
vdisplay -noupdate ball
vsetmaterial -noupdate ball glass

# Create a sphere inside the model
psphere s 8
incmesh s 0.01
vdisplay -noupdate s
vsetlocation -noupdate s 0 0 13
vsetmaterial -noupdate s plaster

# Create chessboard-style floor
box tile 10 10 0.1
eval compound [lrepeat 144 tile] tiles
explode tiles
for {set i 0} {$i < 12} {incr i} {
  for {set j 1} {$j <= 12} {incr j} {
    ttranslate tiles_[expr 12 * $i + $j] [expr $i * 10 - 90] [expr $j * 10 - 70] -0.15
    vdisplay -noupdate tiles_[expr 12 * $i + $j]

    vsetmaterial -noupdate tiles_[expr 12 * $i + $j] plaster

    if {($i + $j) % 2 == 0} {
      vbsdf tiles_[expr 12 * $i + $j] -kd 0.85
    } else {
      vbsdf tiles_[expr 12 * $i + $j] -kd 0.45
    }
  }
}

# Configure light sources
vlight -change 0 -headLight 0
vlight -change 0 -direction -0.25 -1 -1
vlight -change 0 -smoothAngle 17
vlight -change 0 -intensity 10.0

# Load environment map
vtextureenv on 1

puts "Trying path tracing mode..."
vrenderparams -ray -gi -rayDepth 10

# Start progressive refinement mode
#vprogressive

puts "Make several path tracing iterations to refine the picture, please wait..."
vfps 100
puts "Done. To improve the image further, or after view manipulations, give command:"
puts "vfps \[nb_iteratons\] or vrepaint -continuous"