2013-11-30 16:33:06 -05:00
|
|
|
uniform sampler2D tex;
|
|
|
|
uniform vec2 sunpos;
|
|
|
|
|
|
|
|
#define SAMPLES 12
|
|
|
|
|
|
|
|
const float decaystep = 0.88;
|
|
|
|
|
2014-01-19 13:31:00 -05:00
|
|
|
out vec4 FragColor;
|
|
|
|
|
2013-11-30 16:33:06 -05:00
|
|
|
void main()
|
|
|
|
{
|
2015-02-24 16:29:31 -05:00
|
|
|
vec2 uv = 4. * gl_FragCoord.xy / screen;
|
2014-02-23 12:59:24 -05:00
|
|
|
vec2 texc = uv;
|
2013-11-30 16:33:06 -05:00
|
|
|
vec2 tosun = sunpos - texc;
|
|
|
|
|
2014-02-23 14:02:15 -05:00
|
|
|
// if (dot(tosun, tosun) > 0.49) discard;
|
2013-11-30 16:33:06 -05:00
|
|
|
|
|
|
|
vec2 dist = tosun * 1.0/(float(SAMPLES) * 1.12);
|
|
|
|
|
2014-01-19 12:53:35 -05:00
|
|
|
vec3 col = texture(tex, texc).xyz;
|
2013-11-30 16:33:06 -05:00
|
|
|
float decay = 1.0;
|
|
|
|
|
|
|
|
for (int i = 0; i < SAMPLES; i++) {
|
|
|
|
texc += dist;
|
2014-01-19 12:53:35 -05:00
|
|
|
vec3 here = texture(tex, texc).xyz;
|
2013-11-30 16:33:06 -05:00
|
|
|
here *= decay;
|
|
|
|
col += here;
|
|
|
|
decay *= decaystep;
|
|
|
|
}
|
|
|
|
|
2014-01-19 13:31:00 -05:00
|
|
|
FragColor = vec4(col, 1.0) * 0.8;
|
2013-11-30 16:33:06 -05:00
|
|
|
}
|