5 uniform sampler2D tex0;
6 uniform vec2 lightTexSize;
9 // alpha threshold for our occlusion map
10 #define THRESHOLD (0.75)
16 float ltsyStep = 1.0/lightTexSize.y;
17 float theta = PI*1.5+(gl_TexCoord[0].x*2.0-1.0)*PI;
18 float nsint = -sin(theta);
19 float ncost = -cos(theta);
21 for (dst = 0.0; dst < 1.0; dst += ltsyStep) {
22 float r = (1.0+(dst*2.0-1.0))*0.5;
23 // sample the occlusion map
24 float dataa = texture2D(tex0, vec2(r*nsint, r*ncost)*inv2+0.5).a;
25 // if we've hit an opaque fragment (occluder), then get new distance
26 // if the new distance is below the current, then we'll use that for our ray
27 if (dataa > THRESHOLD) break; // the current distance is how far from the top we've come
29 gl_FragColor = vec4(vec3(dst), 1.0);