sourcelibs/Glass/demos/cap-convergence.xtl
1⍝!/usr/bin/env xetal
2⍝ Scene creates named arrays; Glass validates their animated world geometry.
3"sc:" u̲se< "Scene"
4"gl:" u̲se< "Glass"
5"rt:" u̲se< "RayTrace"
6"demo" ˢᶜs̲cene2< "sphere ball center 0 0 0 radius 1 material glass\nfloor ground origin -4 -1.5 -4 u 0 0 8 v 8 0 0 material gray\ndielectric glass color 1 1 1 transmission 1 ior 1.5 absorption .2 .05 .1\nmaterial gray color .4 .4 .4 reflection .2\nlight key position 3 5 4 color 80 80 80\ncamera eye 0 .2 5 target 0 0 0 up 0 1 0 fov .55"
7triangles ← ((demotriangles ˢᶜa̲pplyGroups demogroupids) demotransforms)
8spheres ← ((demospheres ˢᶜa̲pplySphereGroups demospheregroupids) demotransforms)
9geometry ← (triangles, spheres)
10links ← (demotriangleids, demosphereids, demotriangleobjectids, demosphereobjectids, demomaterialids, demospherematerialids)
11shading ← (demomaterials, demomaterialkind, demooptics, demoemission, demolights)
12scene ← (geometry ᵍˡp̲reflight links) shading
13clip ← 0.00001 100.0 1e-10 0.000001
14environment ← 2 3 r̲eshape 0.03 0.03 0.03 1.0 0.8 0.6
15origins ← democamera ʳᵗo̲rigins 48
16directions ← ((democamera ʳᵗr̲ays 8 6) r̲ange 48)
17mediumids ← scene ᵍˡm̲ediums origins
18sampleids ← (r̲ange 48) − 1
19ᵘt̲race ← { cap → (((((((scene ᵍˡt̲race clip) environment) origins) directions) mediumids) sampleids) 123 c̲at cap) }
20ᵘm̲ean ← { cap → (color, _, _, _, _, _, _, _) ← ᵘt̲race cap◆ ('+ r̲/ r̲avel color) ÷ 144.0 }
21ᵘa̲ctive ← { cap → (_, _, _, _, _, active, _, _) ← ᵘt̲race cap◆ '+ r̲/ active }
22"Interaction caps:"
231 2 4 8 16
24"Mean linear RGB component, same sample paths at each cap:"
25'{ cap → ᵘm̲ean cap } e̲ach 1 2 4 8 16
26"Unresolved active paths at each cap:"
27'{ cap → ᵘa̲ctive cap } e̲ach 1 2 4 8 16
28(color, _, _, _, _, _, _, _) ← ᵘt̲race 16
29"Eight by six linear luminance, no tone mapping:"
306 8 r̲eshape '+ r̲/₂ color × 48 3 r̲eshape 0.2126 0.7152 0.0722
31"Glass blocks point-light shadows; this diagnostic does not compute caustics."
32
33⍝ A colored strip behind the sphere makes refraction visible.
34stripe ← ˢᶜr̲ectangle 3 3 r̲eshape -0.35 -1.1 -2.0 0.7 0.0 0.0 0.0 2.2 0.0
35imageLinks ← (demotriangleids c̲at 4 5, demosphereids, demotriangleobjectids c̲at 0 0, demosphereobjectids, demomaterialids c̲at 3 3, demospherematerialids)
36imageShading ← (demomaterials c̲at 1 4 r̲eshape 0.8 0.2 0.05 0.0, demomaterialkind c̲at 0, demooptics c̲at 1 5 r̲eshape 0.0 1.0 0.0 0.0 0.0, demoemission c̲at 1 3 r̲eshape 0.0, demolights)
37imageWorld ← ((triangles c̲at stripe, spheres) ᵍˡp̲reflight imageLinks) imageShading
38size ← 64 48
39spp ← 2
40pixelcount ← '× r̲/ size
41n ← pixelcount × spp
42pixelids ← 1 + ((r̲ange n) − 1) d̲iv spp
43imageOrigins ← democamera ʳᵗo̲rigins n
44imageDirections ← ((democamera ʳᵗr̲ays size) pixelids)
45imageMedium ← imageWorld ᵍˡm̲ediums imageOrigins
46imageColor ← (((((((imageWorld ᵍˡr̲ender clip) environment) imageOrigins) imageDirections) imageMedium) (r̲ange n) − 1) 123 16)
47image ← ('+ r̲/₂ (pixelcount c̲at spp c̲at 3) r̲eshape imageColor) ÷ f̲loat spp
48"Glass refraction of the orange strip, absorption, shadows and reflection."
49picture ← size ʳᵗs̲how! 1.0 ʳᵗs̲rgb image
ˢᶜs̲cene2< expands to
demotriangles ← 2 3 3 r̲eshape -4.0 -1.5 -4.0 -4.0 -1.5 4.0 4.0 -1.5 4.0 -4.0 -1.5 -4.0 4.0 -1.5 4.0 4.0 -1.5 -4.0 demomaterialids ← 2 r̲eshape 2 2 demogroupids ← 2 r̲eshape 1 1 demomaterials ← 2 4 r̲eshape 1.0 1.0 1.0 0.0 0.4 0.4 0.4 0.2 demotransforms ← 1 4 4 r̲eshape 1.0 0.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 0.0 1.0 demopivots ← 1 3 r̲eshape 0.0 0.0 0.0 democamera ← 10 r̲eshape 0.0 0.2 5.0 0.0 0.0 0.0 0.0 1.0 0.0 0.55 demolights ← 1 6 r̲eshape 3.0 5.0 4.0 80.0 80.0 80.0 demotriangleids ← 2 r̲eshape 2 3 demosphereids ← 1 r̲eshape 1 demotriangleobjectids ← 2 r̲eshape 0 0 demosphereobjectids ← 1 r̲eshape 1 demospherematerialids ← 1 r̲eshape 1 demospheregroupids ← 1 r̲eshape 1 demosceneversion ← 2 demolens ← 2 r̲eshape 0.0 1.0 demoemitters ← 0 3 3 r̲eshape 0.0 demoemitterradiance ← 0 3 r̲eshape 0.0 demospheres ← 1 4 r̲eshape 0.0 0.0 0.0 1.0 demomaterialkind ← 2 r̲eshape 1 0 demooptics ← 2 5 r̲eshape 1.0 1.5 0.2 0.05 0.1 0.0 1.0 0.0 0.0 0.0 demoemission ← 2 3 r̲eshape 0.0 0.0 0.0 0.0 0.0 0.0