In the Extended 0.41, how do I apply a shader?

BlitzMax Modules Forums/MiniB3D/In the Extended 0.41, how do I apply a shader?

I'm trying to apply a Bloom shader to the world, but I cannot figure out how. As far as I can see, I can only apply shaders to specific entities? I tried to brush the camera, but that only made the game crash. How do I "brush" the entire world with a bloom shader?

Bloomshaders and the like are so called postprocessing effects. So a step by step algo (pseudo) would look like this:

1. create a sprite (fullscreen)
2. create a texture and attach it to the sprite and apply the bloomshader to the sprite
3. mainloop
4. hide the sprite
5. render the scene
6. copy the backbuffer to the spritetexture
7. show the sprite
8. turnon the bloomshader
9. render the scene again


this is just in short terms. the new version will have (hopefully easy) a posteffect system which will be easy to extend.

Hmm, I'm sure that works great, although I guess my shader is dodgy because the sprite seems to be showing a solid colour, although the colour does change from blacks and browns as I move around the map.

Do you see anything wrong with my shader?

bloom.frag
uniform sampler2D bgl_RenderedTexture;

void main()
{
   vec4 sum = vec4(0);
   vec2 texcoord = vec2(gl_TexCoord[0]);
   Int j;
   Int i;

   For( i= -4 ;i < 4; i++)
   {
        For (j = -3; j < 3; j++)
        {
            sum += texture2D(bgl_RenderedTexture, texcoord + vec2(j, i)*0.004) * 0.25;
        }
   }
       If (texture2D(bgl_RenderedTexture, texcoord).r < 0.3)
    {
       gl_FragColor = sum*sum*0.012 + texture2D(bgl_RenderedTexture, texcoord);
    }
    Else
    {
        If (texture2D(bgl_RenderedTexture, texcoord).r < 0.5)
        {
            gl_FragColor = sum*sum*0.009 + texture2D(bgl_RenderedTexture, texcoord);
        }
        Else
        {
            gl_FragColor = sum*sum*0.0075 + texture2D(bgl_RenderedTexture, texcoord);
        }
    }
}