Hallo, evruhbahddee. I’m working on learning to write 2D filters, and I was working on this one, and I’ve come across a dilemma. It’s a bloom filter that checks the total RGB of a pixel, puts it into a property (“brightness”), and then checks if that property exceeds a certain amount (we’ll call this threshold). If it does, it is SUPPOSED to add a halo around the area by sampling the renderTexture, and then setting up an array around the pixel, thus creating a halo. I’m not sure if I’m describing this correctly… Most of you will see it pretty quickly. My problem is that it only adds this “halo” within the pixels that exceed the threshold, and not around, thus more or less just whiting out the pixels above the given threshold.
uniform sampler2D bgl_RenderedTexture;
uniform sampler2D bgl_DepthTexture;
const int NUM_SAMPLES = 2;
vec4 origcolor = texture2D(bgl_RenderedTexture, gl_TexCoord[0].st);
void main()
{
vec2 texCoo = gl_TexCoord[0].st;
vec4 sample = vec4(0.0);
float brightness = (origcolor.r + origcolor.g + origcolor.b) / 3.0;
if (brightness >= 0.5)
{
for(int i=-NUM_SAMPLES; i <= NUM_SAMPLES ; i++)
{
for(int j=-NUM_SAMPLES; j <= NUM_SAMPLES ; j++)
{
vec2 offset = vec2(i, j) * 0.01;
sample += (texture2D(bgl_RenderedTexture, texCoo + offset));
}
}
}
gl_FragColor = sample + origcolor;
gl_FragColor.a = 1.0;
}
Yes, I realize that this would create a VERY strong bloom as it’s not divided out. Right now I’m just troubleshooting this bit. Thanks! Any help appreciated.