ATTENTION: default value of option vblank_mode overridden by environment. GLSL source for vertex shader 1: #version 150 core #line 74 #define SHADOWS #define RECURSION const float INF=9999.9; const float EPSILON = 0.00001; uniform vec3 cameraPos; uniform mat3 rot3; uniform vec3 lightPos; uniform vec4 backgroundColor; uniform int emitNoMore; in vec4 pos; in vec4 orig_t; in vec4 dir_idx; in vec4 uv_state; // uv_state.z = state // uv_state.w = type (ray generation) //int state // inFB // 0: generation of ray dirs needed // 1: do not generate ray dirs, keep in GS, intersect, not in FB // 3: cull in next GS, already in FB //int type // isShadow // -1: not shadow ray, reflected // 0: not shadow ray, eye ray // 1: shadow ray out vec4 orig_t1; out vec4 dir_idx1; out vec4 uv_state1; //---------------------------------------------------------------- struct Ray { vec3 orig; vec3 dir; }; struct Sphere { vec3 c; float r; }; struct Isec { float t; int idx; vec3 hit; vec3 n; }; const Sphere spheres0 = Sphere( vec3(0.0,0.0,-1.0), 0.5 ); const Sphere spheres1 = Sphere( vec3(-3.0,0.0,-1.0), 1.5 ); const Sphere spheres2 = Sphere( vec3(0.0,3.0,-1.0), 0.5 ); const Sphere spheres3 = Sphere( vec3(2.0,0.0,-1.0), 1.0 ); const Sphere spheres4 = Sphere( vec3(0.0,-11.0,-1.0), 10.0 ); const int nSpheres = 5; const Sphere spheres[5]=Sphere[5](spheres0, spheres1, spheres2, spheres3, spheres4); Isec lookupNormal(const in Ray ray, in Isec isec) { Sphere sph=spheres[isec.idx]; vec3 c = sph.c; float r = sph.r; isec.hit = ray.orig + ray.dir * isec.t; isec.n = (isec.hit - c) / r; return isec; } void intersect(const in Ray ray, const in Sphere sph, const in int idx, inout Isec isec) { // Project both o and the sphere to the plane perpendicular to d // and containing c. Let x be the point where the ray intersects // the plane. If |x-c| < r, the ray intersects the sphere. vec3 o = ray.orig; vec3 d = ray.dir; vec3 n = -d; vec3 c = sph.c; float r = sph.r; float t = dot(c-o,n)/dot(n,d);//ray parameter for point x vec3 x = o+d*t; float e = length(x-c); if (e > r) { // no intersection return; } // Apply Pythagorean theorem on the (intersection,x,c) triangle // to get the distance between c and the intersection. float f = sqrt(r*r - e*e); float dist = t - f; if (dist < 0.0) { // inside the sphere return; } if (dist < EPSILON) return; if (dist > isec.t) return; isec.t = dist; isec.idx = idx; } Isec intersect_spheres(const in Ray ray, const in float max_t /*= INF*/) { Isec nearest; nearest.t = max_t; nearest.idx = -1; intersect(ray, spheres0, 0, nearest); intersect(ray, spheres1, 1, nearest); intersect(ray, spheres2, 2, nearest); intersect(ray, spheres3, 3, nearest); intersect(ray, spheres4, 4, nearest); return nearest; } //--------------------------------------------------------------------- void main() { //inVS(); Ray ray = Ray(orig_t.xyz, dir_idx.xyz); Isec isec = Isec(orig_t.w, int(dir_idx.w), vec3(0,0,0), vec3(0,0,0)); int state = int(uv_state.z); int type = int(uv_state.w); if (state == 0) { // generate eye rays ray = Ray(cameraPos, normalize(vec3(pos.x, pos.y, -1.0) * rot3)); isec.t = INF; isec.idx = -1; state = 1; type = 0; isec = intersect_spheres(ray, isec.t); } #if defined(SHADOWS) || defined(RECURSION) else if (state == 1) { isec = intersect_spheres(ray, isec.t); } #endif //else state == 3 //outVS(); gl_Position = pos; orig_t1.xyz = ray.orig; orig_t1.w = isec.t; dir_idx1.xyz = ray.dir; dir_idx1.w = float(isec.idx); uv_state1.z = float(state); uv_state1.w = float(type); } GLSL IR for shader 1: ( (declare (temporary ) (array Sphere@0x84a2a8c 5) assignment_tmp) (declare (temporary ) int assignment_tmp) (declare (temporary ) Sphere@0x84a2a8c assignment_tmp) (declare (temporary ) Sphere@0x84a2a8c assignment_tmp) (declare (temporary ) Sphere@0x84a2a8c assignment_tmp) (declare (temporary ) Sphere@0x84a2a8c assignment_tmp) (declare (temporary ) Sphere@0x84a2a8c assignment_tmp) (declare (temporary ) float assignment_tmp) (declare (temporary ) float assignment_tmp) (declare (sys ) int gl_InstanceID) (declare (sys ) int gl_VertexID) (declare (shader_out ) (array float 0) gl_ClipDistance) (declare (shader_out ) float gl_PointSize) (declare (shader_out ) vec4 gl_Position) (declare (uniform ) (array vec4 56) gl_CurrentAttribFragMESA) (declare (uniform ) (array vec4 33) gl_CurrentAttribVertMESA) (declare (uniform ) gl_DepthRangeParameters gl_DepthRange) (declare (uniform ) int gl_NumSamples) (declare () int gl_MaxGeometryVaryingComponents) (declare () int gl_MaxGeometryUniformComponents) (declare () int gl_MaxGeometryTotalOutputComponents) (declare () int gl_MaxGeometryOutputVertices) (declare () int gl_MaxGeometryTextureImageUnits) (declare () int gl_MaxFragmentInputComponents) (declare () int gl_MaxGeometryOutputComponents) (declare () int gl_MaxGeometryInputComponents) (declare () int gl_MaxVertexOutputComponents) (declare () int gl_MaxVaryingComponents) (declare () int gl_MaxClipDistances) (declare () int gl_MaxFragmentUniformComponents) (declare () int gl_MaxVaryingFloats) (declare () int gl_MaxVertexUniformComponents) (declare () int gl_MaxDrawBuffers) (declare () int gl_MaxTextureImageUnits) (declare () int gl_MaxCombinedTextureImageUnits) (declare () int gl_MaxVertexTextureImageUnits) (declare () int gl_MaxVertexAttribs) (declare () float INF) (declare () float EPSILON) (declare (uniform ) vec3 cameraPos) (declare (uniform ) mat3 rot3) (declare (uniform ) vec3 lightPos) (declare (uniform ) vec4 backgroundColor) (declare (uniform ) int emitNoMore) (declare (shader_in ) vec4 pos) (declare (shader_in ) vec4 orig_t) (declare (shader_in ) vec4 dir_idx) (declare (shader_in ) vec4 uv_state) (declare (shader_out ) vec4 orig_t1) (declare (shader_out ) vec4 dir_idx1) (declare (shader_out ) vec4 uv_state1) (declare () Sphere@0x84a2a8c spheres0) (declare () Sphere@0x84a2a8c spheres1) (declare () Sphere@0x84a2a8c spheres2) (declare () Sphere@0x84a2a8c spheres3) (declare () Sphere@0x84a2a8c spheres4) (declare () int nSpheres) (declare () (array Sphere@0x84a2a8c 5) spheres) (assign (x) (var_ref INF) (constant float (9999.900391)) ) (assign (x) (var_ref EPSILON) (constant float (0.000010)) ) (assign () (var_ref spheres0) (constant Sphere@0x84a2a8c ((c (constant vec3 (0.000000 0.000000 -1.000000)) )(r (constant float (0.500000)) ))) ) (assign () (var_ref spheres1) (constant Sphere@0x84a2a8c ((c (constant vec3 (-3.000000 0.000000 -1.000000)) )(r (constant float (1.500000)) ))) ) (assign () (var_ref spheres2) (constant Sphere@0x84a2a8c ((c (constant vec3 (0.000000 3.000000 -1.000000)) )(r (constant float (0.500000)) ))) ) (assign () (var_ref spheres3) (constant Sphere@0x84a2a8c ((c (constant vec3 (2.000000 0.000000 -1.000000)) )(r (constant float (1.000000)) ))) ) (assign () (var_ref spheres4) (constant Sphere@0x84a2a8c ((c (constant vec3 (0.000000 -11.000000 -1.000000)) )(r (constant float (10.000000)) ))) ) (assign (x) (var_ref nSpheres) (constant int (5)) ) (assign () (var_ref spheres) (constant (array Sphere@0x84a2a8c 5) ((constant Sphere@0x84a2a8c ((c (constant vec3 (0.000000 0.000000 -1.000000)) )(r (constant float (0.500000)) ))) (constant Sphere@0x84a2a8c ((c (constant vec3 (-3.000000 0.000000 -1.000000)) )(r (constant float (1.500000)) ))) (constant Sphere@0x84a2a8c ((c (constant vec3 (0.000000 3.000000 -1.000000)) )(r (constant float (0.500000)) ))) (constant Sphere@0x84a2a8c ((c (constant vec3 (2.000000 0.000000 -1.000000)) )(r (constant float (1.000000)) ))) (constant Sphere@0x84a2a8c ((c (constant vec3 (0.000000 -11.000000 -1.000000)) )(r (constant float (10.000000)) ))) )) ) (function lookupNormal (signature Isec@0x84a2d44 (parameters (declare (in ) Ray@0x84a2844 ray) (declare (in ) Isec@0x84a2d44 isec) ) ( (declare (temporary ) Sphere@0x84a2a8c assignment_tmp) (assign () (var_ref assignment_tmp) (array_ref (constant (array Sphere@0x84a2a8c 5) ((constant Sphere@0x84a2a8c ((c (constant vec3 (0.000000 0.000000 -1.000000)) )(r (constant float (0.500000)) ))) (constant Sphere@0x84a2a8c ((c (constant vec3 (-3.000000 0.000000 -1.000000)) )(r (constant float (1.500000)) ))) (constant Sphere@0x84a2a8c ((c (constant vec3 (0.000000 3.000000 -1.000000)) )(r (constant float (0.500000)) ))) (constant Sphere@0x84a2a8c ((c (constant vec3 (2.000000 0.000000 -1.000000)) )(r (constant float (1.000000)) ))) (constant Sphere@0x84a2a8c ((c (constant vec3 (0.000000 -11.000000 -1.000000)) )(r (constant float (10.000000)) ))) )) (record_ref (var_ref isec) idx) ) ) (assign (xyz) (record_ref (var_ref isec) hit) (expression vec3 + (record_ref (var_ref ray) orig) (expression vec3 * (record_ref (var_ref ray) dir) (record_ref (var_ref isec) t) ) ) ) (assign (xyz) (record_ref (var_ref isec) n) (expression vec3 / (expression vec3 + (record_ref (var_ref isec) hit) (expression vec3 neg (record_ref (var_ref assignment_tmp) c) ) ) (record_ref (var_ref assignment_tmp) r) ) ) (return (var_ref isec) ) )) ) (function intersect (signature void (parameters (declare (in ) Ray@0x84a2844 ray) (declare (in ) Sphere@0x84a2a8c sph) (declare (in ) int idx) (declare (inout ) Isec@0x84a2d44 isec) ) ( (declare () float t) (declare () float r) (declare () vec3 c) (declare () vec3 n) (declare () vec3 d) (declare () vec3 o) (declare (temporary ) vec3 assignment_tmp) (assign (xyz) (var_ref assignment_tmp) (record_ref (var_ref ray) orig) ) (assign (xyz) (var_ref o) (var_ref assignment_tmp) ) (declare (temporary ) vec3 assignment_tmp@2) (assign (xyz) (var_ref assignment_tmp@2) (record_ref (var_ref ray) dir) ) (assign (xyz) (var_ref d) (var_ref assignment_tmp@2) ) (declare (temporary ) vec3 assignment_tmp@3) (assign (xyz) (var_ref assignment_tmp@3) (expression vec3 neg (var_ref assignment_tmp@2) ) ) (assign (xyz) (var_ref n) (var_ref assignment_tmp@3) ) (declare (temporary ) vec3 assignment_tmp@4) (assign (xyz) (var_ref assignment_tmp@4) (record_ref (var_ref sph) c) ) (assign (xyz) (var_ref c) (var_ref assignment_tmp@4) ) (assign (x) (var_ref r) (record_ref (var_ref sph) r) ) (declare (temporary ) float dot_retval) (call dot (var_ref dot_retval) ((expression vec3 + (var_ref assignment_tmp@4) (expression vec3 neg (var_ref assignment_tmp) ) ) (var_ref assignment_tmp@3) )) (declare (temporary ) float dot_retval@5) (call dot (var_ref dot_retval@5) ((var_ref n) (var_ref d) )) (declare (temporary ) float assignment_tmp@6) (assign (x) (var_ref assignment_tmp@6) (expression float / (var_ref dot_retval) (var_ref dot_retval@5) ) ) (assign (x) (var_ref t) (var_ref assignment_tmp@6) ) (declare (temporary ) float length_retval) (call length (var_ref length_retval) ((expression vec3 + (expression vec3 + (var_ref o) (expression vec3 * (var_ref d) (var_ref assignment_tmp@6) ) ) (expression vec3 neg (var_ref c) ) ) )) (if (expression bool <= (var_ref length_retval) (var_ref r) ) ( (declare (temporary ) float sqrt_retval) (call sqrt (var_ref sqrt_retval) ((expression float + (expression float * (var_ref r) (var_ref r) ) (expression float neg (expression float * (var_ref length_retval) (var_ref length_retval) ) ) ) )) (declare (temporary ) float assignment_tmp@7) (assign (x) (var_ref assignment_tmp@7) (expression float + (var_ref t) (expression float neg (var_ref sqrt_retval) ) ) ) (if (expression bool && (expression bool && (expression bool >= (var_ref assignment_tmp@7) (constant float (0.000000)) ) (expression bool >= (var_ref assignment_tmp@7) (constant float (0.000010)) ) ) (expression bool <= (var_ref assignment_tmp@7) (record_ref (var_ref isec) t) ) ) ( (assign (x) (record_ref (var_ref isec) t) (var_ref assignment_tmp@7) ) (assign (x) (record_ref (var_ref isec) idx) (var_ref idx) ) ) ()) ) ()) )) ) (function dot (signature float (parameters (declare (in ) vec3 x) (declare (in ) vec3 y) ) ( )) ) (function length (signature float (parameters (declare (in ) vec3 x) ) ( )) ) (function sqrt (signature float (parameters (declare (in ) float x) ) ( )) ) (function intersect_spheres (signature Isec@0x84a2d44 (parameters (declare (in ) Ray@0x84a2844 ray) (declare (in ) float max_t) ) ( (declare () Isec@0x84a2d44 nearest) (assign (x) (record_ref (var_ref nearest) t) (var_ref max_t) ) (assign (x) (record_ref (var_ref nearest) idx) (constant int (-1)) ) (call intersect ((var_ref ray) (constant Sphere@0x84a2a8c ((c (constant vec3 (0.000000 0.000000 -1.000000)) )(r (constant float (0.500000)) ))) (constant int (0)) (var_ref nearest) )) (call intersect ((var_ref ray) (constant Sphere@0x84a2a8c ((c (constant vec3 (-3.000000 0.000000 -1.000000)) )(r (constant float (1.500000)) ))) (constant int (1)) (var_ref nearest) )) (call intersect ((var_ref ray) (constant Sphere@0x84a2a8c ((c (constant vec3 (0.000000 3.000000 -1.000000)) )(r (constant float (0.500000)) ))) (constant int (2)) (var_ref nearest) )) (call intersect ((var_ref ray) (constant Sphere@0x84a2a8c ((c (constant vec3 (2.000000 0.000000 -1.000000)) )(r (constant float (1.000000)) ))) (constant int (3)) (var_ref nearest) )) (call intersect ((var_ref ray) (constant Sphere@0x84a2a8c ((c (constant vec3 (0.000000 -11.000000 -1.000000)) )(r (constant float (10.000000)) ))) (constant int (4)) (var_ref nearest) )) (return (var_ref nearest) ) )) ) (function main (signature void (parameters ) ( (declare () int type) (declare () int state) (declare () Isec@0x84a2d44 isec) (declare () Ray@0x84a2844 ray) (declare (temporary ) Ray@0x84a2844 record_ctor) (assign (xyz) (record_ref (var_ref record_ctor) orig) (swiz xyz (var_ref orig_t) )) (assign (xyz) (record_ref (var_ref record_ctor) dir) (swiz xyz (var_ref dir_idx) )) (assign () (var_ref ray) (var_ref record_ctor) ) (declare (temporary ) Isec@0x84a2d44 record_ctor@8) (assign (x) (record_ref (var_ref record_ctor@8) t) (swiz w (var_ref orig_t) )) (assign (x) (record_ref (var_ref record_ctor@8) idx) (expression int f2i (swiz w (var_ref dir_idx) )) ) (assign (xyz) (record_ref (var_ref record_ctor@8) hit) (constant vec3 (0.000000 0.000000 0.000000)) ) (assign (xyz) (record_ref (var_ref record_ctor@8) n) (constant vec3 (0.000000 0.000000 0.000000)) ) (assign () (var_ref isec) (var_ref record_ctor@8) ) (declare (temporary ) int assignment_tmp) (assign (x) (var_ref assignment_tmp) (expression int f2i (swiz z (var_ref uv_state) )) ) (assign (x) (var_ref state) (var_ref assignment_tmp) ) (assign (x) (var_ref type) (expression int f2i (swiz w (var_ref uv_state) )) ) (if (expression bool all_equal (var_ref assignment_tmp) (constant int (0)) ) ( (declare (temporary ) vec3 vec_ctor) (assign (z) (var_ref vec_ctor) (constant float (-1.000000)) ) (assign (x) (var_ref vec_ctor) (swiz x (var_ref pos) )) (assign (y) (var_ref vec_ctor) (swiz y (var_ref pos) )) (declare (temporary ) vec3 normalize_retval) (call normalize (var_ref normalize_retval) ((expression vec3 * (var_ref vec_ctor) (var_ref rot3) ) )) (declare (temporary ) Ray@0x84a2844 record_ctor@9) (assign (xyz) (record_ref (var_ref record_ctor@9) orig) (var_ref cameraPos) ) (assign (xyz) (record_ref (var_ref record_ctor@9) dir) (var_ref normalize_retval) ) (assign () (var_ref ray) (var_ref record_ctor@9) ) (assign (x) (record_ref (var_ref isec) t) (constant float (9999.900391)) ) (assign (x) (record_ref (var_ref isec) idx) (constant int (-1)) ) (assign (x) (var_ref state) (constant int (1)) ) (assign (x) (var_ref type) (constant int (0)) ) (declare (temporary ) Isec@0x84a2d44 intersect_spheres_retval) (call intersect_spheres (var_ref intersect_spheres_retval) ((var_ref record_ctor@9) (record_ref (var_ref isec) t) )) (assign () (var_ref isec) (var_ref intersect_spheres_retval) ) ) ( (if (expression bool all_equal (var_ref state) (constant int (1)) ) ( (declare (temporary ) Isec@0x84a2d44 intersect_spheres_retval@10) (call intersect_spheres (var_ref intersect_spheres_retval@10) ((var_ref ray) (record_ref (var_ref isec) t) )) (assign () (var_ref isec) (var_ref intersect_spheres_retval@10) ) ) ()) )) (assign (xyzw) (var_ref gl_Position) (var_ref pos) ) (assign (xyz) (var_ref orig_t1) (record_ref (var_ref ray) orig) ) (assign (w) (var_ref orig_t1) (record_ref (var_ref isec) t) ) (assign (xyz) (var_ref dir_idx1) (record_ref (var_ref ray) dir) ) (assign (w) (var_ref dir_idx1) (expression float i2f (record_ref (var_ref isec) idx) ) ) (assign (z) (var_ref uv_state1) (expression float i2f (var_ref state) ) ) (assign (w) (var_ref uv_state1) (expression float i2f (var_ref type) ) ) )) ) (function normalize (signature vec3 (parameters (declare (in ) vec3 x) ) ( )) ) ) GLSL source for geometry shader 2: #version 150 core #line 257 layout(points) in; layout(points, max_vertices = 3) out; #define SHADOWS #define RECURSION const float INF=9999.9; const float EPSILON = 0.00001; uniform vec3 cameraPos; uniform mat3 rot3; uniform vec3 lightPos; uniform vec4 backgroundColor; uniform int emitNoMore; //----------------------------------------------------------------------- struct Ray { vec3 orig; vec3 dir; }; struct Sphere { vec3 c; float r; }; struct Isec { float t; int idx; vec3 hit; vec3 n; }; const Sphere spheres0 = Sphere( vec3(0.0,0.0,-1.0), 0.5 ); const Sphere spheres1 = Sphere( vec3(-3.0,0.0,-1.0), 1.5 ); const Sphere spheres2 = Sphere( vec3(0.0,3.0,-1.0), 0.5 ); const Sphere spheres3 = Sphere( vec3(2.0,0.0,-1.0), 1.0 ); const Sphere spheres4 = Sphere( vec3(0.0,-11.0,-1.0), 10.0 ); const int nSpheres = 5; const Sphere spheres[5]=Sphere[5](spheres0, spheres1, spheres2, spheres3, spheres4); Isec lookupNormal(const in Ray ray, in Isec isec) { Sphere sph=spheres[isec.idx]; vec3 c = sph.c; float r = sph.r; isec.hit = ray.orig + ray.dir * isec.t; isec.n = (isec.hit - c) / r; return isec; } in vec4 orig_t1[1]; in vec4 dir_idx1[1]; in vec4 uv_state1[1]; out vec4 orig_t2; out vec4 dir_idx2; out vec4 uv_state2; void main() { //inGS(); Ray ray = Ray(orig_t1[0].xyz, dir_idx1[0].xyz); Isec isec = Isec(orig_t1[0].w, int(dir_idx1[0].w), vec3(0,0,0), vec3(0,0,0)); int state = int(uv_state1[0].z); int type = int(uv_state1[0].w); if (state > 1) return; if (isec.idx == -1) return; // emitPassThrough(); gl_Position = gl_in[0].gl_Position; orig_t2 = orig_t1[0]; dir_idx2 = dir_idx1[0]; uv_state2.xyw= uv_state1[0].xyw; uv_state2.z = 3.0; /*state*/ EmitVertex(); EndPrimitive(); if (type != 0 || emitNoMore>0) return; #if defined(SHADOWS) || defined(RECURSION) isec = lookupNormal(ray, isec); vec3 hitN = isec.n; vec3 hitP = ray.orig + ray.dir*isec.t + hitN*EPSILON; #endif #ifdef SHADOWS vec3 toLight = lightPos - hitP; float lightDist = length(toLight); Ray shadowRay = Ray(hitP, toLight/lightDist); Isec shadowHit = Isec(lightDist, -1, vec3(0,0,0), vec3(0,0,0)); state = 1; type = 1; //emitShadowRay(); gl_Position = gl_in[0].gl_Position; orig_t2.xyz = shadowRay.orig; orig_t2.w = shadowHit.t; dir_idx2.xyz = shadowRay.dir; dir_idx2.w = float(shadowHit.idx); uv_state2.z = float(state); uv_state2.w = float(type); EmitVertex(); EndPrimitive(); #endif #ifdef RECURSION Ray reflRay = Ray(hitP, reflect(ray.dir, hitN)); Isec reflHit = Isec(INF, -1, vec3(0,0,0), vec3(0,0,0)); state = 1; // intersect in next pass, FS discard in this pass type = -1; //emitReflRay(); gl_Position = gl_in[0].gl_Position; orig_t2.xyz = reflRay.orig; orig_t2.w = reflHit.t; dir_idx2.xyz = reflRay.dir; dir_idx2.w = float(reflHit.idx); uv_state2.z = float(state); uv_state2.w = float(type); EmitVertex(); EndPrimitive(); #endif } GLSL IR for shader 2: ( (declare (temporary ) (array Sphere@0x84a2a8c 5) assignment_tmp) (declare (temporary ) int assignment_tmp) (declare (temporary ) Sphere@0x84a2a8c assignment_tmp) (declare (temporary ) Sphere@0x84a2a8c assignment_tmp) (declare (temporary ) Sphere@0x84a2a8c assignment_tmp) (declare (temporary ) Sphere@0x84a2a8c assignment_tmp) (declare (temporary ) Sphere@0x84a2a8c assignment_tmp) (declare (temporary ) float assignment_tmp) (declare (temporary ) float assignment_tmp) (declare (shader_out flat) int gl_PrimitiveID) (declare (shader_in flat) int gl_PrimitiveIDIn) (declare (shader_out ) int gl_Layer) (declare (shader_out ) (array float 0) gl_ClipDistance) (declare (shader_out ) float gl_PointSize) (declare (shader_out ) vec4 gl_Position) (declare (shader_in ) (array gl_PerVertex 1) gl_in) (declare (uniform ) (array vec4 56) gl_CurrentAttribFragMESA) (declare (uniform ) (array vec4 33) gl_CurrentAttribVertMESA) (declare (uniform ) gl_DepthRangeParameters gl_DepthRange) (declare (uniform ) int gl_NumSamples) (declare () int gl_MaxGeometryVaryingComponents) (declare () int gl_MaxGeometryUniformComponents) (declare () int gl_MaxGeometryTotalOutputComponents) (declare () int gl_MaxGeometryOutputVertices) (declare () int gl_MaxGeometryTextureImageUnits) (declare () int gl_MaxFragmentInputComponents) (declare () int gl_MaxGeometryOutputComponents) (declare () int gl_MaxGeometryInputComponents) (declare () int gl_MaxVertexOutputComponents) (declare () int gl_MaxVaryingComponents) (declare () int gl_MaxClipDistances) (declare () int gl_MaxFragmentUniformComponents) (declare () int gl_MaxVaryingFloats) (declare () int gl_MaxVertexUniformComponents) (declare () int gl_MaxDrawBuffers) (declare () int gl_MaxTextureImageUnits) (declare () int gl_MaxCombinedTextureImageUnits) (declare () int gl_MaxVertexTextureImageUnits) (declare () int gl_MaxVertexAttribs) (declare () float INF) (declare () float EPSILON) (declare (uniform ) vec3 cameraPos) (declare (uniform ) mat3 rot3) (declare (uniform ) vec3 lightPos) (declare (uniform ) vec4 backgroundColor) (declare (uniform ) int emitNoMore) (declare () Sphere@0x84a2a8c spheres0) (declare () Sphere@0x84a2a8c spheres1) (declare () Sphere@0x84a2a8c spheres2) (declare () Sphere@0x84a2a8c spheres3) (declare () Sphere@0x84a2a8c spheres4) (declare () int nSpheres) (declare () (array Sphere@0x84a2a8c 5) spheres) (declare (shader_in ) (array vec4 1) orig_t1) (declare (shader_in ) (array vec4 1) dir_idx1) (declare (shader_in ) (array vec4 1) uv_state1) (declare (shader_out ) vec4 orig_t2) (declare (shader_out ) vec4 dir_idx2) (declare (shader_out ) vec4 uv_state2) (assign (x) (var_ref INF) (constant float (9999.900391)) ) (assign (x) (var_ref EPSILON) (constant float (0.000010)) ) (assign () (var_ref spheres0) (constant Sphere@0x84a2a8c ((c (constant vec3 (0.000000 0.000000 -1.000000)) )(r (constant float (0.500000)) ))) ) (assign () (var_ref spheres1) (constant Sphere@0x84a2a8c ((c (constant vec3 (-3.000000 0.000000 -1.000000)) )(r (constant float (1.500000)) ))) ) (assign () (var_ref spheres2) (constant Sphere@0x84a2a8c ((c (constant vec3 (0.000000 3.000000 -1.000000)) )(r (constant float (0.500000)) ))) ) (assign () (var_ref spheres3) (constant Sphere@0x84a2a8c ((c (constant vec3 (2.000000 0.000000 -1.000000)) )(r (constant float (1.000000)) ))) ) (assign () (var_ref spheres4) (constant Sphere@0x84a2a8c ((c (constant vec3 (0.000000 -11.000000 -1.000000)) )(r (constant float (10.000000)) ))) ) (assign (x) (var_ref nSpheres) (constant int (5)) ) (assign () (var_ref spheres) (constant (array Sphere@0x84a2a8c 5) ((constant Sphere@0x84a2a8c ((c (constant vec3 (0.000000 0.000000 -1.000000)) )(r (constant float (0.500000)) ))) (constant Sphere@0x84a2a8c ((c (constant vec3 (-3.000000 0.000000 -1.000000)) )(r (constant float (1.500000)) ))) (constant Sphere@0x84a2a8c ((c (constant vec3 (0.000000 3.000000 -1.000000)) )(r (constant float (0.500000)) ))) (constant Sphere@0x84a2a8c ((c (constant vec3 (2.000000 0.000000 -1.000000)) )(r (constant float (1.000000)) ))) (constant Sphere@0x84a2a8c ((c (constant vec3 (0.000000 -11.000000 -1.000000)) )(r (constant float (10.000000)) ))) )) ) (function lookupNormal (signature Isec@0x84a2d44 (parameters (declare (in ) Ray@0x84a2844 ray) (declare (in ) Isec@0x84a2d44 isec) ) ( (declare (temporary ) Sphere@0x84a2a8c assignment_tmp) (assign () (var_ref assignment_tmp) (array_ref (constant (array Sphere@0x84a2a8c 5) ((constant Sphere@0x84a2a8c ((c (constant vec3 (0.000000 0.000000 -1.000000)) )(r (constant float (0.500000)) ))) (constant Sphere@0x84a2a8c ((c (constant vec3 (-3.000000 0.000000 -1.000000)) )(r (constant float (1.500000)) ))) (constant Sphere@0x84a2a8c ((c (constant vec3 (0.000000 3.000000 -1.000000)) )(r (constant float (0.500000)) ))) (constant Sphere@0x84a2a8c ((c (constant vec3 (2.000000 0.000000 -1.000000)) )(r (constant float (1.000000)) ))) (constant Sphere@0x84a2a8c ((c (constant vec3 (0.000000 -11.000000 -1.000000)) )(r (constant float (10.000000)) ))) )) (record_ref (var_ref isec) idx) ) ) (assign (xyz) (record_ref (var_ref isec) hit) (expression vec3 + (record_ref (var_ref ray) orig) (expression vec3 * (record_ref (var_ref ray) dir) (record_ref (var_ref isec) t) ) ) ) (assign (xyz) (record_ref (var_ref isec) n) (expression vec3 / (expression vec3 + (record_ref (var_ref isec) hit) (expression vec3 neg (record_ref (var_ref assignment_tmp) c) ) ) (record_ref (var_ref assignment_tmp) r) ) ) (return (var_ref isec) ) )) ) (function main (signature void (parameters ) ( (declare () vec3 toLight) (declare () vec3 hitP) (declare () vec3 hitN) (declare () int type) (declare () Isec@0x84a2d44 isec) (declare () Ray@0x84a2844 ray) (declare (temporary ) Ray@0x84a2844 record_ctor) (assign (xyz) (record_ref (var_ref record_ctor) orig) (swiz xyz (array_ref (var_ref orig_t1) (constant int (0)) ) )) (assign (xyz) (record_ref (var_ref record_ctor) dir) (swiz xyz (array_ref (var_ref dir_idx1) (constant int (0)) ) )) (assign () (var_ref ray) (var_ref record_ctor) ) (declare (temporary ) Isec@0x84a2d44 record_ctor@11) (assign (x) (record_ref (var_ref record_ctor@11) t) (swiz w (array_ref (var_ref orig_t1) (constant int (0)) ) )) (assign (x) (record_ref (var_ref record_ctor@11) idx) (expression int f2i (swiz w (array_ref (var_ref dir_idx1) (constant int (0)) ) )) ) (assign (xyz) (record_ref (var_ref record_ctor@11) hit) (constant vec3 (0.000000 0.000000 0.000000)) ) (assign (xyz) (record_ref (var_ref record_ctor@11) n) (constant vec3 (0.000000 0.000000 0.000000)) ) (assign () (var_ref isec) (var_ref record_ctor@11) ) (declare (temporary ) int assignment_tmp) (assign (x) (var_ref assignment_tmp) (expression int f2i (swiz z (array_ref (var_ref uv_state1) (constant int (0)) ) )) ) (assign (x) (var_ref type) (expression int f2i (swiz w (array_ref (var_ref uv_state1) (constant int (0)) ) )) ) (if (expression bool > (var_ref assignment_tmp) (constant int (1)) ) ( (return) ) ()) (if (expression bool all_equal (record_ref (var_ref record_ctor@11) idx) (constant int (-1)) ) ( (return) ) ()) (assign (xyzw) (var_ref gl_Position) (record_ref (array_ref (var_ref gl_in) (constant int (0)) ) gl_Position) ) (assign (xyzw) (var_ref orig_t2) (array_ref (var_ref orig_t1) (constant int (0)) ) ) (assign (xyzw) (var_ref dir_idx2) (array_ref (var_ref dir_idx1) (constant int (0)) ) ) (assign (xyw) (var_ref uv_state2) (swiz xyw (array_ref (var_ref uv_state1) (constant int (0)) ) )) (assign (z) (var_ref uv_state2) (constant float (3.000000)) ) (call EmitVertex ()) (call EndPrimitive ()) (if (expression bool || (expression bool any_nequal (var_ref type) (constant int (0)) ) (expression bool > (var_ref emitNoMore) (constant int (0)) ) ) ( (return) ) ()) (declare (temporary ) Isec@0x84a2d44 lookupNormal_retval) (call lookupNormal (var_ref lookupNormal_retval) ((var_ref ray) (var_ref isec) )) (assign () (var_ref isec) (var_ref lookupNormal_retval) ) (declare (temporary ) vec3 assignment_tmp@12) (assign (xyz) (var_ref assignment_tmp@12) (record_ref (var_ref lookupNormal_retval) n) ) (assign (xyz) (var_ref hitN) (var_ref assignment_tmp@12) ) (declare (temporary ) vec3 assignment_tmp@13) (assign (xyz) (var_ref assignment_tmp@13) (expression vec3 + (expression vec3 + (record_ref (var_ref ray) orig) (expression vec3 * (record_ref (var_ref ray) dir) (record_ref (var_ref lookupNormal_retval) t) ) ) (expression vec3 * (var_ref assignment_tmp@12) (constant float (0.000010)) ) ) ) (assign (xyz) (var_ref hitP) (var_ref assignment_tmp@13) ) (declare (temporary ) vec3 assignment_tmp@14) (assign (xyz) (var_ref assignment_tmp@14) (expression vec3 + (var_ref lightPos) (expression vec3 neg (var_ref assignment_tmp@13) ) ) ) (assign (xyz) (var_ref toLight) (var_ref assignment_tmp@14) ) (declare (temporary ) float length_retval) (call length (var_ref length_retval) ((var_ref assignment_tmp@14) )) (declare (temporary ) Ray@0x84a2844 record_ctor@15) (assign (xyz) (record_ref (var_ref record_ctor@15) orig) (var_ref hitP) ) (assign (xyz) (record_ref (var_ref record_ctor@15) dir) (expression vec3 / (var_ref toLight) (var_ref length_retval) ) ) (declare (temporary ) Isec@0x84a2d44 record_ctor@16) (assign (x) (record_ref (var_ref record_ctor@16) t) (var_ref length_retval) ) (assign (x) (record_ref (var_ref record_ctor@16) idx) (constant int (-1)) ) (assign (xyz) (record_ref (var_ref record_ctor@16) hit) (constant vec3 (0.000000 0.000000 0.000000)) ) (assign (xyz) (record_ref (var_ref record_ctor@16) n) (constant vec3 (0.000000 0.000000 0.000000)) ) (assign (x) (var_ref type) (constant int (1)) ) (assign (xyzw) (var_ref gl_Position) (record_ref (array_ref (var_ref gl_in) (constant int (0)) ) gl_Position) ) (assign (xyz) (var_ref orig_t2) (record_ref (var_ref record_ctor@15) orig) ) (assign (w) (var_ref orig_t2) (record_ref (var_ref record_ctor@16) t) ) (assign (xyz) (var_ref dir_idx2) (record_ref (var_ref record_ctor@15) dir) ) (assign (w) (var_ref dir_idx2) (expression float i2f (record_ref (var_ref record_ctor@16) idx) ) ) (assign (z) (var_ref uv_state2) (constant float (1.000000)) ) (assign (w) (var_ref uv_state2) (constant float (1.000000)) ) (call EmitVertex ()) (call EndPrimitive ()) (declare (temporary ) vec3 reflect_retval) (call reflect (var_ref reflect_retval) ((record_ref (var_ref ray) dir) (var_ref hitN) )) (declare (temporary ) Ray@0x84a2844 record_ctor@17) (assign (xyz) (record_ref (var_ref record_ctor@17) orig) (var_ref hitP) ) (assign (xyz) (record_ref (var_ref record_ctor@17) dir) (var_ref reflect_retval) ) (assign (x) (var_ref type) (constant int (-1)) ) (assign (xyzw) (var_ref gl_Position) (record_ref (array_ref (var_ref gl_in) (constant int (0)) ) gl_Position) ) (assign (xyz) (var_ref orig_t2) (record_ref (var_ref record_ctor@17) orig) ) (assign (w) (var_ref orig_t2) (constant float (9999.900391)) ) (assign (xyz) (var_ref dir_idx2) (record_ref (var_ref record_ctor@17) dir) ) (assign (w) (var_ref dir_idx2) (constant float (-1.000000)) ) (assign (z) (var_ref uv_state2) (constant float (1.000000)) ) (assign (w) (var_ref uv_state2) (constant float (-1.000000)) ) (call EmitVertex ()) (call EndPrimitive ()) )) ) (function EmitVertex (signature void (parameters ) ( )) ) (function EndPrimitive (signature void (parameters ) ( )) ) (function length (signature float (parameters (declare (in ) vec3 x) ) ( )) ) (function reflect (signature vec3 (parameters (declare (in ) vec3 I) (declare (in ) vec3 N) ) ( )) ) ) GLSL source for fragment shader 3: #version 150 core #line 397 #define SHADOWS #define RECURSION const float INF=9999.9; const float EPSILON = 0.00001; uniform vec3 cameraPos; uniform mat3 rot3; uniform vec3 lightPos; uniform vec4 backgroundColor; uniform int emitNoMore; out vec4 frag_color; //----------------------------------------------------------------------- struct Ray { vec3 orig; vec3 dir; }; struct Sphere { vec3 c; float r; }; struct Isec { float t; int idx; vec3 hit; vec3 n; }; const Sphere spheres0 = Sphere( vec3(0.0,0.0,-1.0), 0.5 ); const Sphere spheres1 = Sphere( vec3(-3.0,0.0,-1.0), 1.5 ); const Sphere spheres2 = Sphere( vec3(0.0,3.0,-1.0), 0.5 ); const Sphere spheres3 = Sphere( vec3(2.0,0.0,-1.0), 1.0 ); const Sphere spheres4 = Sphere( vec3(0.0,-11.0,-1.0), 10.0 ); const int nSpheres = 5; const Sphere spheres[5]=Sphere[5](spheres0, spheres1, spheres2, spheres3, spheres4); Isec lookupNormal(const in Ray ray, in Isec isec) { Sphere sph=spheres[isec.idx]; vec3 c = sph.c; float r = sph.r; isec.hit = ray.orig + ray.dir * isec.t; isec.n = (isec.hit - c) / r; return isec; } in vec4 orig_t2; in vec4 dir_idx2; in vec4 uv_state2; vec3 idx2color(const in int idx) { vec3 diff; if (idx == 0) diff = vec3(1.0, 0.0, 0.0); else if (idx == 1) diff = vec3(0.0, 1.0, 0.0); else if (idx == 2) diff = vec3(0.0, 0.0, 1.0); else if (idx == 3) diff = vec3(1.0, 1.0, 0.0); else if (idx == 4) diff = vec3(0.7, 0.7, 0.7); return diff; } void main() { Ray ray = Ray(orig_t2.xyz, dir_idx2.xyz); Isec isec = Isec(orig_t2.w, int(dir_idx2.w), vec3(0,0,0), vec3(0,0,0)); int state = int(uv_state2.z); int type = int(uv_state2.w); if (state < 3) { discard; } if (type == 0) { Ray eyeRay = ray; Isec eyeHit = isec; if (eyeHit.idx == -1) { frag_color = vec4(backgroundColor.rgb, 0.0); return; } vec3 eyeHitPosition = eyeRay.orig + eyeRay.dir * eyeHit.t; vec3 lightVec = lightPos - eyeHitPosition; eyeHit = lookupNormal(eyeRay, eyeHit); vec3 N = eyeHit.n; vec3 L = normalize(lightVec); float NdotL = max(dot(N, L), 0.0); vec3 diffuse = idx2color(eyeHit.idx); // material color of the visible point frag_color = vec4(diffuse * NdotL, 1.0); return; } #ifdef SHADOWS if (type > 0) { Isec shadowHit = isec; if (shadowHit.idx == -1) { discard; } frag_color = vec4(-1,-1,-1, 0.0); return; } #endif #ifdef RECURSION // else type < 0 { Ray reflRay = ray; Isec reflHit = isec; if (reflHit.idx == -1) { discard; } vec3 reflHitPosition = reflRay.orig + reflRay.dir * reflHit.t; vec3 lightVec = lightPos - reflHitPosition; reflHit = lookupNormal(reflRay, reflHit); vec3 N = reflHit.n; vec3 L = normalize(lightVec); float NdotL = max(dot(N, L), 0.0); vec3 diffuse = idx2color(reflHit.idx); frag_color = vec4(diffuse * NdotL * 0.25, 1.0); // material color of the visible point return; } #endif } GLSL IR for shader 3: ( (declare (temporary ) (array Sphere@0x84a2a8c 5) assignment_tmp) (declare (temporary ) int assignment_tmp) (declare (temporary ) Sphere@0x84a2a8c assignment_tmp) (declare (temporary ) Sphere@0x84a2a8c assignment_tmp) (declare (temporary ) Sphere@0x84a2a8c assignment_tmp) (declare (temporary ) Sphere@0x84a2a8c assignment_tmp) (declare (temporary ) Sphere@0x84a2a8c assignment_tmp) (declare (temporary ) float assignment_tmp) (declare (temporary ) float assignment_tmp) (declare (shader_out ) float gl_FragDepth) (declare (shader_out ) (array vec4 8) gl_FragData) (declare (shader_out ) vec4 gl_FragColor) (declare (shader_in flat) int gl_PrimitiveID) (declare (shader_in ) vec2 gl_PointCoord) (declare (shader_in ) bool gl_FrontFacing) (declare (shader_in ) vec4 gl_FragCoord) (declare (shader_in ) (array float 0) gl_ClipDistance) (declare (uniform ) (array vec4 56) gl_CurrentAttribFragMESA) (declare (uniform ) (array vec4 33) gl_CurrentAttribVertMESA) (declare (uniform ) gl_DepthRangeParameters gl_DepthRange) (declare (uniform ) int gl_NumSamples) (declare () int gl_MaxGeometryVaryingComponents) (declare () int gl_MaxGeometryUniformComponents) (declare () int gl_MaxGeometryTotalOutputComponents) (declare () int gl_MaxGeometryOutputVertices) (declare () int gl_MaxGeometryTextureImageUnits) (declare () int gl_MaxFragmentInputComponents) (declare () int gl_MaxGeometryOutputComponents) (declare () int gl_MaxGeometryInputComponents) (declare () int gl_MaxVertexOutputComponents) (declare () int gl_MaxVaryingComponents) (declare () int gl_MaxClipDistances) (declare () int gl_MaxFragmentUniformComponents) (declare () int gl_MaxVaryingFloats) (declare () int gl_MaxVertexUniformComponents) (declare () int gl_MaxDrawBuffers) (declare () int gl_MaxTextureImageUnits) (declare () int gl_MaxCombinedTextureImageUnits) (declare () int gl_MaxVertexTextureImageUnits) (declare () int gl_MaxVertexAttribs) (declare () float INF) (declare () float EPSILON) (declare (uniform ) vec3 cameraPos) (declare (uniform ) mat3 rot3) (declare (uniform ) vec3 lightPos) (declare (uniform ) vec4 backgroundColor) (declare (uniform ) int emitNoMore) (declare (shader_out ) vec4 frag_color) (declare () Sphere@0x84a2a8c spheres0) (declare () Sphere@0x84a2a8c spheres1) (declare () Sphere@0x84a2a8c spheres2) (declare () Sphere@0x84a2a8c spheres3) (declare () Sphere@0x84a2a8c spheres4) (declare () int nSpheres) (declare () (array Sphere@0x84a2a8c 5) spheres) (declare (shader_in ) vec4 orig_t2) (declare (shader_in ) vec4 dir_idx2) (declare (shader_in ) vec4 uv_state2) (assign (x) (var_ref INF) (constant float (9999.900391)) ) (assign (x) (var_ref EPSILON) (constant float (0.000010)) ) (assign () (var_ref spheres0) (constant Sphere@0x84a2a8c ((c (constant vec3 (0.000000 0.000000 -1.000000)) )(r (constant float (0.500000)) ))) ) (assign () (var_ref spheres1) (constant Sphere@0x84a2a8c ((c (constant vec3 (-3.000000 0.000000 -1.000000)) )(r (constant float (1.500000)) ))) ) (assign () (var_ref spheres2) (constant Sphere@0x84a2a8c ((c (constant vec3 (0.000000 3.000000 -1.000000)) )(r (constant float (0.500000)) ))) ) (assign () (var_ref spheres3) (constant Sphere@0x84a2a8c ((c (constant vec3 (2.000000 0.000000 -1.000000)) )(r (constant float (1.000000)) ))) ) (assign () (var_ref spheres4) (constant Sphere@0x84a2a8c ((c (constant vec3 (0.000000 -11.000000 -1.000000)) )(r (constant float (10.000000)) ))) ) (assign (x) (var_ref nSpheres) (constant int (5)) ) (assign () (var_ref spheres) (constant (array Sphere@0x84a2a8c 5) ((constant Sphere@0x84a2a8c ((c (constant vec3 (0.000000 0.000000 -1.000000)) )(r (constant float (0.500000)) ))) (constant Sphere@0x84a2a8c ((c (constant vec3 (-3.000000 0.000000 -1.000000)) )(r (constant float (1.500000)) ))) (constant Sphere@0x84a2a8c ((c (constant vec3 (0.000000 3.000000 -1.000000)) )(r (constant float (0.500000)) ))) (constant Sphere@0x84a2a8c ((c (constant vec3 (2.000000 0.000000 -1.000000)) )(r (constant float (1.000000)) ))) (constant Sphere@0x84a2a8c ((c (constant vec3 (0.000000 -11.000000 -1.000000)) )(r (constant float (10.000000)) ))) )) ) (function lookupNormal (signature Isec@0x84a2d44 (parameters (declare (in ) Ray@0x84a2844 ray) (declare (in ) Isec@0x84a2d44 isec) ) ( (declare (temporary ) Sphere@0x84a2a8c assignment_tmp) (assign () (var_ref assignment_tmp) (array_ref (constant (array Sphere@0x84a2a8c 5) ((constant Sphere@0x84a2a8c ((c (constant vec3 (0.000000 0.000000 -1.000000)) )(r (constant float (0.500000)) ))) (constant Sphere@0x84a2a8c ((c (constant vec3 (-3.000000 0.000000 -1.000000)) )(r (constant float (1.500000)) ))) (constant Sphere@0x84a2a8c ((c (constant vec3 (0.000000 3.000000 -1.000000)) )(r (constant float (0.500000)) ))) (constant Sphere@0x84a2a8c ((c (constant vec3 (2.000000 0.000000 -1.000000)) )(r (constant float (1.000000)) ))) (constant Sphere@0x84a2a8c ((c (constant vec3 (0.000000 -11.000000 -1.000000)) )(r (constant float (10.000000)) ))) )) (record_ref (var_ref isec) idx) ) ) (assign (xyz) (record_ref (var_ref isec) hit) (expression vec3 + (record_ref (var_ref ray) orig) (expression vec3 * (record_ref (var_ref ray) dir) (record_ref (var_ref isec) t) ) ) ) (assign (xyz) (record_ref (var_ref isec) n) (expression vec3 / (expression vec3 + (record_ref (var_ref isec) hit) (expression vec3 neg (record_ref (var_ref assignment_tmp) c) ) ) (record_ref (var_ref assignment_tmp) r) ) ) (return (var_ref isec) ) )) ) (function idx2color (signature vec3 (parameters (declare (in ) int idx) ) ( (declare () vec3 diff) (if (expression bool all_equal (var_ref idx) (constant int (0)) ) ( (assign (xyz) (var_ref diff) (constant vec3 (1.000000 0.000000 0.000000)) ) ) ( (if (expression bool all_equal (var_ref idx) (constant int (1)) ) ( (assign (xyz) (var_ref diff) (constant vec3 (0.000000 1.000000 0.000000)) ) ) ( (if (expression bool all_equal (var_ref idx) (constant int (2)) ) ( (assign (xyz) (var_ref diff) (constant vec3 (0.000000 0.000000 1.000000)) ) ) ( (if (expression bool all_equal (var_ref idx) (constant int (3)) ) ( (assign (xyz) (var_ref diff) (constant vec3 (1.000000 1.000000 0.000000)) ) ) ( (if (expression bool all_equal (var_ref idx) (constant int (4)) ) ( (assign (xyz) (var_ref diff) (constant vec3 (0.700000 0.700000 0.700000)) ) ) ()) )) )) )) )) (return (var_ref diff) ) )) ) (function main (signature void (parameters ) ( (declare () float NdotL) (declare () vec3 N) (declare () vec3 lightVec) (declare () Isec@0x84a2d44 reflHit) (declare () int type) (declare () Isec@0x84a2d44 isec) (declare () Ray@0x84a2844 ray) (declare (temporary ) Ray@0x84a2844 record_ctor) (assign (xyz) (record_ref (var_ref record_ctor) orig) (swiz xyz (var_ref orig_t2) )) (assign (xyz) (record_ref (var_ref record_ctor) dir) (swiz xyz (var_ref dir_idx2) )) (assign () (var_ref ray) (var_ref record_ctor) ) (declare (temporary ) Isec@0x84a2d44 record_ctor@18) (assign (x) (record_ref (var_ref record_ctor@18) t) (swiz w (var_ref orig_t2) )) (assign (x) (record_ref (var_ref record_ctor@18) idx) (expression int f2i (swiz w (var_ref dir_idx2) )) ) (assign (xyz) (record_ref (var_ref record_ctor@18) hit) (constant vec3 (0.000000 0.000000 0.000000)) ) (assign (xyz) (record_ref (var_ref record_ctor@18) n) (constant vec3 (0.000000 0.000000 0.000000)) ) (assign () (var_ref isec) (var_ref record_ctor@18) ) (declare (temporary ) int assignment_tmp) (assign (x) (var_ref assignment_tmp) (expression int f2i (swiz z (var_ref uv_state2) )) ) (declare (temporary ) int assignment_tmp@19) (assign (x) (var_ref assignment_tmp@19) (expression int f2i (swiz w (var_ref uv_state2) )) ) (assign (x) (var_ref type) (var_ref assignment_tmp@19) ) (if (expression bool < (var_ref assignment_tmp) (constant int (3)) ) ( (discard ) ) ()) (if (expression bool all_equal (var_ref assignment_tmp@19) (constant int (0)) ) ( (declare () float NdotL@20) (declare () vec3 N@21) (declare () vec3 lightVec@22) (declare () Isec@0x84a2d44 eyeHit) (assign () (var_ref eyeHit) (var_ref record_ctor@18) ) (if (expression bool all_equal (record_ref (var_ref record_ctor@18) idx) (constant int (-1)) ) ( (declare (temporary ) vec4 vec_ctor) (assign (w) (var_ref vec_ctor) (constant float (0.000000)) ) (assign (xyz) (var_ref vec_ctor) (swiz xyz (var_ref backgroundColor) )) (assign (xyzw) (var_ref frag_color) (var_ref vec_ctor) ) (return) ) ()) (assign (xyz) (var_ref lightVec@22) (expression vec3 + (var_ref lightPos) (expression vec3 neg (expression vec3 + (record_ref (var_ref record_ctor) orig) (expression vec3 * (record_ref (var_ref record_ctor) dir) (record_ref (var_ref record_ctor@18) t) ) ) ) ) ) (declare (temporary ) Isec@0x84a2d44 lookupNormal_retval) (call lookupNormal (var_ref lookupNormal_retval) ((var_ref record_ctor) (var_ref record_ctor@18) )) (assign () (var_ref eyeHit) (var_ref lookupNormal_retval) ) (assign (xyz) (var_ref N@21) (record_ref (var_ref lookupNormal_retval) n) ) (declare (temporary ) vec3 normalize_retval) (call normalize (var_ref normalize_retval) ((var_ref lightVec@22) )) (declare (temporary ) float dot_retval) (call dot (var_ref dot_retval) ((var_ref N@21) (var_ref normalize_retval) )) (declare (temporary ) float max_retval) (call max (var_ref max_retval) ((var_ref dot_retval) (constant float (0.000000)) )) (assign (x) (var_ref NdotL@20) (var_ref max_retval) ) (declare (temporary ) vec3 idx2color_retval) (call idx2color (var_ref idx2color_retval) ((record_ref (var_ref eyeHit) idx) )) (declare (temporary ) vec4 vec_ctor@23) (assign (w) (var_ref vec_ctor@23) (constant float (1.000000)) ) (assign (xyz) (var_ref vec_ctor@23) (expression vec3 * (var_ref idx2color_retval) (var_ref NdotL@20) ) ) (assign (xyzw) (var_ref frag_color) (var_ref vec_ctor@23) ) (return) ) ()) (if (expression bool > (var_ref type) (constant int (0)) ) ( (if (expression bool all_equal (record_ref (var_ref isec) idx) (constant int (-1)) ) ( (discard ) ) ()) (assign (xyzw) (var_ref frag_color) (constant vec4 (-1.000000 -1.000000 -1.000000 0.000000)) ) (return) ) ()) (assign () (var_ref reflHit) (var_ref isec) ) (if (expression bool all_equal (record_ref (var_ref isec) idx) (constant int (-1)) ) ( (discard ) ) ()) (assign (xyz) (var_ref lightVec) (expression vec3 + (var_ref lightPos) (expression vec3 neg (expression vec3 + (record_ref (var_ref ray) orig) (expression vec3 * (record_ref (var_ref ray) dir) (record_ref (var_ref isec) t) ) ) ) ) ) (declare (temporary ) Isec@0x84a2d44 lookupNormal_retval@24) (call lookupNormal (var_ref lookupNormal_retval@24) ((var_ref ray) (var_ref isec) )) (assign () (var_ref reflHit) (var_ref lookupNormal_retval@24) ) (assign (xyz) (var_ref N) (record_ref (var_ref lookupNormal_retval@24) n) ) (declare (temporary ) vec3 normalize_retval@25) (call normalize (var_ref normalize_retval@25) ((var_ref lightVec) )) (declare (temporary ) float dot_retval@26) (call dot (var_ref dot_retval@26) ((var_ref N) (var_ref normalize_retval@25) )) (declare (temporary ) float max_retval@27) (call max (var_ref max_retval@27) ((var_ref dot_retval@26) (constant float (0.000000)) )) (assign (x) (var_ref NdotL) (var_ref max_retval@27) ) (declare (temporary ) vec3 idx2color_retval@28) (call idx2color (var_ref idx2color_retval@28) ((record_ref (var_ref reflHit) idx) )) (declare (temporary ) vec4 vec_ctor@29) (assign (w) (var_ref vec_ctor@29) (constant float (1.000000)) ) (assign (xyz) (var_ref vec_ctor@29) (expression vec3 * (expression vec3 * (var_ref idx2color_retval@28) (var_ref NdotL) ) (constant float (0.250000)) ) ) (assign (xyzw) (var_ref frag_color) (var_ref vec_ctor@29) ) )) ) (function normalize (signature vec3 (parameters (declare (in ) vec3 x) ) ( )) ) (function dot (signature float (parameters (declare (in ) vec3 x) (declare (in ) vec3 y) ) ( )) ) (function max (signature float (parameters (declare (in ) float x) (declare (in ) float y) ) ( )) ) ) GLSL IR for linked vertex program 4: ( (declare (shader_out ) vec4 gl_Position) (declare (temporary ) vec4 gl_Position) (declare (shader_out flat) vec4 dir_idx1) (declare (temporary ) vec4 dir_idx1) (declare (shader_out flat) vec4 orig_t1) (declare (temporary ) vec4 orig_t1) (declare (shader_out flat) vec4 uv_state1) (declare (temporary ) vec4 uv_state1) (declare (uniform ) vec3 cameraPos) (declare (uniform ) mat3 rot3) (declare (shader_in ) vec4 pos) (declare (shader_in ) vec4 orig_t) (declare (shader_in ) vec4 dir_idx) (declare (shader_in ) vec4 uv_state) (function main (signature void (parameters ) ( (declare () int type) (declare () int state) (declare (temporary ) float isec_t) (declare (temporary ) int isec_idx) (declare (temporary ) vec3 ray_orig) (declare (temporary ) vec3 ray_dir) (assign (xyz) (var_ref ray_orig) (swiz xyz (var_ref orig_t) )) (assign (xyz) (var_ref ray_dir) (swiz xyz (var_ref dir_idx) )) (assign (x) (var_ref isec_t) (swiz w (var_ref orig_t) )) (assign (x) (var_ref isec_idx) (expression int f2i (swiz w (var_ref dir_idx) )) ) (declare (temporary ) int assignment_tmp) (assign (x) (var_ref assignment_tmp) (expression int f2i (swiz z (var_ref uv_state) )) ) (assign (x) (var_ref state) (var_ref assignment_tmp) ) (assign (x) (var_ref type) (expression int f2i (swiz w (var_ref uv_state) )) ) (if (expression bool all_equal (var_ref assignment_tmp) (constant int (0)) ) ( (declare (temporary ) vec3 vec_ctor) (assign (z) (var_ref vec_ctor) (constant float (-1.000000)) ) (assign (x) (var_ref vec_ctor) (swiz x (var_ref pos) )) (assign (y) (var_ref vec_ctor) (swiz y (var_ref pos) )) (declare (temporary ) vec3 normalize_retval) (declare (temporary ) vec3 flattening_tmp) (assign (x) (var_ref flattening_tmp) (expression float dot (var_ref vec_ctor) (array_ref (var_ref rot3) (constant int (0)) ) ) ) (assign (y) (var_ref flattening_tmp) (expression float dot (var_ref vec_ctor) (array_ref (var_ref rot3) (constant int (1)) ) ) ) (assign (z) (var_ref flattening_tmp) (expression float dot (var_ref vec_ctor) (array_ref (var_ref rot3) (constant int (2)) ) ) ) (assign (xyz) (var_ref normalize_retval) (expression vec3 * (var_ref flattening_tmp) (expression float rsq (expression float dot (var_ref flattening_tmp) (var_ref flattening_tmp) ) ) ) ) (assign (xyz) (var_ref ray_orig) (var_ref cameraPos) ) (assign (xyz) (var_ref ray_dir) (var_ref normalize_retval) ) (assign (x) (var_ref isec_t) (constant float (9999.900391)) ) (assign (x) (var_ref isec_idx) (constant int (-1)) ) (assign (x) (var_ref state) (constant int (1)) ) (assign (x) (var_ref type) (constant int (0)) ) (declare (temporary ) int nearest_idx) (assign (x) (var_ref nearest_idx) (constant int (-1)) ) (declare (temporary ) float isec_t@30) (declare (temporary ) int isec_idx@31) (assign (x) (var_ref isec_t@30) (var_ref isec_t) ) (assign (x) (var_ref isec_idx@31) (var_ref nearest_idx) ) (declare (temporary ) vec3 assignment_tmp@32) (assign (xyz) (var_ref assignment_tmp@32) (expression vec3 neg (var_ref normalize_retval) ) ) (declare (temporary ) float assignment_tmp@33) (assign (x) (var_ref assignment_tmp@33) (expression float * (expression float dot (expression vec3 + (constant vec3 (0.000000 0.000000 -1.000000)) (expression vec3 neg (var_ref cameraPos) ) ) (var_ref assignment_tmp@32) ) (expression float rcp (expression float dot (var_ref assignment_tmp@32) (var_ref normalize_retval) ) ) ) ) (declare (temporary ) float length_retval) (declare () vec3 x) (assign (xyz) (var_ref x) (expression vec3 + (expression vec3 + (var_ref cameraPos) (expression vec3 * (var_ref normalize_retval) (var_ref assignment_tmp@33) ) ) (constant vec3 (-0.000000 -0.000000 1.000000)) ) ) (assign (x) (var_ref length_retval) (expression float sqrt (expression float dot (var_ref x) (var_ref x) ) ) ) (if (expression bool <= (var_ref length_retval) (constant float (0.500000)) ) ( (declare (temporary ) float assignment_tmp@34) (assign (x) (var_ref assignment_tmp@34) (expression float + (var_ref assignment_tmp@33) (expression float neg (expression float sqrt (expression float + (constant float (0.250000)) (expression float neg (expression float * (var_ref length_retval) (var_ref length_retval) ) ) ) ) ) ) ) (if (expression bool && (expression bool && (expression bool >= (var_ref assignment_tmp@34) (constant float (0.000000)) ) (expression bool >= (var_ref assignment_tmp@34) (constant float (0.000010)) ) ) (expression bool <= (var_ref assignment_tmp@34) (constant float (9999.900391)) ) ) ( (assign (x) (var_ref isec_t@30) (var_ref assignment_tmp@34) ) (assign (x) (var_ref isec_idx@31) (constant int (0)) ) ) ()) ) ()) (assign (x) (var_ref nearest_idx) (var_ref isec_idx@31) ) (declare (temporary ) float isec_t@35) (declare (temporary ) int isec_idx@36) (assign (x) (var_ref isec_t@35) (var_ref isec_t@30) ) (assign (x) (var_ref isec_idx@36) (var_ref isec_idx@31) ) (declare (temporary ) vec3 assignment_tmp@37) (assign (xyz) (var_ref assignment_tmp@37) (expression vec3 neg (var_ref normalize_retval) ) ) (declare (temporary ) float assignment_tmp@38) (assign (x) (var_ref assignment_tmp@38) (expression float * (expression float dot (expression vec3 + (constant vec3 (-3.000000 0.000000 -1.000000)) (expression vec3 neg (var_ref cameraPos) ) ) (var_ref assignment_tmp@37) ) (expression float rcp (expression float dot (var_ref assignment_tmp@37) (var_ref normalize_retval) ) ) ) ) (declare (temporary ) float length_retval@39) (declare () vec3 x@40) (assign (xyz) (var_ref x@40) (expression vec3 + (expression vec3 + (var_ref cameraPos) (expression vec3 * (var_ref normalize_retval) (var_ref assignment_tmp@38) ) ) (constant vec3 (3.000000 -0.000000 1.000000)) ) ) (assign (x) (var_ref length_retval@39) (expression float sqrt (expression float dot (var_ref x@40) (var_ref x@40) ) ) ) (if (expression bool <= (var_ref length_retval@39) (constant float (1.500000)) ) ( (declare (temporary ) float assignment_tmp@41) (assign (x) (var_ref assignment_tmp@41) (expression float + (var_ref assignment_tmp@38) (expression float neg (expression float sqrt (expression float + (constant float (2.250000)) (expression float neg (expression float * (var_ref length_retval@39) (var_ref length_retval@39) ) ) ) ) ) ) ) (if (expression bool && (expression bool && (expression bool >= (var_ref assignment_tmp@41) (constant float (0.000000)) ) (expression bool >= (var_ref assignment_tmp@41) (constant float (0.000010)) ) ) (expression bool <= (var_ref assignment_tmp@41) (var_ref isec_t@30) ) ) ( (assign (x) (var_ref isec_t@35) (var_ref assignment_tmp@41) ) (assign (x) (var_ref isec_idx@36) (constant int (1)) ) ) ()) ) ()) (assign (x) (var_ref nearest_idx) (var_ref isec_idx@36) ) (declare (temporary ) float isec_t@42) (declare (temporary ) int isec_idx@43) (assign (x) (var_ref isec_t@42) (var_ref isec_t@35) ) (assign (x) (var_ref isec_idx@43) (var_ref isec_idx@36) ) (declare (temporary ) vec3 assignment_tmp@44) (assign (xyz) (var_ref assignment_tmp@44) (expression vec3 neg (var_ref normalize_retval) ) ) (declare (temporary ) float assignment_tmp@45) (assign (x) (var_ref assignment_tmp@45) (expression float * (expression float dot (expression vec3 + (constant vec3 (0.000000 3.000000 -1.000000)) (expression vec3 neg (var_ref cameraPos) ) ) (var_ref assignment_tmp@44) ) (expression float rcp (expression float dot (var_ref assignment_tmp@44) (var_ref normalize_retval) ) ) ) ) (declare (temporary ) float length_retval@46) (declare () vec3 x@47) (assign (xyz) (var_ref x@47) (expression vec3 + (expression vec3 + (var_ref cameraPos) (expression vec3 * (var_ref normalize_retval) (var_ref assignment_tmp@45) ) ) (constant vec3 (-0.000000 -3.000000 1.000000)) ) ) (assign (x) (var_ref length_retval@46) (expression float sqrt (expression float dot (var_ref x@47) (var_ref x@47) ) ) ) (if (expression bool <= (var_ref length_retval@46) (constant float (0.500000)) ) ( (declare (temporary ) float assignment_tmp@48) (assign (x) (var_ref assignment_tmp@48) (expression float + (var_ref assignment_tmp@45) (expression float neg (expression float sqrt (expression float + (constant float (0.250000)) (expression float neg (expression float * (var_ref length_retval@46) (var_ref length_retval@46) ) ) ) ) ) ) ) (if (expression bool && (expression bool && (expression bool >= (var_ref assignment_tmp@48) (constant float (0.000000)) ) (expression bool >= (var_ref assignment_tmp@48) (constant float (0.000010)) ) ) (expression bool <= (var_ref assignment_tmp@48) (var_ref isec_t@35) ) ) ( (assign (x) (var_ref isec_t@42) (var_ref assignment_tmp@48) ) (assign (x) (var_ref isec_idx@43) (constant int (2)) ) ) ()) ) ()) (assign (x) (var_ref nearest_idx) (var_ref isec_idx@43) ) (declare (temporary ) float isec_t@49) (declare (temporary ) int isec_idx@50) (assign (x) (var_ref isec_t@49) (var_ref isec_t@42) ) (assign (x) (var_ref isec_idx@50) (var_ref isec_idx@43) ) (declare (temporary ) vec3 assignment_tmp@51) (assign (xyz) (var_ref assignment_tmp@51) (expression vec3 neg (var_ref normalize_retval) ) ) (declare (temporary ) float assignment_tmp@52) (assign (x) (var_ref assignment_tmp@52) (expression float * (expression float dot (expression vec3 + (constant vec3 (2.000000 0.000000 -1.000000)) (expression vec3 neg (var_ref cameraPos) ) ) (var_ref assignment_tmp@51) ) (expression float rcp (expression float dot (var_ref assignment_tmp@51) (var_ref normalize_retval) ) ) ) ) (declare (temporary ) float length_retval@53) (declare () vec3 x@54) (assign (xyz) (var_ref x@54) (expression vec3 + (expression vec3 + (var_ref cameraPos) (expression vec3 * (var_ref normalize_retval) (var_ref assignment_tmp@52) ) ) (constant vec3 (-2.000000 -0.000000 1.000000)) ) ) (assign (x) (var_ref length_retval@53) (expression float sqrt (expression float dot (var_ref x@54) (var_ref x@54) ) ) ) (if (expression bool <= (var_ref length_retval@53) (constant float (1.000000)) ) ( (declare (temporary ) float assignment_tmp@55) (assign (x) (var_ref assignment_tmp@55) (expression float + (var_ref assignment_tmp@52) (expression float neg (expression float sqrt (expression float + (constant float (1.000000)) (expression float neg (expression float * (var_ref length_retval@53) (var_ref length_retval@53) ) ) ) ) ) ) ) (if (expression bool && (expression bool && (expression bool >= (var_ref assignment_tmp@55) (constant float (0.000000)) ) (expression bool >= (var_ref assignment_tmp@55) (constant float (0.000010)) ) ) (expression bool <= (var_ref assignment_tmp@55) (var_ref isec_t@42) ) ) ( (assign (x) (var_ref isec_t@49) (var_ref assignment_tmp@55) ) (assign (x) (var_ref isec_idx@50) (constant int (3)) ) ) ()) ) ()) (assign (x) (var_ref nearest_idx) (var_ref isec_idx@50) ) (declare (temporary ) float isec_t@56) (declare (temporary ) int isec_idx@57) (assign (x) (var_ref isec_t@56) (var_ref isec_t@49) ) (assign (x) (var_ref isec_idx@57) (var_ref isec_idx@50) ) (declare (temporary ) vec3 assignment_tmp@58) (assign (xyz) (var_ref assignment_tmp@58) (expression vec3 neg (var_ref normalize_retval) ) ) (declare (temporary ) float assignment_tmp@59) (assign (x) (var_ref assignment_tmp@59) (expression float * (expression float dot (expression vec3 + (constant vec3 (0.000000 -11.000000 -1.000000)) (expression vec3 neg (var_ref cameraPos) ) ) (var_ref assignment_tmp@58) ) (expression float rcp (expression float dot (var_ref assignment_tmp@58) (var_ref normalize_retval) ) ) ) ) (declare (temporary ) float length_retval@60) (declare () vec3 x@61) (assign (xyz) (var_ref x@61) (expression vec3 + (expression vec3 + (var_ref cameraPos) (expression vec3 * (var_ref normalize_retval) (var_ref assignment_tmp@59) ) ) (constant vec3 (-0.000000 11.000000 1.000000)) ) ) (assign (x) (var_ref length_retval@60) (expression float sqrt (expression float dot (var_ref x@61) (var_ref x@61) ) ) ) (if (expression bool <= (var_ref length_retval@60) (constant float (10.000000)) ) ( (declare (temporary ) float assignment_tmp@62) (assign (x) (var_ref assignment_tmp@62) (expression float + (var_ref assignment_tmp@59) (expression float neg (expression float sqrt (expression float + (constant float (100.000000)) (expression float neg (expression float * (var_ref length_retval@60) (var_ref length_retval@60) ) ) ) ) ) ) ) (if (expression bool && (expression bool && (expression bool >= (var_ref assignment_tmp@62) (constant float (0.000000)) ) (expression bool >= (var_ref assignment_tmp@62) (constant float (0.000010)) ) ) (expression bool <= (var_ref assignment_tmp@62) (var_ref isec_t@49) ) ) ( (assign (x) (var_ref isec_t@56) (var_ref assignment_tmp@62) ) (assign (x) (var_ref isec_idx@57) (constant int (4)) ) ) ()) ) ()) (assign (x) (var_ref nearest_idx) (var_ref isec_idx@57) ) (assign (x) (var_ref isec_t) (var_ref isec_t@56) ) (assign (x) (var_ref isec_idx) (var_ref isec_idx@57) ) ) ( (if (expression bool all_equal (var_ref state) (constant int (1)) ) ( (declare (temporary ) int nearest_idx@63) (assign (x) (var_ref nearest_idx@63) (constant int (-1)) ) (declare (temporary ) float isec_t@64) (declare (temporary ) int isec_idx@65) (assign (x) (var_ref isec_t@64) (var_ref isec_t) ) (assign (x) (var_ref isec_idx@65) (var_ref nearest_idx@63) ) (declare (temporary ) vec3 assignment_tmp@66) (assign (xyz) (var_ref assignment_tmp@66) (expression vec3 neg (var_ref ray_dir) ) ) (declare (temporary ) float assignment_tmp@67) (assign (x) (var_ref assignment_tmp@67) (expression float * (expression float dot (expression vec3 + (constant vec3 (0.000000 0.000000 -1.000000)) (expression vec3 neg (var_ref ray_orig) ) ) (var_ref assignment_tmp@66) ) (expression float rcp (expression float dot (var_ref assignment_tmp@66) (var_ref ray_dir) ) ) ) ) (declare (temporary ) float length_retval@68) (declare () vec3 x@69) (assign (xyz) (var_ref x@69) (expression vec3 + (expression vec3 + (var_ref ray_orig) (expression vec3 * (var_ref ray_dir) (var_ref assignment_tmp@67) ) ) (constant vec3 (-0.000000 -0.000000 1.000000)) ) ) (assign (x) (var_ref length_retval@68) (expression float sqrt (expression float dot (var_ref x@69) (var_ref x@69) ) ) ) (if (expression bool <= (var_ref length_retval@68) (constant float (0.500000)) ) ( (declare (temporary ) float assignment_tmp@70) (assign (x) (var_ref assignment_tmp@70) (expression float + (var_ref assignment_tmp@67) (expression float neg (expression float sqrt (expression float + (constant float (0.250000)) (expression float neg (expression float * (var_ref length_retval@68) (var_ref length_retval@68) ) ) ) ) ) ) ) (if (expression bool && (expression bool && (expression bool >= (var_ref assignment_tmp@70) (constant float (0.000000)) ) (expression bool >= (var_ref assignment_tmp@70) (constant float (0.000010)) ) ) (expression bool <= (var_ref assignment_tmp@70) (var_ref isec_t) ) ) ( (assign (x) (var_ref isec_t@64) (var_ref assignment_tmp@70) ) (assign (x) (var_ref isec_idx@65) (constant int (0)) ) ) ()) ) ()) (assign (x) (var_ref nearest_idx@63) (var_ref isec_idx@65) ) (declare (temporary ) float isec_t@71) (declare (temporary ) int isec_idx@72) (assign (x) (var_ref isec_t@71) (var_ref isec_t@64) ) (assign (x) (var_ref isec_idx@72) (var_ref isec_idx@65) ) (declare (temporary ) vec3 assignment_tmp@73) (assign (xyz) (var_ref assignment_tmp@73) (expression vec3 neg (var_ref ray_dir) ) ) (declare (temporary ) float assignment_tmp@74) (assign (x) (var_ref assignment_tmp@74) (expression float * (expression float dot (expression vec3 + (constant vec3 (-3.000000 0.000000 -1.000000)) (expression vec3 neg (var_ref ray_orig) ) ) (var_ref assignment_tmp@73) ) (expression float rcp (expression float dot (var_ref assignment_tmp@73) (var_ref ray_dir) ) ) ) ) (declare (temporary ) float length_retval@75) (declare () vec3 x@76) (assign (xyz) (var_ref x@76) (expression vec3 + (expression vec3 + (var_ref ray_orig) (expression vec3 * (var_ref ray_dir) (var_ref assignment_tmp@74) ) ) (constant vec3 (3.000000 -0.000000 1.000000)) ) ) (assign (x) (var_ref length_retval@75) (expression float sqrt (expression float dot (var_ref x@76) (var_ref x@76) ) ) ) (if (expression bool <= (var_ref length_retval@75) (constant float (1.500000)) ) ( (declare (temporary ) float assignment_tmp@77) (assign (x) (var_ref assignment_tmp@77) (expression float + (var_ref assignment_tmp@74) (expression float neg (expression float sqrt (expression float + (constant float (2.250000)) (expression float neg (expression float * (var_ref length_retval@75) (var_ref length_retval@75) ) ) ) ) ) ) ) (if (expression bool && (expression bool && (expression bool >= (var_ref assignment_tmp@77) (constant float (0.000000)) ) (expression bool >= (var_ref assignment_tmp@77) (constant float (0.000010)) ) ) (expression bool <= (var_ref assignment_tmp@77) (var_ref isec_t@64) ) ) ( (assign (x) (var_ref isec_t@71) (var_ref assignment_tmp@77) ) (assign (x) (var_ref isec_idx@72) (constant int (1)) ) ) ()) ) ()) (assign (x) (var_ref nearest_idx@63) (var_ref isec_idx@72) ) (declare (temporary ) float isec_t@78) (declare (temporary ) int isec_idx@79) (assign (x) (var_ref isec_t@78) (var_ref isec_t@71) ) (assign (x) (var_ref isec_idx@79) (var_ref isec_idx@72) ) (declare (temporary ) vec3 assignment_tmp@80) (assign (xyz) (var_ref assignment_tmp@80) (expression vec3 neg (var_ref ray_dir) ) ) (declare (temporary ) float assignment_tmp@81) (assign (x) (var_ref assignment_tmp@81) (expression float * (expression float dot (expression vec3 + (constant vec3 (0.000000 3.000000 -1.000000)) (expression vec3 neg (var_ref ray_orig) ) ) (var_ref assignment_tmp@80) ) (expression float rcp (expression float dot (var_ref assignment_tmp@80) (var_ref ray_dir) ) ) ) ) (declare (temporary ) float length_retval@82) (declare () vec3 x@83) (assign (xyz) (var_ref x@83) (expression vec3 + (expression vec3 + (var_ref ray_orig) (expression vec3 * (var_ref ray_dir) (var_ref assignment_tmp@81) ) ) (constant vec3 (-0.000000 -3.000000 1.000000)) ) ) (assign (x) (var_ref length_retval@82) (expression float sqrt (expression float dot (var_ref x@83) (var_ref x@83) ) ) ) (if (expression bool <= (var_ref length_retval@82) (constant float (0.500000)) ) ( (declare (temporary ) float assignment_tmp@84) (assign (x) (var_ref assignment_tmp@84) (expression float + (var_ref assignment_tmp@81) (expression float neg (expression float sqrt (expression float + (constant float (0.250000)) (expression float neg (expression float * (var_ref length_retval@82) (var_ref length_retval@82) ) ) ) ) ) ) ) (if (expression bool && (expression bool && (expression bool >= (var_ref assignment_tmp@84) (constant float (0.000000)) ) (expression bool >= (var_ref assignment_tmp@84) (constant float (0.000010)) ) ) (expression bool <= (var_ref assignment_tmp@84) (var_ref isec_t@71) ) ) ( (assign (x) (var_ref isec_t@78) (var_ref assignment_tmp@84) ) (assign (x) (var_ref isec_idx@79) (constant int (2)) ) ) ()) ) ()) (assign (x) (var_ref nearest_idx@63) (var_ref isec_idx@79) ) (declare (temporary ) float isec_t@85) (declare (temporary ) int isec_idx@86) (assign (x) (var_ref isec_t@85) (var_ref isec_t@78) ) (assign (x) (var_ref isec_idx@86) (var_ref isec_idx@79) ) (declare (temporary ) vec3 assignment_tmp@87) (assign (xyz) (var_ref assignment_tmp@87) (expression vec3 neg (var_ref ray_dir) ) ) (declare (temporary ) float assignment_tmp@88) (assign (x) (var_ref assignment_tmp@88) (expression float * (expression float dot (expression vec3 + (constant vec3 (2.000000 0.000000 -1.000000)) (expression vec3 neg (var_ref ray_orig) ) ) (var_ref assignment_tmp@87) ) (expression float rcp (expression float dot (var_ref assignment_tmp@87) (var_ref ray_dir) ) ) ) ) (declare (temporary ) float length_retval@89) (declare () vec3 x@90) (assign (xyz) (var_ref x@90) (expression vec3 + (expression vec3 + (var_ref ray_orig) (expression vec3 * (var_ref ray_dir) (var_ref assignment_tmp@88) ) ) (constant vec3 (-2.000000 -0.000000 1.000000)) ) ) (assign (x) (var_ref length_retval@89) (expression float sqrt (expression float dot (var_ref x@90) (var_ref x@90) ) ) ) (if (expression bool <= (var_ref length_retval@89) (constant float (1.000000)) ) ( (declare (temporary ) float assignment_tmp@91) (assign (x) (var_ref assignment_tmp@91) (expression float + (var_ref assignment_tmp@88) (expression float neg (expression float sqrt (expression float + (constant float (1.000000)) (expression float neg (expression float * (var_ref length_retval@89) (var_ref length_retval@89) ) ) ) ) ) ) ) (if (expression bool && (expression bool && (expression bool >= (var_ref assignment_tmp@91) (constant float (0.000000)) ) (expression bool >= (var_ref assignment_tmp@91) (constant float (0.000010)) ) ) (expression bool <= (var_ref assignment_tmp@91) (var_ref isec_t@78) ) ) ( (assign (x) (var_ref isec_t@85) (var_ref assignment_tmp@91) ) (assign (x) (var_ref isec_idx@86) (constant int (3)) ) ) ()) ) ()) (assign (x) (var_ref nearest_idx@63) (var_ref isec_idx@86) ) (declare (temporary ) float isec_t@92) (declare (temporary ) int isec_idx@93) (assign (x) (var_ref isec_t@92) (var_ref isec_t@85) ) (assign (x) (var_ref isec_idx@93) (var_ref isec_idx@86) ) (declare (temporary ) vec3 assignment_tmp@94) (assign (xyz) (var_ref assignment_tmp@94) (expression vec3 neg (var_ref ray_dir) ) ) (declare (temporary ) float assignment_tmp@95) (assign (x) (var_ref assignment_tmp@95) (expression float * (expression float dot (expression vec3 + (constant vec3 (0.000000 -11.000000 -1.000000)) (expression vec3 neg (var_ref ray_orig) ) ) (var_ref assignment_tmp@94) ) (expression float rcp (expression float dot (var_ref assignment_tmp@94) (var_ref ray_dir) ) ) ) ) (declare (temporary ) float length_retval@96) (declare () vec3 x@97) (assign (xyz) (var_ref x@97) (expression vec3 + (expression vec3 + (var_ref ray_orig) (expression vec3 * (var_ref ray_dir) (var_ref assignment_tmp@95) ) ) (constant vec3 (-0.000000 11.000000 1.000000)) ) ) (assign (x) (var_ref length_retval@96) (expression float sqrt (expression float dot (var_ref x@97) (var_ref x@97) ) ) ) (if (expression bool <= (var_ref length_retval@96) (constant float (10.000000)) ) ( (declare (temporary ) float assignment_tmp@98) (assign (x) (var_ref assignment_tmp@98) (expression float + (var_ref assignment_tmp@95) (expression float neg (expression float sqrt (expression float + (constant float (100.000000)) (expression float neg (expression float * (var_ref length_retval@96) (var_ref length_retval@96) ) ) ) ) ) ) ) (if (expression bool && (expression bool && (expression bool >= (var_ref assignment_tmp@98) (constant float (0.000000)) ) (expression bool >= (var_ref assignment_tmp@98) (constant float (0.000010)) ) ) (expression bool <= (var_ref assignment_tmp@98) (var_ref isec_t@85) ) ) ( (assign (x) (var_ref isec_t@92) (var_ref assignment_tmp@98) ) (assign (x) (var_ref isec_idx@93) (constant int (4)) ) ) ()) ) ()) (assign (x) (var_ref nearest_idx@63) (var_ref isec_idx@93) ) (assign (x) (var_ref isec_t) (var_ref isec_t@92) ) (assign (x) (var_ref isec_idx) (var_ref isec_idx@93) ) ) ()) )) (assign (xyzw) (var_ref gl_Position) (var_ref pos) ) (assign (xyz) (var_ref orig_t1) (var_ref ray_orig) ) (assign (w) (var_ref orig_t1) (var_ref isec_t) ) (assign (xyz) (var_ref dir_idx1) (var_ref ray_dir) ) (assign (w) (var_ref dir_idx1) (expression float i2f (var_ref isec_idx) ) ) (assign (z) (var_ref uv_state1) (expression float i2f (var_ref state) ) ) (assign (w) (var_ref uv_state1) (expression float i2f (var_ref type) ) ) (assign (xyzw) (var_ref uv_state1@99) (var_ref uv_state1) ) (assign (xyzw) (var_ref dir_idx1@100) (var_ref dir_idx1) ) (assign (xyzw) (var_ref orig_t1@101) (var_ref orig_t1) ) (assign (xyzw) (var_ref gl_Position@102) (var_ref gl_Position) ) )) ) ) GLSL IR for linked geometry program 4: ( (declare (shader_in ) (array vec4 1) gl_Position) (declare (shader_in flat) (array vec4 1) dir_idx1) (declare (shader_in flat) (array vec4 1) orig_t1) (declare (shader_in flat) (array vec4 1) uv_state1) (declare (shader_out ) vec4 gl_Position) (declare (temporary ) vec4 gl_Position) (declare (temporary ) vec4 gl_Position) (declare (temporary ) vec4 gl_Position) (declare (shader_out ) vec4 dir_idx2) (declare (temporary ) vec4 dir_idx2) (declare (temporary ) vec4 dir_idx2) (declare (temporary ) vec4 dir_idx2) (declare (shader_out ) vec4 orig_t2) (declare (temporary ) vec4 orig_t2) (declare (temporary ) vec4 orig_t2) (declare (temporary ) vec4 orig_t2) (declare (shader_out ) vec4 uv_state2) (declare (temporary ) vec4 uv_state2) (declare (temporary ) vec4 uv_state2) (declare (temporary ) vec4 uv_state2) (declare (uniform ) vec3 lightPos) (declare (uniform ) int emitNoMore) (function main (signature void (parameters ) ( (declare () int type) (declare (temporary ) vec3 record_ctor_orig) (declare (temporary ) vec3 record_ctor_dir) (assign (xyz) (var_ref record_ctor_orig) (swiz xyz (array_ref (var_ref orig_t1) (constant int (0)) ) )) (assign (xyz) (var_ref record_ctor_dir) (swiz xyz (array_ref (var_ref dir_idx1) (constant int (0)) ) )) (declare (temporary ) float record_ctor_t) (declare (temporary ) int record_ctor_idx) (assign (x) (var_ref record_ctor_t) (swiz w (array_ref (var_ref orig_t1) (constant int (0)) ) )) (assign (x) (var_ref record_ctor_idx) (expression int f2i (swiz w (array_ref (var_ref dir_idx1) (constant int (0)) ) )) ) (declare (temporary ) int assignment_tmp) (assign (x) (var_ref assignment_tmp) (expression int f2i (swiz z (array_ref (var_ref uv_state1) (constant int (0)) ) )) ) (assign (x) (var_ref type) (expression int f2i (swiz w (array_ref (var_ref uv_state1) (constant int (0)) ) )) ) (if (expression bool && (expression bool <= (var_ref assignment_tmp) (constant int (1)) ) (expression bool any_nequal (var_ref record_ctor_idx) (constant int (-1)) ) ) ( (assign (xyzw) (var_ref gl_Position) (array_ref (var_ref gl_Position@103) (constant int (0)) ) ) (assign (xyzw) (var_ref orig_t2) (array_ref (var_ref orig_t1) (constant int (0)) ) ) (assign (xyzw) (var_ref dir_idx2) (array_ref (var_ref dir_idx1) (constant int (0)) ) ) (assign (xyw) (var_ref uv_state2) (swiz xyw (array_ref (var_ref uv_state1) (constant int (0)) ) )) (assign (z) (var_ref uv_state2) (constant float (3.000000)) ) (assign (xyzw) (var_ref uv_state2@104) (var_ref uv_state2) ) (assign (xyzw) (var_ref dir_idx2@105) (var_ref dir_idx2) ) (assign (xyzw) (var_ref orig_t2@106) (var_ref orig_t2) ) (assign (xyzw) (var_ref gl_Position@107) (var_ref gl_Position) ) (emit-vertex (constant int (0)) ) (end-primitive (constant int (0)) ) (if (expression bool ! (expression bool || (expression bool any_nequal (var_ref type) (constant int (0)) ) (expression bool > (var_ref emitNoMore) (constant int (0)) ) ) ) ( (declare (temporary ) vec3 isec_n) (declare (temporary ) Sphere@0x84a2a8c assignment_tmp@108) (assign () (var_ref assignment_tmp@108) (array_ref (constant (array Sphere@0x84a2a8c 5) ((constant Sphere@0x84a2a8c ((c (constant vec3 (0.000000 0.000000 -1.000000)) )(r (constant float (0.500000)) ))) (constant Sphere@0x84a2a8c ((c (constant vec3 (-3.000000 0.000000 -1.000000)) )(r (constant float (1.500000)) ))) (constant Sphere@0x84a2a8c ((c (constant vec3 (0.000000 3.000000 -1.000000)) )(r (constant float (0.500000)) ))) (constant Sphere@0x84a2a8c ((c (constant vec3 (2.000000 0.000000 -1.000000)) )(r (constant float (1.000000)) ))) (constant Sphere@0x84a2a8c ((c (constant vec3 (0.000000 -11.000000 -1.000000)) )(r (constant float (10.000000)) ))) )) (var_ref record_ctor_idx) ) ) (assign (xyz) (var_ref isec_n) (expression vec3 * (expression vec3 + (expression vec3 + (var_ref record_ctor_orig) (expression vec3 * (var_ref record_ctor_dir) (var_ref record_ctor_t) ) ) (expression vec3 neg (record_ref (var_ref assignment_tmp@108) c) ) ) (expression float rcp (record_ref (var_ref assignment_tmp@108) r) ) ) ) (declare (temporary ) vec3 assignment_tmp@109) (assign (xyz) (var_ref assignment_tmp@109) (expression vec3 + (expression vec3 + (var_ref record_ctor_orig) (expression vec3 * (var_ref record_ctor_dir) (var_ref record_ctor_t) ) ) (expression vec3 * (var_ref isec_n) (constant float (0.000010)) ) ) ) (declare (temporary ) vec3 assignment_tmp@110) (assign (xyz) (var_ref assignment_tmp@110) (expression vec3 + (var_ref lightPos) (expression vec3 neg (var_ref assignment_tmp@109) ) ) ) (declare (temporary ) float length_retval) (assign (x) (var_ref length_retval) (expression float sqrt (expression float dot (var_ref assignment_tmp@110) (var_ref assignment_tmp@110) ) ) ) (assign (xyzw) (var_ref gl_Position@111) (array_ref (var_ref gl_Position@103) (constant int (0)) ) ) (assign (xyz) (var_ref orig_t2@112) (var_ref assignment_tmp@109) ) (assign (w) (var_ref orig_t2@112) (var_ref length_retval) ) (assign (xyz) (var_ref dir_idx2@113) (expression vec3 * (var_ref assignment_tmp@110) (expression float rcp (var_ref length_retval) ) ) ) (assign (w) (var_ref dir_idx2@113) (constant float (-1.000000)) ) (assign (z) (var_ref uv_state2@114) (constant float (1.000000)) ) (assign (w) (var_ref uv_state2@114) (constant float (1.000000)) ) (assign (xyzw) (var_ref uv_state2@104) (var_ref uv_state2@114) ) (assign (xyzw) (var_ref dir_idx2@105) (var_ref dir_idx2@113) ) (assign (xyzw) (var_ref orig_t2@106) (var_ref orig_t2@112) ) (assign (xyzw) (var_ref gl_Position@107) (var_ref gl_Position@111) ) (emit-vertex (constant int (0)) ) (end-primitive (constant int (0)) ) (assign (x) (var_ref type) (constant int (-1)) ) (assign (xyzw) (var_ref gl_Position@115) (array_ref (var_ref gl_Position@103) (constant int (0)) ) ) (assign (xyz) (var_ref orig_t2@116) (var_ref assignment_tmp@109) ) (assign (w) (var_ref orig_t2@116) (constant float (9999.900391)) ) (assign (xyz) (var_ref dir_idx2@117) (expression vec3 + (var_ref record_ctor_dir) (expression vec3 neg (expression vec3 * (constant float (2.000000)) (expression vec3 * (expression float dot (var_ref isec_n) (var_ref record_ctor_dir) ) (var_ref isec_n) ) ) ) ) ) (assign (w) (var_ref dir_idx2@117) (constant float (-1.000000)) ) (assign (z) (var_ref uv_state2@118) (constant float (1.000000)) ) (assign (w) (var_ref uv_state2@118) (constant float (-1.000000)) ) (assign (xyzw) (var_ref uv_state2@104) (var_ref uv_state2@118) ) (assign (xyzw) (var_ref dir_idx2@105) (var_ref dir_idx2@117) ) (assign (xyzw) (var_ref orig_t2@106) (var_ref orig_t2@116) ) (assign (xyzw) (var_ref gl_Position@107) (var_ref gl_Position@115) ) (emit-vertex (constant int (0)) ) (end-primitive (constant int (0)) ) ) ()) ) ()) )) ) ) GLSL IR for linked fragment program 4: ( (declare (shader_in ) vec4 dir_idx2) (declare (shader_in ) vec4 orig_t2) (declare (shader_in ) vec4 uv_state2) (declare (uniform ) vec3 lightPos) (declare (uniform ) vec4 backgroundColor) (declare (shader_out ) vec4 frag_color) (declare (temporary ) vec4 frag_color) (function main (signature void (parameters ) ( (declare () vec3 lightVec) (declare (temporary ) int record_ctor_idx) (assign (x) (var_ref record_ctor_idx) (expression int f2i (swiz w (var_ref dir_idx2) )) ) (declare (temporary ) int assignment_tmp) (assign (x) (var_ref assignment_tmp) (expression int f2i (swiz z (var_ref uv_state2) )) ) (declare (temporary ) int assignment_tmp@119) (assign (x) (var_ref assignment_tmp@119) (expression int f2i (swiz w (var_ref uv_state2) )) ) (if (expression bool < (var_ref assignment_tmp) (constant int (3)) ) ( (discard ) ) ()) (if (expression bool all_equal (var_ref assignment_tmp@119) (constant int (0)) ) ( (declare () vec3 lightVec@120) (if (expression bool all_equal (var_ref record_ctor_idx) (constant int (-1)) ) ( (declare (temporary ) vec4 vec_ctor) (assign (w) (var_ref vec_ctor) (constant float (0.000000)) ) (assign (xyz) (var_ref vec_ctor) (swiz xyz (var_ref backgroundColor) )) (assign (xyzw) (var_ref frag_color) (var_ref vec_ctor) ) ) ( (declare () vec3 cse) (assign (xyz) (var_ref cse) (expression vec3 * (swiz xyz (var_ref dir_idx2) )(swiz w (var_ref orig_t2) )) ) (assign (xyz) (var_ref lightVec@120) (expression vec3 + (var_ref lightPos) (expression vec3 neg (expression vec3 + (swiz xyz (var_ref orig_t2) )(var_ref cse) ) ) ) ) (declare (temporary ) Sphere@0x84a2a8c assignment_tmp@121) (assign () (var_ref assignment_tmp@121) (array_ref (constant (array Sphere@0x84a2a8c 5) ((constant Sphere@0x84a2a8c ((c (constant vec3 (0.000000 0.000000 -1.000000)) )(r (constant float (0.500000)) ))) (constant Sphere@0x84a2a8c ((c (constant vec3 (-3.000000 0.000000 -1.000000)) )(r (constant float (1.500000)) ))) (constant Sphere@0x84a2a8c ((c (constant vec3 (0.000000 3.000000 -1.000000)) )(r (constant float (0.500000)) ))) (constant Sphere@0x84a2a8c ((c (constant vec3 (2.000000 0.000000 -1.000000)) )(r (constant float (1.000000)) ))) (constant Sphere@0x84a2a8c ((c (constant vec3 (0.000000 -11.000000 -1.000000)) )(r (constant float (10.000000)) ))) )) (var_ref record_ctor_idx) ) ) (declare (temporary ) float max_retval) (assign (x) (var_ref max_retval) (expression float max (expression float dot (expression vec3 * (expression vec3 + (expression vec3 + (swiz xyz (var_ref orig_t2) )(var_ref cse) ) (expression vec3 neg (record_ref (var_ref assignment_tmp@121) c) ) ) (expression float rcp (record_ref (var_ref assignment_tmp@121) r) ) ) (expression vec3 * (var_ref lightVec@120) (expression float rsq (expression float dot (var_ref lightVec@120) (var_ref lightVec@120) ) ) ) ) (constant float (0.000000)) ) ) (declare () vec3 diff) (if (expression bool all_equal (var_ref record_ctor_idx) (constant int (0)) ) ( (assign (xyz) (var_ref diff) (constant vec3 (1.000000 0.000000 0.000000)) ) ) ( (if (expression bool all_equal (var_ref record_ctor_idx) (constant int (1)) ) ( (assign (xyz) (var_ref diff) (constant vec3 (0.000000 1.000000 0.000000)) ) ) ( (if (expression bool all_equal (var_ref record_ctor_idx) (constant int (2)) ) ( (assign (xyz) (var_ref diff) (constant vec3 (0.000000 0.000000 1.000000)) ) ) ( (if (expression bool all_equal (var_ref record_ctor_idx) (constant int (3)) ) ( (assign (xyz) (var_ref diff) (constant vec3 (1.000000 1.000000 0.000000)) ) ) ( (if (expression bool all_equal (var_ref record_ctor_idx) (constant int (4)) ) ( (assign (xyz) (var_ref diff) (constant vec3 (0.700000 0.700000 0.700000)) ) ) ()) )) )) )) )) (declare (temporary ) vec4 vec_ctor@122) (assign (w) (var_ref vec_ctor@122) (constant float (1.000000)) ) (assign (xyz) (var_ref vec_ctor@122) (expression vec3 * (var_ref diff) (var_ref max_retval) ) ) (assign (xyzw) (var_ref frag_color) (var_ref vec_ctor@122) ) )) ) ( (if (expression bool > (var_ref assignment_tmp@119) (constant int (0)) ) ( (if (expression bool all_equal (var_ref record_ctor_idx) (constant int (-1)) ) ( (discard ) ) ()) (assign (xyzw) (var_ref frag_color) (constant vec4 (-1.000000 -1.000000 -1.000000 0.000000)) ) ) ( (if (expression bool all_equal (var_ref record_ctor_idx) (constant int (-1)) ) ( (discard ) ) ()) (declare () vec3 cse@123) (assign (xyz) (var_ref cse@123) (expression vec3 * (swiz xyz (var_ref dir_idx2) )(swiz w (var_ref orig_t2) )) ) (assign (xyz) (var_ref lightVec) (expression vec3 + (var_ref lightPos) (expression vec3 neg (expression vec3 + (swiz xyz (var_ref orig_t2) )(var_ref cse@123) ) ) ) ) (declare (temporary ) Sphere@0x84a2a8c assignment_tmp@124) (assign () (var_ref assignment_tmp@124) (array_ref (constant (array Sphere@0x84a2a8c 5) ((constant Sphere@0x84a2a8c ((c (constant vec3 (0.000000 0.000000 -1.000000)) )(r (constant float (0.500000)) ))) (constant Sphere@0x84a2a8c ((c (constant vec3 (-3.000000 0.000000 -1.000000)) )(r (constant float (1.500000)) ))) (constant Sphere@0x84a2a8c ((c (constant vec3 (0.000000 3.000000 -1.000000)) )(r (constant float (0.500000)) ))) (constant Sphere@0x84a2a8c ((c (constant vec3 (2.000000 0.000000 -1.000000)) )(r (constant float (1.000000)) ))) (constant Sphere@0x84a2a8c ((c (constant vec3 (0.000000 -11.000000 -1.000000)) )(r (constant float (10.000000)) ))) )) (var_ref record_ctor_idx) ) ) (declare (temporary ) float max_retval@125) (assign (x) (var_ref max_retval@125) (expression float max (expression float dot (expression vec3 * (expression vec3 + (expression vec3 + (swiz xyz (var_ref orig_t2) )(var_ref cse@123) ) (expression vec3 neg (record_ref (var_ref assignment_tmp@124) c) ) ) (expression float rcp (record_ref (var_ref assignment_tmp@124) r) ) ) (expression vec3 * (var_ref lightVec) (expression float rsq (expression float dot (var_ref lightVec) (var_ref lightVec) ) ) ) ) (constant float (0.000000)) ) ) (declare () vec3 diff@126) (if (expression bool all_equal (var_ref record_ctor_idx) (constant int (0)) ) ( (assign (xyz) (var_ref diff@126) (constant vec3 (1.000000 0.000000 0.000000)) ) ) ( (if (expression bool all_equal (var_ref record_ctor_idx) (constant int (1)) ) ( (assign (xyz) (var_ref diff@126) (constant vec3 (0.000000 1.000000 0.000000)) ) ) ( (if (expression bool all_equal (var_ref record_ctor_idx) (constant int (2)) ) ( (assign (xyz) (var_ref diff@126) (constant vec3 (0.000000 0.000000 1.000000)) ) ) ( (if (expression bool all_equal (var_ref record_ctor_idx) (constant int (3)) ) ( (assign (xyz) (var_ref diff@126) (constant vec3 (1.000000 1.000000 0.000000)) ) ) ( (if (expression bool all_equal (var_ref record_ctor_idx) (constant int (4)) ) ( (assign (xyz) (var_ref diff@126) (constant vec3 (0.700000 0.700000 0.700000)) ) ) ()) )) )) )) )) (declare (temporary ) vec4 vec_ctor@127) (assign (w) (var_ref vec_ctor@127) (constant float (1.000000)) ) (assign (xyz) (var_ref vec_ctor@127) (expression vec3 * (expression vec3 * (var_ref diff@126) (var_ref max_retval@125) ) (constant float (0.250000)) ) ) (assign (xyzw) (var_ref frag_color) (var_ref vec_ctor@127) ) )) )) (assign (xyzw) (var_ref frag_color@128) (var_ref frag_color) ) )) ) ) GLSL IR for linked vertex program 4: ( (declare (shader_out ) vec4 gl_Position) (declare (temporary ) vec4 gl_Position) (declare (shader_out flat) vec4 dir_idx1) (declare (temporary ) vec4 dir_idx1) (declare (shader_out flat) vec4 orig_t1) (declare (temporary ) vec4 orig_t1) (declare (shader_out flat) vec4 uv_state1) (declare (temporary ) vec4 uv_state1) (declare (uniform ) vec3 cameraPos) (declare (uniform ) mat3 rot3) (declare (shader_in ) vec4 pos) (declare (shader_in ) vec4 orig_t) (declare (shader_in ) vec4 dir_idx) (declare (shader_in ) vec4 uv_state) (function main (signature void (parameters ) ( (declare () int type) (declare () int state) (declare (temporary ) float isec_t) (declare (temporary ) int isec_idx) (declare (temporary ) vec3 ray_orig) (declare (temporary ) vec3 ray_dir) (assign (xyz) (var_ref ray_orig) (swiz xyz (var_ref orig_t) )) (assign (xyz) (var_ref ray_dir) (swiz xyz (var_ref dir_idx) )) (assign (x) (var_ref isec_t) (swiz w (var_ref orig_t) )) (assign (x) (var_ref isec_idx) (expression int f2i (swiz w (var_ref dir_idx) )) ) (declare (temporary ) int assignment_tmp) (assign (x) (var_ref assignment_tmp) (expression int f2i (swiz z (var_ref uv_state) )) ) (assign (x) (var_ref state) (var_ref assignment_tmp) ) (assign (x) (var_ref type) (expression int f2i (swiz w (var_ref uv_state) )) ) (if (expression bool all_equal (var_ref assignment_tmp) (constant int (0)) ) ( (declare (temporary ) vec3 vec_ctor) (assign (z) (var_ref vec_ctor) (constant float (-1.000000)) ) (assign (x) (var_ref vec_ctor) (swiz x (var_ref pos) )) (assign (y) (var_ref vec_ctor) (swiz y (var_ref pos) )) (declare (temporary ) vec3 normalize_retval) (declare (temporary ) vec3 flattening_tmp) (assign (x) (var_ref flattening_tmp) (expression float dot (var_ref vec_ctor) (array_ref (var_ref rot3) (constant int (0)) ) ) ) (assign (y) (var_ref flattening_tmp) (expression float dot (var_ref vec_ctor) (array_ref (var_ref rot3) (constant int (1)) ) ) ) (assign (z) (var_ref flattening_tmp) (expression float dot (var_ref vec_ctor) (array_ref (var_ref rot3) (constant int (2)) ) ) ) (assign (xyz) (var_ref normalize_retval) (expression vec3 * (var_ref flattening_tmp) (expression float rsq (expression float dot (var_ref flattening_tmp) (var_ref flattening_tmp) ) ) ) ) (assign (xyz) (var_ref ray_orig) (var_ref cameraPos) ) (assign (xyz) (var_ref ray_dir) (var_ref normalize_retval) ) (assign (x) (var_ref isec_t) (constant float (9999.900391)) ) (assign (x) (var_ref isec_idx) (constant int (-1)) ) (assign (x) (var_ref state) (constant int (1)) ) (assign (x) (var_ref type) (constant int (0)) ) (declare (temporary ) int nearest_idx) (assign (x) (var_ref nearest_idx) (constant int (-1)) ) (declare (temporary ) float isec_t@129) (declare (temporary ) int isec_idx@130) (assign (x) (var_ref isec_t@129) (var_ref isec_t) ) (assign (x) (var_ref isec_idx@130) (var_ref nearest_idx) ) (declare (temporary ) vec3 assignment_tmp@131) (assign (xyz) (var_ref assignment_tmp@131) (expression vec3 neg (var_ref normalize_retval) ) ) (declare (temporary ) float assignment_tmp@132) (assign (x) (var_ref assignment_tmp@132) (expression float * (expression float dot (expression vec3 + (constant vec3 (0.000000 0.000000 -1.000000)) (expression vec3 neg (var_ref cameraPos) ) ) (var_ref assignment_tmp@131) ) (expression float rcp (expression float dot (var_ref assignment_tmp@131) (var_ref normalize_retval) ) ) ) ) (declare (temporary ) float length_retval) (declare () vec3 x) (assign (xyz) (var_ref x) (expression vec3 + (expression vec3 + (var_ref cameraPos) (expression vec3 * (var_ref normalize_retval) (var_ref assignment_tmp@132) ) ) (constant vec3 (-0.000000 -0.000000 1.000000)) ) ) (assign (x) (var_ref length_retval) (expression float sqrt (expression float dot (var_ref x) (var_ref x) ) ) ) (if (expression bool <= (var_ref length_retval) (constant float (0.500000)) ) ( (declare (temporary ) float assignment_tmp@133) (assign (x) (var_ref assignment_tmp@133) (expression float + (var_ref assignment_tmp@132) (expression float neg (expression float sqrt (expression float + (constant float (0.250000)) (expression float neg (expression float * (var_ref length_retval) (var_ref length_retval) ) ) ) ) ) ) ) (if (expression bool && (expression bool && (expression bool >= (var_ref assignment_tmp@133) (constant float (0.000000)) ) (expression bool >= (var_ref assignment_tmp@133) (constant float (0.000010)) ) ) (expression bool <= (var_ref assignment_tmp@133) (constant float (9999.900391)) ) ) ( (assign (x) (var_ref isec_t@129) (var_ref assignment_tmp@133) ) (assign (x) (var_ref isec_idx@130) (constant int (0)) ) ) ()) ) ()) (assign (x) (var_ref nearest_idx) (var_ref isec_idx@130) ) (declare (temporary ) float isec_t@134) (declare (temporary ) int isec_idx@135) (assign (x) (var_ref isec_t@134) (var_ref isec_t@129) ) (assign (x) (var_ref isec_idx@135) (var_ref isec_idx@130) ) (declare (temporary ) vec3 assignment_tmp@136) (assign (xyz) (var_ref assignment_tmp@136) (expression vec3 neg (var_ref normalize_retval) ) ) (declare (temporary ) float assignment_tmp@137) (assign (x) (var_ref assignment_tmp@137) (expression float * (expression float dot (expression vec3 + (constant vec3 (-3.000000 0.000000 -1.000000)) (expression vec3 neg (var_ref cameraPos) ) ) (var_ref assignment_tmp@136) ) (expression float rcp (expression float dot (var_ref assignment_tmp@136) (var_ref normalize_retval) ) ) ) ) (declare (temporary ) float length_retval@138) (declare () vec3 x@139) (assign (xyz) (var_ref x@139) (expression vec3 + (expression vec3 + (var_ref cameraPos) (expression vec3 * (var_ref normalize_retval) (var_ref assignment_tmp@137) ) ) (constant vec3 (3.000000 -0.000000 1.000000)) ) ) (assign (x) (var_ref length_retval@138) (expression float sqrt (expression float dot (var_ref x@139) (var_ref x@139) ) ) ) (if (expression bool <= (var_ref length_retval@138) (constant float (1.500000)) ) ( (declare (temporary ) float assignment_tmp@140) (assign (x) (var_ref assignment_tmp@140) (expression float + (var_ref assignment_tmp@137) (expression float neg (expression float sqrt (expression float + (constant float (2.250000)) (expression float neg (expression float * (var_ref length_retval@138) (var_ref length_retval@138) ) ) ) ) ) ) ) (if (expression bool && (expression bool && (expression bool >= (var_ref assignment_tmp@140) (constant float (0.000000)) ) (expression bool >= (var_ref assignment_tmp@140) (constant float (0.000010)) ) ) (expression bool <= (var_ref assignment_tmp@140) (var_ref isec_t@129) ) ) ( (assign (x) (var_ref isec_t@134) (var_ref assignment_tmp@140) ) (assign (x) (var_ref isec_idx@135) (constant int (1)) ) ) ()) ) ()) (assign (x) (var_ref nearest_idx) (var_ref isec_idx@135) ) (declare (temporary ) float isec_t@141) (declare (temporary ) int isec_idx@142) (assign (x) (var_ref isec_t@141) (var_ref isec_t@134) ) (assign (x) (var_ref isec_idx@142) (var_ref isec_idx@135) ) (declare (temporary ) vec3 assignment_tmp@143) (assign (xyz) (var_ref assignment_tmp@143) (expression vec3 neg (var_ref normalize_retval) ) ) (declare (temporary ) float assignment_tmp@144) (assign (x) (var_ref assignment_tmp@144) (expression float * (expression float dot (expression vec3 + (constant vec3 (0.000000 3.000000 -1.000000)) (expression vec3 neg (var_ref cameraPos) ) ) (var_ref assignment_tmp@143) ) (expression float rcp (expression float dot (var_ref assignment_tmp@143) (var_ref normalize_retval) ) ) ) ) (declare (temporary ) float length_retval@145) (declare () vec3 x@146) (assign (xyz) (var_ref x@146) (expression vec3 + (expression vec3 + (var_ref cameraPos) (expression vec3 * (var_ref normalize_retval) (var_ref assignment_tmp@144) ) ) (constant vec3 (-0.000000 -3.000000 1.000000)) ) ) (assign (x) (var_ref length_retval@145) (expression float sqrt (expression float dot (var_ref x@146) (var_ref x@146) ) ) ) (if (expression bool <= (var_ref length_retval@145) (constant float (0.500000)) ) ( (declare (temporary ) float assignment_tmp@147) (assign (x) (var_ref assignment_tmp@147) (expression float + (var_ref assignment_tmp@144) (expression float neg (expression float sqrt (expression float + (constant float (0.250000)) (expression float neg (expression float * (var_ref length_retval@145) (var_ref length_retval@145) ) ) ) ) ) ) ) (if (expression bool && (expression bool && (expression bool >= (var_ref assignment_tmp@147) (constant float (0.000000)) ) (expression bool >= (var_ref assignment_tmp@147) (constant float (0.000010)) ) ) (expression bool <= (var_ref assignment_tmp@147) (var_ref isec_t@134) ) ) ( (assign (x) (var_ref isec_t@141) (var_ref assignment_tmp@147) ) (assign (x) (var_ref isec_idx@142) (constant int (2)) ) ) ()) ) ()) (assign (x) (var_ref nearest_idx) (var_ref isec_idx@142) ) (declare (temporary ) float isec_t@148) (declare (temporary ) int isec_idx@149) (assign (x) (var_ref isec_t@148) (var_ref isec_t@141) ) (assign (x) (var_ref isec_idx@149) (var_ref isec_idx@142) ) (declare (temporary ) vec3 assignment_tmp@150) (assign (xyz) (var_ref assignment_tmp@150) (expression vec3 neg (var_ref normalize_retval) ) ) (declare (temporary ) float assignment_tmp@151) (assign (x) (var_ref assignment_tmp@151) (expression float * (expression float dot (expression vec3 + (constant vec3 (2.000000 0.000000 -1.000000)) (expression vec3 neg (var_ref cameraPos) ) ) (var_ref assignment_tmp@150) ) (expression float rcp (expression float dot (var_ref assignment_tmp@150) (var_ref normalize_retval) ) ) ) ) (declare (temporary ) float length_retval@152) (declare () vec3 x@153) (assign (xyz) (var_ref x@153) (expression vec3 + (expression vec3 + (var_ref cameraPos) (expression vec3 * (var_ref normalize_retval) (var_ref assignment_tmp@151) ) ) (constant vec3 (-2.000000 -0.000000 1.000000)) ) ) (assign (x) (var_ref length_retval@152) (expression float sqrt (expression float dot (var_ref x@153) (var_ref x@153) ) ) ) (if (expression bool <= (var_ref length_retval@152) (constant float (1.000000)) ) ( (declare (temporary ) float assignment_tmp@154) (assign (x) (var_ref assignment_tmp@154) (expression float + (var_ref assignment_tmp@151) (expression float neg (expression float sqrt (expression float + (constant float (1.000000)) (expression float neg (expression float * (var_ref length_retval@152) (var_ref length_retval@152) ) ) ) ) ) ) ) (if (expression bool && (expression bool && (expression bool >= (var_ref assignment_tmp@154) (constant float (0.000000)) ) (expression bool >= (var_ref assignment_tmp@154) (constant float (0.000010)) ) ) (expression bool <= (var_ref assignment_tmp@154) (var_ref isec_t@141) ) ) ( (assign (x) (var_ref isec_t@148) (var_ref assignment_tmp@154) ) (assign (x) (var_ref isec_idx@149) (constant int (3)) ) ) ()) ) ()) (assign (x) (var_ref nearest_idx) (var_ref isec_idx@149) ) (declare (temporary ) float isec_t@155) (declare (temporary ) int isec_idx@156) (assign (x) (var_ref isec_t@155) (var_ref isec_t@148) ) (assign (x) (var_ref isec_idx@156) (var_ref isec_idx@149) ) (declare (temporary ) vec3 assignment_tmp@157) (assign (xyz) (var_ref assignment_tmp@157) (expression vec3 neg (var_ref normalize_retval) ) ) (declare (temporary ) float assignment_tmp@158) (assign (x) (var_ref assignment_tmp@158) (expression float * (expression float dot (expression vec3 + (constant vec3 (0.000000 -11.000000 -1.000000)) (expression vec3 neg (var_ref cameraPos) ) ) (var_ref assignment_tmp@157) ) (expression float rcp (expression float dot (var_ref assignment_tmp@157) (var_ref normalize_retval) ) ) ) ) (declare (temporary ) float length_retval@159) (declare () vec3 x@160) (assign (xyz) (var_ref x@160) (expression vec3 + (expression vec3 + (var_ref cameraPos) (expression vec3 * (var_ref normalize_retval) (var_ref assignment_tmp@158) ) ) (constant vec3 (-0.000000 11.000000 1.000000)) ) ) (assign (x) (var_ref length_retval@159) (expression float sqrt (expression float dot (var_ref x@160) (var_ref x@160) ) ) ) (if (expression bool <= (var_ref length_retval@159) (constant float (10.000000)) ) ( (declare (temporary ) float assignment_tmp@161) (assign (x) (var_ref assignment_tmp@161) (expression float + (var_ref assignment_tmp@158) (expression float neg (expression float sqrt (expression float + (constant float (100.000000)) (expression float neg (expression float * (var_ref length_retval@159) (var_ref length_retval@159) ) ) ) ) ) ) ) (if (expression bool && (expression bool && (expression bool >= (var_ref assignment_tmp@161) (constant float (0.000000)) ) (expression bool >= (var_ref assignment_tmp@161) (constant float (0.000010)) ) ) (expression bool <= (var_ref assignment_tmp@161) (var_ref isec_t@148) ) ) ( (assign (x) (var_ref isec_t@155) (var_ref assignment_tmp@161) ) (assign (x) (var_ref isec_idx@156) (constant int (4)) ) ) ()) ) ()) (assign (x) (var_ref nearest_idx) (var_ref isec_idx@156) ) (assign (x) (var_ref isec_t) (var_ref isec_t@155) ) (assign (x) (var_ref isec_idx) (var_ref isec_idx@156) ) ) ( (if (expression bool all_equal (var_ref state) (constant int (1)) ) ( (declare (temporary ) int nearest_idx@162) (assign (x) (var_ref nearest_idx@162) (constant int (-1)) ) (declare (temporary ) float isec_t@163) (declare (temporary ) int isec_idx@164) (assign (x) (var_ref isec_t@163) (var_ref isec_t) ) (assign (x) (var_ref isec_idx@164) (var_ref nearest_idx@162) ) (declare (temporary ) vec3 assignment_tmp@165) (assign (xyz) (var_ref assignment_tmp@165) (expression vec3 neg (var_ref ray_dir) ) ) (declare (temporary ) float assignment_tmp@166) (assign (x) (var_ref assignment_tmp@166) (expression float * (expression float dot (expression vec3 + (constant vec3 (0.000000 0.000000 -1.000000)) (expression vec3 neg (var_ref ray_orig) ) ) (var_ref assignment_tmp@165) ) (expression float rcp (expression float dot (var_ref assignment_tmp@165) (var_ref ray_dir) ) ) ) ) (declare (temporary ) float length_retval@167) (declare () vec3 x@168) (assign (xyz) (var_ref x@168) (expression vec3 + (expression vec3 + (var_ref ray_orig) (expression vec3 * (var_ref ray_dir) (var_ref assignment_tmp@166) ) ) (constant vec3 (-0.000000 -0.000000 1.000000)) ) ) (assign (x) (var_ref length_retval@167) (expression float sqrt (expression float dot (var_ref x@168) (var_ref x@168) ) ) ) (if (expression bool <= (var_ref length_retval@167) (constant float (0.500000)) ) ( (declare (temporary ) float assignment_tmp@169) (assign (x) (var_ref assignment_tmp@169) (expression float + (var_ref assignment_tmp@166) (expression float neg (expression float sqrt (expression float + (constant float (0.250000)) (expression float neg (expression float * (var_ref length_retval@167) (var_ref length_retval@167) ) ) ) ) ) ) ) (if (expression bool && (expression bool && (expression bool >= (var_ref assignment_tmp@169) (constant float (0.000000)) ) (expression bool >= (var_ref assignment_tmp@169) (constant float (0.000010)) ) ) (expression bool <= (var_ref assignment_tmp@169) (var_ref isec_t) ) ) ( (assign (x) (var_ref isec_t@163) (var_ref assignment_tmp@169) ) (assign (x) (var_ref isec_idx@164) (constant int (0)) ) ) ()) ) ()) (assign (x) (var_ref nearest_idx@162) (var_ref isec_idx@164) ) (declare (temporary ) float isec_t@170) (declare (temporary ) int isec_idx@171) (assign (x) (var_ref isec_t@170) (var_ref isec_t@163) ) (assign (x) (var_ref isec_idx@171) (var_ref isec_idx@164) ) (declare (temporary ) vec3 assignment_tmp@172) (assign (xyz) (var_ref assignment_tmp@172) (expression vec3 neg (var_ref ray_dir) ) ) (declare (temporary ) float assignment_tmp@173) (assign (x) (var_ref assignment_tmp@173) (expression float * (expression float dot (expression vec3 + (constant vec3 (-3.000000 0.000000 -1.000000)) (expression vec3 neg (var_ref ray_orig) ) ) (var_ref assignment_tmp@172) ) (expression float rcp (expression float dot (var_ref assignment_tmp@172) (var_ref ray_dir) ) ) ) ) (declare (temporary ) float length_retval@174) (declare () vec3 x@175) (assign (xyz) (var_ref x@175) (expression vec3 + (expression vec3 + (var_ref ray_orig) (expression vec3 * (var_ref ray_dir) (var_ref assignment_tmp@173) ) ) (constant vec3 (3.000000 -0.000000 1.000000)) ) ) (assign (x) (var_ref length_retval@174) (expression float sqrt (expression float dot (var_ref x@175) (var_ref x@175) ) ) ) (if (expression bool <= (var_ref length_retval@174) (constant float (1.500000)) ) ( (declare (temporary ) float assignment_tmp@176) (assign (x) (var_ref assignment_tmp@176) (expression float + (var_ref assignment_tmp@173) (expression float neg (expression float sqrt (expression float + (constant float (2.250000)) (expression float neg (expression float * (var_ref length_retval@174) (var_ref length_retval@174) ) ) ) ) ) ) ) (if (expression bool && (expression bool && (expression bool >= (var_ref assignment_tmp@176) (constant float (0.000000)) ) (expression bool >= (var_ref assignment_tmp@176) (constant float (0.000010)) ) ) (expression bool <= (var_ref assignment_tmp@176) (var_ref isec_t@163) ) ) ( (assign (x) (var_ref isec_t@170) (var_ref assignment_tmp@176) ) (assign (x) (var_ref isec_idx@171) (constant int (1)) ) ) ()) ) ()) (assign (x) (var_ref nearest_idx@162) (var_ref isec_idx@171) ) (declare (temporary ) float isec_t@177) (declare (temporary ) int isec_idx@178) (assign (x) (var_ref isec_t@177) (var_ref isec_t@170) ) (assign (x) (var_ref isec_idx@178) (var_ref isec_idx@171) ) (declare (temporary ) vec3 assignment_tmp@179) (assign (xyz) (var_ref assignment_tmp@179) (expression vec3 neg (var_ref ray_dir) ) ) (declare (temporary ) float assignment_tmp@180) (assign (x) (var_ref assignment_tmp@180) (expression float * (expression float dot (expression vec3 + (constant vec3 (0.000000 3.000000 -1.000000)) (expression vec3 neg (var_ref ray_orig) ) ) (var_ref assignment_tmp@179) ) (expression float rcp (expression float dot (var_ref assignment_tmp@179) (var_ref ray_dir) ) ) ) ) (declare (temporary ) float length_retval@181) (declare () vec3 x@182) (assign (xyz) (var_ref x@182) (expression vec3 + (expression vec3 + (var_ref ray_orig) (expression vec3 * (var_ref ray_dir) (var_ref assignment_tmp@180) ) ) (constant vec3 (-0.000000 -3.000000 1.000000)) ) ) (assign (x) (var_ref length_retval@181) (expression float sqrt (expression float dot (var_ref x@182) (var_ref x@182) ) ) ) (if (expression bool <= (var_ref length_retval@181) (constant float (0.500000)) ) ( (declare (temporary ) float assignment_tmp@183) (assign (x) (var_ref assignment_tmp@183) (expression float + (var_ref assignment_tmp@180) (expression float neg (expression float sqrt (expression float + (constant float (0.250000)) (expression float neg (expression float * (var_ref length_retval@181) (var_ref length_retval@181) ) ) ) ) ) ) ) (if (expression bool && (expression bool && (expression bool >= (var_ref assignment_tmp@183) (constant float (0.000000)) ) (expression bool >= (var_ref assignment_tmp@183) (constant float (0.000010)) ) ) (expression bool <= (var_ref assignment_tmp@183) (var_ref isec_t@170) ) ) ( (assign (x) (var_ref isec_t@177) (var_ref assignment_tmp@183) ) (assign (x) (var_ref isec_idx@178) (constant int (2)) ) ) ()) ) ()) (assign (x) (var_ref nearest_idx@162) (var_ref isec_idx@178) ) (declare (temporary ) float isec_t@184) (declare (temporary ) int isec_idx@185) (assign (x) (var_ref isec_t@184) (var_ref isec_t@177) ) (assign (x) (var_ref isec_idx@185) (var_ref isec_idx@178) ) (declare (temporary ) vec3 assignment_tmp@186) (assign (xyz) (var_ref assignment_tmp@186) (expression vec3 neg (var_ref ray_dir) ) ) (declare (temporary ) float assignment_tmp@187) (assign (x) (var_ref assignment_tmp@187) (expression float * (expression float dot (expression vec3 + (constant vec3 (2.000000 0.000000 -1.000000)) (expression vec3 neg (var_ref ray_orig) ) ) (var_ref assignment_tmp@186) ) (expression float rcp (expression float dot (var_ref assignment_tmp@186) (var_ref ray_dir) ) ) ) ) (declare (temporary ) float length_retval@188) (declare () vec3 x@189) (assign (xyz) (var_ref x@189) (expression vec3 + (expression vec3 + (var_ref ray_orig) (expression vec3 * (var_ref ray_dir) (var_ref assignment_tmp@187) ) ) (constant vec3 (-2.000000 -0.000000 1.000000)) ) ) (assign (x) (var_ref length_retval@188) (expression float sqrt (expression float dot (var_ref x@189) (var_ref x@189) ) ) ) (if (expression bool <= (var_ref length_retval@188) (constant float (1.000000)) ) ( (declare (temporary ) float assignment_tmp@190) (assign (x) (var_ref assignment_tmp@190) (expression float + (var_ref assignment_tmp@187) (expression float neg (expression float sqrt (expression float + (constant float (1.000000)) (expression float neg (expression float * (var_ref length_retval@188) (var_ref length_retval@188) ) ) ) ) ) ) ) (if (expression bool && (expression bool && (expression bool >= (var_ref assignment_tmp@190) (constant float (0.000000)) ) (expression bool >= (var_ref assignment_tmp@190) (constant float (0.000010)) ) ) (expression bool <= (var_ref assignment_tmp@190) (var_ref isec_t@177) ) ) ( (assign (x) (var_ref isec_t@184) (var_ref assignment_tmp@190) ) (assign (x) (var_ref isec_idx@185) (constant int (3)) ) ) ()) ) ()) (assign (x) (var_ref nearest_idx@162) (var_ref isec_idx@185) ) (declare (temporary ) float isec_t@191) (declare (temporary ) int isec_idx@192) (assign (x) (var_ref isec_t@191) (var_ref isec_t@184) ) (assign (x) (var_ref isec_idx@192) (var_ref isec_idx@185) ) (declare (temporary ) vec3 assignment_tmp@193) (assign (xyz) (var_ref assignment_tmp@193) (expression vec3 neg (var_ref ray_dir) ) ) (declare (temporary ) float assignment_tmp@194) (assign (x) (var_ref assignment_tmp@194) (expression float * (expression float dot (expression vec3 + (constant vec3 (0.000000 -11.000000 -1.000000)) (expression vec3 neg (var_ref ray_orig) ) ) (var_ref assignment_tmp@193) ) (expression float rcp (expression float dot (var_ref assignment_tmp@193) (var_ref ray_dir) ) ) ) ) (declare (temporary ) float length_retval@195) (declare () vec3 x@196) (assign (xyz) (var_ref x@196) (expression vec3 + (expression vec3 + (var_ref ray_orig) (expression vec3 * (var_ref ray_dir) (var_ref assignment_tmp@194) ) ) (constant vec3 (-0.000000 11.000000 1.000000)) ) ) (assign (x) (var_ref length_retval@195) (expression float sqrt (expression float dot (var_ref x@196) (var_ref x@196) ) ) ) (if (expression bool <= (var_ref length_retval@195) (constant float (10.000000)) ) ( (declare (temporary ) float assignment_tmp@197) (assign (x) (var_ref assignment_tmp@197) (expression float + (var_ref assignment_tmp@194) (expression float neg (expression float sqrt (expression float + (constant float (100.000000)) (expression float neg (expression float * (var_ref length_retval@195) (var_ref length_retval@195) ) ) ) ) ) ) ) (if (expression bool && (expression bool && (expression bool >= (var_ref assignment_tmp@197) (constant float (0.000000)) ) (expression bool >= (var_ref assignment_tmp@197) (constant float (0.000010)) ) ) (expression bool <= (var_ref assignment_tmp@197) (var_ref isec_t@184) ) ) ( (assign (x) (var_ref isec_t@191) (var_ref assignment_tmp@197) ) (assign (x) (var_ref isec_idx@192) (constant int (4)) ) ) ()) ) ()) (assign (x) (var_ref nearest_idx@162) (var_ref isec_idx@192) ) (assign (x) (var_ref isec_t) (var_ref isec_t@191) ) (assign (x) (var_ref isec_idx) (var_ref isec_idx@192) ) ) ()) )) (assign (xyzw) (var_ref gl_Position) (var_ref pos) ) (assign (xyz) (var_ref orig_t1) (var_ref ray_orig) ) (assign (w) (var_ref orig_t1) (var_ref isec_t) ) (assign (xyz) (var_ref dir_idx1) (var_ref ray_dir) ) (assign (w) (var_ref dir_idx1) (expression float i2f (var_ref isec_idx) ) ) (assign (z) (var_ref uv_state1) (expression float i2f (var_ref state) ) ) (assign (w) (var_ref uv_state1) (expression float i2f (var_ref type) ) ) (assign (xyzw) (var_ref uv_state1@198) (var_ref uv_state1) ) (assign (xyzw) (var_ref dir_idx1@199) (var_ref dir_idx1) ) (assign (xyzw) (var_ref orig_t1@200) (var_ref orig_t1) ) (assign (xyzw) (var_ref gl_Position@201) (var_ref gl_Position) ) )) ) ) GLSL IR for linked geometry program 4: ( (declare (shader_in ) (array vec4 1) gl_Position) (declare (shader_in flat) (array vec4 1) dir_idx1) (declare (shader_in flat) (array vec4 1) orig_t1) (declare (shader_in flat) (array vec4 1) uv_state1) (declare (shader_out ) vec4 gl_Position) (declare (temporary ) vec4 gl_Position) (declare (temporary ) vec4 gl_Position) (declare (temporary ) vec4 gl_Position) (declare (shader_out ) vec4 dir_idx2) (declare (temporary ) vec4 dir_idx2) (declare (temporary ) vec4 dir_idx2) (declare (temporary ) vec4 dir_idx2) (declare (shader_out ) vec4 orig_t2) (declare (temporary ) vec4 orig_t2) (declare (temporary ) vec4 orig_t2) (declare (temporary ) vec4 orig_t2) (declare (shader_out ) vec4 uv_state2) (declare (temporary ) vec4 uv_state2) (declare (temporary ) vec4 uv_state2) (declare (temporary ) vec4 uv_state2) (declare (uniform ) vec3 lightPos) (declare (uniform ) int emitNoMore) (function main (signature void (parameters ) ( (declare () int type) (declare (temporary ) vec3 record_ctor_orig) (declare (temporary ) vec3 record_ctor_dir) (assign (xyz) (var_ref record_ctor_orig) (swiz xyz (array_ref (var_ref orig_t1) (constant int (0)) ) )) (assign (xyz) (var_ref record_ctor_dir) (swiz xyz (array_ref (var_ref dir_idx1) (constant int (0)) ) )) (declare (temporary ) float record_ctor_t) (declare (temporary ) int record_ctor_idx) (assign (x) (var_ref record_ctor_t) (swiz w (array_ref (var_ref orig_t1) (constant int (0)) ) )) (assign (x) (var_ref record_ctor_idx) (expression int f2i (swiz w (array_ref (var_ref dir_idx1) (constant int (0)) ) )) ) (declare (temporary ) int assignment_tmp) (assign (x) (var_ref assignment_tmp) (expression int f2i (swiz z (array_ref (var_ref uv_state1) (constant int (0)) ) )) ) (assign (x) (var_ref type) (expression int f2i (swiz w (array_ref (var_ref uv_state1) (constant int (0)) ) )) ) (if (expression bool && (expression bool <= (var_ref assignment_tmp) (constant int (1)) ) (expression bool any_nequal (var_ref record_ctor_idx) (constant int (-1)) ) ) ( (assign (xyzw) (var_ref gl_Position) (array_ref (var_ref gl_Position@202) (constant int (0)) ) ) (assign (xyzw) (var_ref orig_t2) (array_ref (var_ref orig_t1) (constant int (0)) ) ) (assign (xyzw) (var_ref dir_idx2) (array_ref (var_ref dir_idx1) (constant int (0)) ) ) (assign (xyw) (var_ref uv_state2) (swiz xyw (array_ref (var_ref uv_state1) (constant int (0)) ) )) (assign (z) (var_ref uv_state2) (constant float (3.000000)) ) (assign (xyzw) (var_ref uv_state2@203) (var_ref uv_state2) ) (assign (xyzw) (var_ref dir_idx2@204) (var_ref dir_idx2) ) (assign (xyzw) (var_ref orig_t2@205) (var_ref orig_t2) ) (assign (xyzw) (var_ref gl_Position@206) (var_ref gl_Position) ) (emit-vertex (constant int (0)) ) (end-primitive (constant int (0)) ) (if (expression bool ! (expression bool || (expression bool any_nequal (var_ref type) (constant int (0)) ) (expression bool > (var_ref emitNoMore) (constant int (0)) ) ) ) ( (declare (temporary ) vec3 isec_n) (declare (temporary ) Sphere@0x84a2a8c assignment_tmp@207) (assign () (var_ref assignment_tmp@207) (array_ref (constant (array Sphere@0x84a2a8c 5) ((constant Sphere@0x84a2a8c ((c (constant vec3 (0.000000 0.000000 -1.000000)) )(r (constant float (0.500000)) ))) (constant Sphere@0x84a2a8c ((c (constant vec3 (-3.000000 0.000000 -1.000000)) )(r (constant float (1.500000)) ))) (constant Sphere@0x84a2a8c ((c (constant vec3 (0.000000 3.000000 -1.000000)) )(r (constant float (0.500000)) ))) (constant Sphere@0x84a2a8c ((c (constant vec3 (2.000000 0.000000 -1.000000)) )(r (constant float (1.000000)) ))) (constant Sphere@0x84a2a8c ((c (constant vec3 (0.000000 -11.000000 -1.000000)) )(r (constant float (10.000000)) ))) )) (var_ref record_ctor_idx) ) ) (assign (xyz) (var_ref isec_n) (expression vec3 * (expression vec3 + (expression vec3 + (var_ref record_ctor_orig) (expression vec3 * (var_ref record_ctor_dir) (var_ref record_ctor_t) ) ) (expression vec3 neg (record_ref (var_ref assignment_tmp@207) c) ) ) (expression float rcp (record_ref (var_ref assignment_tmp@207) r) ) ) ) (declare (temporary ) vec3 assignment_tmp@208) (assign (xyz) (var_ref assignment_tmp@208) (expression vec3 + (expression vec3 + (var_ref record_ctor_orig) (expression vec3 * (var_ref record_ctor_dir) (var_ref record_ctor_t) ) ) (expression vec3 * (var_ref isec_n) (constant float (0.000010)) ) ) ) (declare (temporary ) vec3 assignment_tmp@209) (assign (xyz) (var_ref assignment_tmp@209) (expression vec3 + (var_ref lightPos) (expression vec3 neg (var_ref assignment_tmp@208) ) ) ) (declare (temporary ) float length_retval) (assign (x) (var_ref length_retval) (expression float sqrt (expression float dot (var_ref assignment_tmp@209) (var_ref assignment_tmp@209) ) ) ) (assign (xyzw) (var_ref gl_Position@210) (array_ref (var_ref gl_Position@202) (constant int (0)) ) ) (assign (xyz) (var_ref orig_t2@211) (var_ref assignment_tmp@208) ) (assign (w) (var_ref orig_t2@211) (var_ref length_retval) ) (assign (xyz) (var_ref dir_idx2@212) (expression vec3 * (var_ref assignment_tmp@209) (expression float rcp (var_ref length_retval) ) ) ) (assign (w) (var_ref dir_idx2@212) (constant float (-1.000000)) ) (assign (z) (var_ref uv_state2@213) (constant float (1.000000)) ) (assign (w) (var_ref uv_state2@213) (constant float (1.000000)) ) (assign (xyzw) (var_ref uv_state2@203) (var_ref uv_state2@213) ) (assign (xyzw) (var_ref dir_idx2@204) (var_ref dir_idx2@212) ) (assign (xyzw) (var_ref orig_t2@205) (var_ref orig_t2@211) ) (assign (xyzw) (var_ref gl_Position@206) (var_ref gl_Position@210) ) (emit-vertex (constant int (0)) ) (end-primitive (constant int (0)) ) (assign (x) (var_ref type) (constant int (-1)) ) (assign (xyzw) (var_ref gl_Position@214) (array_ref (var_ref gl_Position@202) (constant int (0)) ) ) (assign (xyz) (var_ref orig_t2@215) (var_ref assignment_tmp@208) ) (assign (w) (var_ref orig_t2@215) (constant float (9999.900391)) ) (assign (xyz) (var_ref dir_idx2@216) (expression vec3 + (var_ref record_ctor_dir) (expression vec3 neg (expression vec3 * (constant float (2.000000)) (expression vec3 * (expression float dot (var_ref isec_n) (var_ref record_ctor_dir) ) (var_ref isec_n) ) ) ) ) ) (assign (w) (var_ref dir_idx2@216) (constant float (-1.000000)) ) (assign (z) (var_ref uv_state2@217) (constant float (1.000000)) ) (assign (w) (var_ref uv_state2@217) (constant float (-1.000000)) ) (assign (xyzw) (var_ref uv_state2@203) (var_ref uv_state2@217) ) (assign (xyzw) (var_ref dir_idx2@204) (var_ref dir_idx2@216) ) (assign (xyzw) (var_ref orig_t2@205) (var_ref orig_t2@215) ) (assign (xyzw) (var_ref gl_Position@206) (var_ref gl_Position@214) ) (emit-vertex (constant int (0)) ) (end-primitive (constant int (0)) ) ) ()) ) ()) )) ) ) GLSL IR for linked fragment program 4: ( (declare (shader_in ) vec4 dir_idx2) (declare (shader_in ) vec4 orig_t2) (declare (shader_in ) vec4 uv_state2) (declare (uniform ) vec3 lightPos) (declare (uniform ) vec4 backgroundColor) (declare (shader_out ) vec4 frag_color) (declare (temporary ) vec4 frag_color) (function main (signature void (parameters ) ( (declare () vec3 lightVec) (declare (temporary ) int record_ctor_idx) (assign (x) (var_ref record_ctor_idx) (expression int f2i (swiz w (var_ref dir_idx2) )) ) (declare (temporary ) int assignment_tmp) (assign (x) (var_ref assignment_tmp) (expression int f2i (swiz z (var_ref uv_state2) )) ) (declare (temporary ) int assignment_tmp@218) (assign (x) (var_ref assignment_tmp@218) (expression int f2i (swiz w (var_ref uv_state2) )) ) (if (expression bool < (var_ref assignment_tmp) (constant int (3)) ) ( (discard ) ) ()) (if (expression bool all_equal (var_ref assignment_tmp@218) (constant int (0)) ) ( (declare () vec3 lightVec@219) (if (expression bool all_equal (var_ref record_ctor_idx) (constant int (-1)) ) ( (declare (temporary ) vec4 vec_ctor) (assign (w) (var_ref vec_ctor) (constant float (0.000000)) ) (assign (xyz) (var_ref vec_ctor) (swiz xyz (var_ref backgroundColor) )) (assign (xyzw) (var_ref frag_color) (var_ref vec_ctor) ) ) ( (declare () vec3 cse) (assign (xyz) (var_ref cse) (expression vec3 * (swiz xyz (var_ref dir_idx2) )(swiz w (var_ref orig_t2) )) ) (assign (xyz) (var_ref lightVec@219) (expression vec3 + (var_ref lightPos) (expression vec3 neg (expression vec3 + (swiz xyz (var_ref orig_t2) )(var_ref cse) ) ) ) ) (declare (temporary ) Sphere@0x84a2a8c assignment_tmp@220) (assign () (var_ref assignment_tmp@220) (array_ref (constant (array Sphere@0x84a2a8c 5) ((constant Sphere@0x84a2a8c ((c (constant vec3 (0.000000 0.000000 -1.000000)) )(r (constant float (0.500000)) ))) (constant Sphere@0x84a2a8c ((c (constant vec3 (-3.000000 0.000000 -1.000000)) )(r (constant float (1.500000)) ))) (constant Sphere@0x84a2a8c ((c (constant vec3 (0.000000 3.000000 -1.000000)) )(r (constant float (0.500000)) ))) (constant Sphere@0x84a2a8c ((c (constant vec3 (2.000000 0.000000 -1.000000)) )(r (constant float (1.000000)) ))) (constant Sphere@0x84a2a8c ((c (constant vec3 (0.000000 -11.000000 -1.000000)) )(r (constant float (10.000000)) ))) )) (var_ref record_ctor_idx) ) ) (declare (temporary ) float max_retval) (assign (x) (var_ref max_retval) (expression float max (expression float dot (expression vec3 * (expression vec3 + (expression vec3 + (swiz xyz (var_ref orig_t2) )(var_ref cse) ) (expression vec3 neg (record_ref (var_ref assignment_tmp@220) c) ) ) (expression float rcp (record_ref (var_ref assignment_tmp@220) r) ) ) (expression vec3 * (var_ref lightVec@219) (expression float rsq (expression float dot (var_ref lightVec@219) (var_ref lightVec@219) ) ) ) ) (constant float (0.000000)) ) ) (declare () vec3 diff) (if (expression bool all_equal (var_ref record_ctor_idx) (constant int (0)) ) ( (assign (xyz) (var_ref diff) (constant vec3 (1.000000 0.000000 0.000000)) ) ) ( (if (expression bool all_equal (var_ref record_ctor_idx) (constant int (1)) ) ( (assign (xyz) (var_ref diff) (constant vec3 (0.000000 1.000000 0.000000)) ) ) ( (if (expression bool all_equal (var_ref record_ctor_idx) (constant int (2)) ) ( (assign (xyz) (var_ref diff) (constant vec3 (0.000000 0.000000 1.000000)) ) ) ( (if (expression bool all_equal (var_ref record_ctor_idx) (constant int (3)) ) ( (assign (xyz) (var_ref diff) (constant vec3 (1.000000 1.000000 0.000000)) ) ) ( (if (expression bool all_equal (var_ref record_ctor_idx) (constant int (4)) ) ( (assign (xyz) (var_ref diff) (constant vec3 (0.700000 0.700000 0.700000)) ) ) ()) )) )) )) )) (declare (temporary ) vec4 vec_ctor@221) (assign (w) (var_ref vec_ctor@221) (constant float (1.000000)) ) (assign (xyz) (var_ref vec_ctor@221) (expression vec3 * (var_ref diff) (var_ref max_retval) ) ) (assign (xyzw) (var_ref frag_color) (var_ref vec_ctor@221) ) )) ) ( (if (expression bool > (var_ref assignment_tmp@218) (constant int (0)) ) ( (if (expression bool all_equal (var_ref record_ctor_idx) (constant int (-1)) ) ( (discard ) ) ()) (assign (xyzw) (var_ref frag_color) (constant vec4 (-1.000000 -1.000000 -1.000000 0.000000)) ) ) ( (if (expression bool all_equal (var_ref record_ctor_idx) (constant int (-1)) ) ( (discard ) ) ()) (declare () vec3 cse@222) (assign (xyz) (var_ref cse@222) (expression vec3 * (swiz xyz (var_ref dir_idx2) )(swiz w (var_ref orig_t2) )) ) (assign (xyz) (var_ref lightVec) (expression vec3 + (var_ref lightPos) (expression vec3 neg (expression vec3 + (swiz xyz (var_ref orig_t2) )(var_ref cse@222) ) ) ) ) (declare (temporary ) Sphere@0x84a2a8c assignment_tmp@223) (assign () (var_ref assignment_tmp@223) (array_ref (constant (array Sphere@0x84a2a8c 5) ((constant Sphere@0x84a2a8c ((c (constant vec3 (0.000000 0.000000 -1.000000)) )(r (constant float (0.500000)) ))) (constant Sphere@0x84a2a8c ((c (constant vec3 (-3.000000 0.000000 -1.000000)) )(r (constant float (1.500000)) ))) (constant Sphere@0x84a2a8c ((c (constant vec3 (0.000000 3.000000 -1.000000)) )(r (constant float (0.500000)) ))) (constant Sphere@0x84a2a8c ((c (constant vec3 (2.000000 0.000000 -1.000000)) )(r (constant float (1.000000)) ))) (constant Sphere@0x84a2a8c ((c (constant vec3 (0.000000 -11.000000 -1.000000)) )(r (constant float (10.000000)) ))) )) (var_ref record_ctor_idx) ) ) (declare (temporary ) float max_retval@224) (assign (x) (var_ref max_retval@224) (expression float max (expression float dot (expression vec3 * (expression vec3 + (expression vec3 + (swiz xyz (var_ref orig_t2) )(var_ref cse@222) ) (expression vec3 neg (record_ref (var_ref assignment_tmp@223) c) ) ) (expression float rcp (record_ref (var_ref assignment_tmp@223) r) ) ) (expression vec3 * (var_ref lightVec) (expression float rsq (expression float dot (var_ref lightVec) (var_ref lightVec) ) ) ) ) (constant float (0.000000)) ) ) (declare () vec3 diff@225) (if (expression bool all_equal (var_ref record_ctor_idx) (constant int (0)) ) ( (assign (xyz) (var_ref diff@225) (constant vec3 (1.000000 0.000000 0.000000)) ) ) ( (if (expression bool all_equal (var_ref record_ctor_idx) (constant int (1)) ) ( (assign (xyz) (var_ref diff@225) (constant vec3 (0.000000 1.000000 0.000000)) ) ) ( (if (expression bool all_equal (var_ref record_ctor_idx) (constant int (2)) ) ( (assign (xyz) (var_ref diff@225) (constant vec3 (0.000000 0.000000 1.000000)) ) ) ( (if (expression bool all_equal (var_ref record_ctor_idx) (constant int (3)) ) ( (assign (xyz) (var_ref diff@225) (constant vec3 (1.000000 1.000000 0.000000)) ) ) ( (if (expression bool all_equal (var_ref record_ctor_idx) (constant int (4)) ) ( (assign (xyz) (var_ref diff@225) (constant vec3 (0.700000 0.700000 0.700000)) ) ) ()) )) )) )) )) (declare (temporary ) vec4 vec_ctor@226) (assign (w) (var_ref vec_ctor@226) (constant float (1.000000)) ) (assign (xyz) (var_ref vec_ctor@226) (expression vec3 * (expression vec3 * (var_ref diff@225) (var_ref max_retval@224) ) (constant float (0.250000)) ) ) (assign (xyzw) (var_ref frag_color) (var_ref vec_ctor@226) ) )) )) (assign (xyzw) (var_ref frag_color@227) (var_ref frag_color) ) )) ) ) GL_RENDERER = Gallium 0.4 on AMD RV730 ESC = exit demo left mouse + drag = rotate camera GLSL IR for linked fragment program 0: ( (declare (shader_in ) vec4 gl_Color) (declare (shader_out ) vec4 gl_FragColor) (declare (temporary ) vec4 gl_FragColor) (function main (signature void (parameters ) ( (assign (xyzw) (var_ref gl_FragColor) (var_ref gl_Color) ) (assign (xyzw) (var_ref gl_FragColor@228) (var_ref gl_FragColor) ) )) ) ) 0.043789 FPS (1 frames in 22.837000 seconds) GLSL IR for linked fragment program 0: ( (declare (uniform ) (array vec4 4) gl_CurrentAttribFragMESA) (declare (shader_out ) vec4 gl_FragColor) (declare (temporary ) vec4 gl_FragColor) (function main (signature void (parameters ) ( (assign (xyzw) (var_ref gl_FragColor) (array_ref (var_ref gl_CurrentAttribFragMESA) (constant uint (3)) ) ) (assign (xyzw) (var_ref gl_FragColor@229) (var_ref gl_FragColor) ) )) ) ) 0.047181 FPS (1 frames in 21.195000 seconds)