0031999: Tests - request Core Profile on macOS for Ray-Tracing tests
[occt.git] / samples / tcl / vis_pbr_spheres.tcl
CommitLineData
89d855ba 1# Script demonstrating PBR metallic-roughness material properties
2#Category: Visualization
3#Title: PBR metallic-rougness spheres
4
5pload XDE OCAF MODELING VISUALIZATION
6psphere s 0.35
7
8catch { Close D }
9XNewDoc D
10
11# grid of spheres
12set THE_UPPER 6
13foreach i [list 0 3] {
14 set aPrefix ""
15 set aColor "GRAY80"
16 if { $i != 0 } {
17 set aPrefix "g_";
18 set aColor "CCB11D"
19 }
20 set aColShapes {}
21 for { set m 0 } { $m <= $THE_UPPER } { incr m } {
22 set aRowShapes {}
23 for { set r 0 } { $r <= $THE_UPPER } { incr r } {
24 set aName ${aPrefix}m${m}r${r}
25 copy s $aName
26 lappend aRowShapes $aName
27 ttranslate $aName ${r} ${i} ${m}
28 }
29 set aName ${aPrefix}m${m}
30 compound {*}$aRowShapes $aName
31 lappend aColShapes $aName
32 }
33 set aName ${aPrefix}spheres
34 compound {*}$aColShapes $aName
35 set aLabName "Gray Spheres"
36 if { $i != 0 } { set aLabName "Golden Spheres" }
37 set aLabComp [XAddShape D $aName 0]
38 SetName D $aLabComp $aLabName
39
40 for { set m 0 } { $m <= $THE_UPPER } { incr m } {
41 set aMet [expr 100 * ${m}/$THE_UPPER]
42 set aName ${aPrefix}m${m}
43 XAddComponent D $aLabComp $aName
44 set aLabCompCol [XFindShape D $aName]
45 SetName D $aLabCompCol "${aPrefix}m${aMet}%"
46 SetName D {*}[XFindComponent D $aName] "${aPrefix}m${aMet}%"
47 for { set r 0 } { $r <= $THE_UPPER } { incr r } {
48 set aRoug [expr 100 * ${r}/$THE_UPPER]
49 set aName ${aPrefix}m${m}r${r}
50 XAddComponent D $aLabCompCol $aName
51 set aLab [XFindComponent D $aName]
52 SetName D {*}$aLab "${aPrefix}m${aMet}%_r${aRoug}%"
53 XAddVisMaterial D $aName -baseColor $aColor -metallic ${m}/$THE_UPPER -roughness ${r}/$THE_UPPER
54 XSetVisMaterial D {*}$aLab $aName
55 }
56 }
57}
58set aLab [XFindShape D s]
59SetName D {*}$aLab "Sphere"
60
61XGetAllVisMaterials D
62
63# labels
64text2brep tm "Metal" -plane 0 -1 0 0 0 -1 -height 0.5 -pos -0.5 0 6.5 -halign left -valign top -font monospace
65text2brep tnm "Non-metal" -plane 0 -1 0 0 0 -1 -height 0.5 -pos -0.5 0 -0.5 -halign right -valign top -font monospace
66text2brep ts "Smooth" -plane 0 -1 0 1 0 0 -height 0.5 -pos -0.5 0 -0.5 -halign left -valign top -font monospace
67text2brep tr "Rough" -plane 0 -1 0 1 0 0 -height 0.5 -pos 6.5 0 -0.5 -halign right -valign top -font monospace
68compound tm tnm ts tr labs
69set aLab [XAddShape D labs 0]
70SetName D $aLab "Labels"
71XAddComponent D $aLab tm
72XAddComponent D $aLab tnm
73XAddComponent D $aLab ts
74XAddComponent D $aLab tr
75SetName D {*}[XFindComponent D tm] "Metal"
76SetName D [XFindShape D tm] "Metal"
77SetName D {*}[XFindComponent D tnm] "Non-metal"
78SetName D [XFindShape D tnm] "Non-metal"
79SetName D {*}[XFindComponent D ts] "Smooth"
80SetName D [XFindShape D ts] "Smooth"
81SetName D {*}[XFindComponent D tr] "Rough"
82SetName D [XFindShape D tr] "Rough"
83
ba562b2b 84# Ray-Tracing doesn't work with Compatible Profile on macOS
85if { $::tcl_platform(os) == "Darwin" } { vcaps -core }
86
89d855ba 87vclear
88vinit View1 -width 768 -height 768
89vfront
90vrenderparams -shadingModel PBR
91vlight -change 0 -intensity 2.5
92XDisplay -dispMode 1 D
93vcamera -ortho
94vfit