0030953: Data Exchange - implement export of mesh data into glTF 2.0 format
[occt.git] / tests / v3d / glsl / pbr_spheres
1 puts "========"
2 puts "0030700: Visualization, TKOpenGl - support PBR Metallic-Roughness shading model"
3 puts "Spheres grid with different roughness values"
4 puts "========"
5
6 pload XDE OCAF MODELING VISUALIZATION
7 psphere s 0.35
8
9 catch { Close D }
10 XNewDoc D
11
12 # grid of spheres
13 set THE_UPPER 6
14 foreach i [list 0 3] {
15   set aPrefix ""
16   set aColor "GRAY80"
17   if { $i != 0 } {
18     set aPrefix "g_";
19     set aColor "CCB11D"
20   }
21   set aColShapes {}
22   for { set m 0 } { $m <= $THE_UPPER } { incr m } {
23     set aRowShapes {}
24     for { set r 0 } { $r <= $THE_UPPER } { incr r } {
25       set aName ${aPrefix}m${m}r${r}
26       copy s $aName
27       lappend aRowShapes $aName
28       ttranslate $aName ${r} ${i} ${m}
29     }
30     set aName ${aPrefix}m${m}
31     compound {*}$aRowShapes $aName
32     lappend aColShapes $aName
33   }
34   set aName ${aPrefix}spheres
35   compound {*}$aColShapes $aName
36   set aLabName "Gray Spheres"
37   if { $i != 0 } { set aLabName "Golden Spheres" }
38   set aLabComp [XAddShape D $aName 0]
39   SetName D $aLabComp $aLabName
40
41   for { set m 0 } { $m <= $THE_UPPER } { incr m } {
42     set aMet [expr 100 * ${m}/$THE_UPPER]
43     set aName ${aPrefix}m${m}
44     XAddComponent D $aLabComp $aName
45     set aLabCompCol [XFindShape D $aName]
46     SetName D $aLabCompCol "${aPrefix}m${aMet}%"
47     SetName D {*}[XFindComponent D $aName] "${aPrefix}m${aMet}%"
48     for { set r 0 } { $r <= $THE_UPPER } { incr r } {
49       set aRoug [expr 100 * ${r}/$THE_UPPER]
50       set aName ${aPrefix}m${m}r${r}
51       XAddComponent D $aLabCompCol $aName
52       set aLab [XFindComponent D $aName]
53       SetName D {*}$aLab "${aPrefix}m${aMet}%_r${aRoug}%"
54       XAddVisMaterial D $aName -baseColor $aColor -metallic ${m}/$THE_UPPER -roughness ${r}/$THE_UPPER
55       XSetVisMaterial D {*}$aLab $aName
56     }
57   }
58 }
59 set aLab [XFindShape D s]
60 SetName D {*}$aLab "Sphere"
61
62 XGetAllVisMaterials D
63
64 # labels
65 text2brep tm  "Metal"     -plane 0 -1 0 0 0 -1 -height 0.5 -pos -0.5 0  6.5 -halign left  -valign top -font monospace
66 text2brep 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
67 text2brep ts  "Smooth"    -plane 0 -1 0 1 0  0 -height 0.5 -pos -0.5 0 -0.5 -halign left  -valign top -font monospace
68 text2brep tr  "Rough"     -plane 0 -1 0 1 0  0 -height 0.5 -pos  6.5 0 -0.5 -halign right -valign top -font monospace
69 compound tm tnm ts tr labs
70 set aLab [XAddShape D labs 0]
71 SetName D $aLab "Labels"
72 XAddComponent D $aLab tm
73 XAddComponent D $aLab tnm
74 XAddComponent D $aLab ts
75 XAddComponent D $aLab tr
76 SetName D {*}[XFindComponent D tm]  "Metal"
77 SetName D    [XFindShape     D tm]  "Metal"
78 SetName D {*}[XFindComponent D tnm] "Non-metal"
79 SetName D    [XFindShape     D tnm] "Non-metal"
80 SetName D {*}[XFindComponent D ts]  "Smooth"
81 SetName D    [XFindShape     D ts]  "Smooth"
82 SetName D {*}[XFindComponent D tr]  "Rough"
83 SetName D    [XFindShape     D tr]  "Rough"
84
85 vclear
86 vinit View1 -width 768 -height 768
87 vfront
88 vrenderparams -shadingModel PBR
89 vlight -change 0 -intensity 2.5
90 XDisplay -dispMode 1 D
91 vcamera -ortho
92 vfit
93 vlight -change 1 -intensity 0.0001
94 vdump $::imagedir/${::casename}_ortho0.png
95 vlight -change 1 -intensity 0.3
96 vdump $::imagedir/${::casename}_ortho30.png
97 vcamera -persp
98 vfit
99 vlight -change 1 -intensity 0.0001
100 vdump $::imagedir/${::casename}_persp0.png
101 vlight -change 1 -intensity 0.3
102 vdump $::imagedir/${::casename}_persp30.png
103
104 set aCubeMap [locate_data_file Circus_CubeMap_V.png]
105 vlight -change 1 -intensity 1
106 vbackground -cubemap $aCubeMap
107 vcamera -ortho
108 vdump $::imagedir/${::casename}_orthoenv.png
109 vcamera -persp
110 vdump $::imagedir/${::casename}_perspenv.png