sourcelibs/Glass/demos/example.xtl

1⍝!/usr/bin/env xetal 2⍝ All sample generation, camera rays and transport stay in ordinary X_eTaL. 3"sc:" u̲se< "Scene" 4"rt:" u̲se< "RayTrace" 5"gl:" u̲se< "Glass" 6"r:" u̲se< "Random" 7"demo" ˢᶜs̲cene2< "lens aperture .08 focus 5\nfloor ground origin -3 -1 -3 u 0 0 6 v 6 0 0 material gray\nsphere ball center 0 0 0 radius .7 material glass\nemitter panel origin -1 2.5 -1 u 2 0 0 v 0 0 2 radiance 12 10 8\nmaterial gray color .5 .5 .5 reflection .15\ndielectric glass color 1 1 1 transmission 1 ior 1.5 absorption .05 .1 .15\ncamera eye 0 .5 5 target 0 0 0 up 0 1 0 fov .9"
ˢᶜs̲cene2< expands to
demotriangles ← 4 3 3 r̲eshape -3.0 -1.0 -3.0 -3.0 -1.0 3.0 3.0 -1.0 3.0 -3.0 -1.0 -3.0 3.0 -1.0 3.0 3.0 -1.0 -3.0 -1.0 2.5 -1.0 1.0 2.5 -1.0 1.0 2.5 1.0 -1.0 2.5 -1.0 1.0 2.5 1.0 -1.0 2.5 1.0
demomaterialids ← 4 r̲eshape 1 1 3 3
demogroupids ← 4 r̲eshape 1 1 1 1
demomaterials ← 3 4 r̲eshape 0.5 0.5 0.5 0.15 1.0 1.0 1.0 0.0 0.0 0.0 0.0 0.0
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.5 5.0 0.0 0.0 0.0 0.0 1.0 0.0 0.9
demolights ← 0 6 r̲eshape 0.0
demotriangleids ← 4 r̲eshape 1 2 4 5
demosphereids ← 1 r̲eshape 3
demotriangleobjectids ← 4 r̲eshape 0 0 0 0
demosphereobjectids ← 1 r̲eshape 2
demospherematerialids ← 1 r̲eshape 2
demospheregroupids ← 1 r̲eshape 1
demosceneversion ← 2
demolens ← 2 r̲eshape 0.08 5.0
demoemitters ← 1 3 3 r̲eshape -1.0 2.5 -1.0 2.0 0.0 0.0 0.0 0.0 2.0
demoemitterradiance ← 1 3 r̲eshape 12.0 10.0 8.0
demospheres ← 1 4 r̲eshape 0.0 0.0 0.0 0.7
demomaterialkind ← 3 r̲eshape 0 1 0
demooptics ← 3 5 r̲eshape 0.0 1.0 0.0 0.0 0.0 1.0 1.5 0.05 0.1 0.15 0.0 1.0 0.0 0.0 0.0
demoemission ← 3 3 r̲eshape 0.0 0.0 0.0 0.0 0.0 0.0 12.0 10.0 8.0
8world ← ((demotriangles, demospheres) ᵍˡp̲reflight (demotriangleids, demosphereids, demotriangleobjectids, demosphereobjectids, demomaterialids, demospherematerialids)) (demomaterials, demomaterialkind, demooptics, demoemission, demolights) 9area ← (world ᵍˡp̲reflightArea demoemitters) demoemitterradiance 10size ← 8 6 11⍝ Small interactive workload; the published reference is rendered separately. 12spp ← 1 13pixelcount ← '× r̲/ size 14n ← pixelcount × spp 15pixels ← ((r̲ange n) − 1) d̲iv spp 16samples ← ((r̲ange n) − 1) m̲od spp 17identities ← o̲\ ((1 c̲at n) r̲eshape pixels) c̲at (1 c̲at n) r̲eshape samples 18ᵘc̲ounters ← { dimension → 19 o̲\ (o̲\ identities) c̲at ((1 c̲at n) r̲eshape 4294967295) c̲at (1 c̲at n) r̲eshape dimension 20} 21ᵘc̲olumns ← { x y → o̲\ ((1 c̲at n) r̲eshape x) c̲at (1 c̲at n) r̲eshape y } 22film ← (123 ʳs̲amples ᵘc̲ounters 0) ᵘc̲olumns 123 ʳs̲amples ᵘc̲ounters 1 23disk ← ʳd̲isk (123 ʳs̲amples ᵘc̲ounters 2) ᵘc̲olumns 123 ʳs̲amples ᵘc̲ounters 3 24pinhole ← (((democamera ʳᵗr̲aysAt size) pixels + 1) film) 25(origins, directions) ← (((democamera ʳᵗl̲ensRays demolens) pinhole) disk) 26medium ← world ᵍˡm̲ediums origins 27(color, _, _, _, _, active, counts, clipped) ← (((((((area ᵍˡt̲raceArea 0.00001 100.0 1e-10 0.000001) 2 3 r̲eshape 0.0 0.0 0.0 0.1 0.15 0.2) origins) directions) medium) identities) 123 4) 28image ← ('+ r̲/₂ (pixelcount c̲at spp c̲at 3) r̲eshape color) ÷ f̲loat spp 29"Thin lens, a glass sphere, a visible bright panel and soft shadows." 30picture ← size ʳᵗs̲how! 1.0 ʳᵗs̲rgb image 31"Unresolved paths and clipped interior paths:" 32('+ r̲/ active) c̲at '+ r̲/ clipped