File: pathtrace_cube.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 (85 lines) | stat: -rw-r--r-- 2,381 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
80
81
82
83
84
85
# Script demonstrating Global illumination effects using non-interactive 
# path tracing rendering engine in 3d view

#Category: Visualization
#Title: Path tracing - Cube

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

# setup 3D viewer content
vclear
vinit name=View1 w=512 h=512
vglinfo

# setup light sources
vlight -clear
vlight -add POSITIONAL -headLight 0 -pos 0.5 0.5 0.85 -smoothRadius 0.06 -intensity 30.0 -name pntlight

vvbo 0
vsetdispmode 1
vcamera -persp

# setup outer box
box b 1 1 1 
explode b FACE 
vdisplay -noupdate b_1 b_2 b_3 b_5 b_6
vlocation -noupdate b_1 -setLocation  1  0  0
vlocation -noupdate b_2 -setLocation -1  0  0
vlocation -noupdate b_3 -setLocation  0  1  0
vlocation -noupdate b_5 -setLocation  0  0  1
vlocation -noupdate b_6 -setLocation  0  0 -1

vsetmaterial -noupdate b_1 plastic
vsetmaterial -noupdate b_2 plastic
vsetmaterial -noupdate b_3 plastic
vsetmaterial -noupdate b_5 plastic
vsetmaterial -noupdate b_6 plastic
vbsdf b_1 -kd 1 0.3 0.3 -ks 0
vbsdf b_2 -kd 0.3 0.5 1 -ks 0
vbsdf b_3 -kd 1 -ks 0
vbsdf b_5 -kd 1 -ks 0
vbsdf b_6 -kd 1 -ks 0

vfront
vfit

# setup first inner sphere
psphere s 0.2
vdisplay     -noupdate s
vlocation    -noupdate s -setLocation 0.21 0.3 0.2
vsetmaterial -noupdate s glass
vbsdf s -absorpColor 0.8 0.8 1.0
vbsdf s -absorpCoeff 6

# setup first inner box
box c 0.3 0.3 0.2
vdisplay     -noupdate c
vlocation    -noupdate c -reset -rotate 0 0 0 0 0 1 -30 -translate 0.55 0.3 0.0
vsetmaterial -noupdate c plastic
vbsdf c -kd 1.0 0.8 0.2 -ks 0.3 -n

# setup second inner box
box g 0.15 0.15 0.3
vdisplay     -noupdate g
vlocation    -noupdate g -reset -rotate 0 0 0 0 0 1 10 -translate 0.7 0.25 0.2
vsetmaterial -noupdate g glass
vbsdf g -absorpColor 0.8 1.0 0.8
vbsdf g -absorpCoeff 6

# setup second inner sphere
psphere r 0.1
vdisplay -noupdate r
vsetmaterial -noupdate r plastic
vbsdf r -kd 0.5 0.9 0.3 -ks 0.3 -baseRoughness 0.0 -n
vbsdf r -baseFresnel Constant 1.0
vlocation r -setLocation 0.5 0.65 0.1

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

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"