Created
October 2, 2013 15:37
-
-
Save defHLT/6795682 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
varying LOWP vec2 texcoord; | |
uniform sampler2D bgl_RenderedTexture; | |
float samples[11]; | |
void main() | |
{ | |
/*vec2 texcoord = gl_TexCoord[0].xy*/ | |
samples[0] = 0.0222244; | |
samples[1] = 0.0378346; | |
samples[2] = 0.0755906; | |
samples[3] = 0.1309775; | |
samples[4] = 0.1756663; | |
samples[5] = 0.1974126; | |
samples[6] = 0.1756663; | |
samples[7] = 0.1309775; | |
samples[8] = 0.0755906; | |
samples[9] = 0.0378346; | |
samples[10] = 0.0222244; | |
vec4 sum = vec4(0); | |
/*vec2 texcoord = vec2(gl_TexCoord[0]);*/ | |
float width = 0.004; // width = how wide of a sample to use (is repeated 16 times below (4 times horizontally, 4 times for each of those vertically) | |
// Usually 0.004, but as can be seen below, sum would USUALLY be calculated 8 * 8 times (absurd CPU drain); should probably be around 0.001 | |
sum += texture2D(bgl_RenderedTexture, texcoord + vec2(-4, -4)*width) * samples[0]; | |
sum += texture2D(bgl_RenderedTexture, texcoord + vec2(-2, -4)*width) * samples[2]; | |
sum += texture2D(bgl_RenderedTexture, texcoord + vec2(0, -4)*width) * samples[4]; | |
sum += texture2D(bgl_RenderedTexture, texcoord + vec2(2, -4)*width) * samples[6]; | |
sum += texture2D(bgl_RenderedTexture, texcoord + vec2(-4, -2)*width) * samples[0]; | |
sum += texture2D(bgl_RenderedTexture, texcoord + vec2(-2, -2)*width) * samples[2]; | |
sum += texture2D(bgl_RenderedTexture, texcoord + vec2(0, -2)*width) * samples[4]; | |
sum += texture2D(bgl_RenderedTexture, texcoord + vec2(2, -2)*width) * samples[6]; | |
sum += texture2D(bgl_RenderedTexture, texcoord + vec2(-4, 0)*width) * samples[0]; | |
sum += texture2D(bgl_RenderedTexture, texcoord + vec2(-2, 0)*width) * samples[2]; | |
sum += texture2D(bgl_RenderedTexture, texcoord + vec2(0, 0)*width) * samples[4]; | |
sum += texture2D(bgl_RenderedTexture, texcoord + vec2(2, 0)*width) * samples[6]; | |
sum += texture2D(bgl_RenderedTexture, texcoord + vec2(-4, 2)*width) * samples[0]; | |
sum += texture2D(bgl_RenderedTexture, texcoord + vec2(-2, 2)*width) * samples[2]; | |
sum += texture2D(bgl_RenderedTexture, texcoord + vec2(0, 2)*width) * samples[4]; | |
sum += texture2D(bgl_RenderedTexture, texcoord + vec2(2, 2)*width) * samples[6]; | |
//for( i= -4 ;i < 4; i++) // The sixteen sum instructions above replace these for loops | |
//{ | |
// for( j= -4 ;j < 4; j++) | |
// { | |
// sum += texture2D(bgl_RenderedTexture, texcoord + vec2(j, i)*0.004) * samples[j+4]; | |
// } | |
// } | |
gl_FragColor = sum*0.32 + texture2D(bgl_RenderedTexture, texcoord); // Usually sum*0.08; 0.08 < is how bright the bloom effect appears on the screen; should probably be around 0.32 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment