// Copyright (C) 2006 Robert Geist // All rights reserved. #include "xrgba.h" uniform sampler2DRect cloud; uniform sampler2DRect photon; uniform sampler2DRect omega; uniform sampler2DRect directions; #define DIRECTIONS 19 void main(void) { float fEDGE = float(EDGE); float fDIR = float(DIRECTIONS); float i, j, k, m; float row, col, from_m, scatter; vec4 cloud_density, nbr_incoming_color, scattered_in; vec3 from_node, xyzdir; int n; vec4 color; float goober; i = mod(gl_TexCoord[0].t,fEDGE); j = floor(gl_TexCoord[0].s/fDIR); k = floor(gl_TexCoord[0].t/fEDGE); m = mod(gl_TexCoord[0].s,fDIR); // access incoming photon density in direction m from neighbor xyzdir = texture2DRect(directions,vec2(m,0.5)); from_node = vec3(i,j,k) - xyzdir; // build photon texture index; // note this is always called with 1 < k < EDGE/4 -1 row = from_node.z*fEDGE + from_node.x; col = from_node.y*fDIR + m; // grab 4 photon values in parallel color = texture2DRect(photon,vec2(col,row)); // that's it, unless the neighbor had a non-zero cloud density; // in that case, he might have scattered some our way (m) from // other directions cloud_density = texture2DRect(cloud,vec2(from_node.y,row)); // collect the density scattered our way by the neighbor scattered_in = vec4(0.0,0.0,0.0,0.0); for(n=0;n