sourcelibs/RayTrace/demos/diagnostic.xtl

1⍝!/usr/bin/env xetal 2⍝ A tiny two-material tile: opaque orange and a partly reflective blue. 3⍝ The host may encode these pixels; tracing and display conversion are X_eTaL. 4"rt:" u̲se< "RayTrace" 5clip ← 1e-6 100.0 1e-10 1e-5 6camera ← 0.0 0.0 3.0 0.0 0.0 0.0 0.0 1.0 0.0 0.9 7triangles ← 2 3 3 r̲eshape -1.0 -1.0 0.0 1.0 -1.0 0.0 1.0 1.0 0.0 -1.0 -1.0 0.0 1.0 1.0 0.0 -1.0 1.0 0.0 8materialids ← 1 2 9materials ← 2 4 r̲eshape 0.8 0.3 0.1 0.0 0.1 0.3 0.8 0.35 10lights ← 1 6 r̲eshape 0.0 1.0 3.0 30.0 30.0 30.0 11environment ← 2 3 r̲eshape 0.05 0.05 0.05 0.01 0.02 0.04 12ᵘo̲rigins ← { pixels → camera ʳᵗo̲rigins t̲ally pixels } 13ᵘd̲irections ← { pixels → ((camera ʳᵗr̲ays 4 4) pixels) } 14ᵘp̲ixels ← { pixels → 15 (((((((clip ʳᵗr̲ender triangles) materialids) materials) lights) environment) ᵘo̲rigins pixels) ᵘd̲irections pixels) 16} 17⍝ Row-major triangle IDs (zero is background), then raw linear RGB. 184 4 r̲eshape (((clip ʳᵗn̲earest triangles) ᵘo̲rigins r̲ange 16) ᵘd̲irections r̲ange 16) 19ᵘp̲ixels r̲ange 16 20⍝ Exposed sRGB Float values before a host rounds to TIFF channel integers. 211.0 ʳᵗs̲rgb ᵘp̲ixels r̲ange 16 22 23⍝ A rendered 3D scene, using the same opaque lighting/reflection functions. 24"sc:" u̲se< "Scene" 25"v:" u̲se< "Vector3" 26ᵘm̲ove ← { offset mesh → 27 (s̲hape mesh) r̲eshape offset ᵛt̲ranslate ((3 × t̲ally mesh) c̲at 3) r̲eshape mesh 28} 29box ← -1.0 -0.2 0.2 ᵘm̲ove ˢᶜb̲ox 1.1 1.1 1.1 30crystal ← 0.9 0.05 -0.1 ᵘm̲ove ˢᶜo̲ctahedron 0.7 0.85 0.7 31floor ← ˢᶜr̲ectangle 3 3 r̲eshape -4.0 -0.8 -4.0 0.0 0.0 8.0 8.0 0.0 0.0 32sceneMesh ← box c̲at crystal c̲at floor 33sceneIds ← (12 r̲eshape 1) c̲at (8 r̲eshape 2) c̲at 2 r̲eshape 3 34sceneMaterials ← 3 4 r̲eshape 0.8 0.25 0.06 0.1 0.05 0.25 0.85 0.45 0.18 0.2 0.24 0.4 35sceneLight ← 1 6 r̲eshape -3.0 5.0 3.0 220.0 200.0 170.0 36sceneCamera ← 3.0 2.0 5.0 -0.1 -0.1 0.0 0.0 1.0 0.0 0.62 37size ← 32 24 38⍝ Small interactive workload; the published reference is rendered separately. 39sceneOrigins ← sceneCamera ʳᵗo̲rigins '× r̲/ size 40sceneDirections ← ((sceneCamera ʳᵗr̲ays size) r̲ange '× r̲/ size) 41sceneColor ← (((((((clip ʳᵗr̲ender sceneMesh) sceneIds) sceneMaterials) sceneLight) environment) sceneOrigins) sceneDirections) 42"Orange box, blue crystal, hard shadows and reflected geometry." 43picture ← size ʳᵗs̲how! 1.5 ʳᵗs̲rgb sceneColor