testing bloom and motion blur

This commit is contained in:
Eduardo Bart 2012-03-28 14:18:21 -03:00
parent 81dcd42fd1
commit 56d6cc2cc0
3 changed files with 25 additions and 4 deletions

View File

@ -4,7 +4,25 @@ uniform float time; // time in seconds since shader linkage
uniform sampler2D texture; // map texture uniform sampler2D texture; // map texture
varying vec2 textureCoords; // map texture coords varying vec2 textureCoords; // map texture coords
/*
void main() void main()
{ {
gl_FragColor = texture2D(texture, textureCoords) * color * opacity; gl_FragColor = texture2D(texture, textureCoords) * color * opacity;
} }
*/
void main()
{
vec4 sum = vec4(0);
vec2 texcoord = textureCoords;
int j;
int i;
for( i= -4 ;i < 4; i++)
{
for (j = -4; j < 4; j++)
{
sum += texture2D(texture, texcoord + vec2(j, i)*0.0005) * 0.008;
}
}
gl_FragColor = texture2D(texture, textureCoords) * color * opacity + sum;
}

View File

@ -49,6 +49,7 @@ void Graphics::init()
#endif #endif
glEnable(GL_BLEND); glEnable(GL_BLEND);
glClear(GL_ACCUM_BUFFER_BIT);
m_emptyTexture = TexturePtr(new Texture); m_emptyTexture = TexturePtr(new Texture);
@ -82,6 +83,7 @@ bool Graphics::parseOption(const std::string& option)
void Graphics::resize(const Size& size) void Graphics::resize(const Size& size)
{ {
setViewportSize(size); setViewportSize(size);
glClear(GL_ACCUM_BUFFER_BIT);
// The projection matrix converts from Painter's coordinate system to GL's coordinate system // The projection matrix converts from Painter's coordinate system to GL's coordinate system
// * GL's viewport is 2x2, Painter's is width x height // * GL's viewport is 2x2, Painter's is width x height
@ -111,16 +113,14 @@ void Graphics::beginRender()
void Graphics::endRender() void Graphics::endRender()
{ {
/*
// this is a simple blur effect // this is a simple blur effect
static Timer timer; static Timer timer;
if(timer.ticksElapsed() >= 20) { if(timer.ticksElapsed() >= 15) {
glAccum(GL_MULT, 0.8); glAccum(GL_MULT, 0.8);
glAccum(GL_ACCUM, 0.2); glAccum(GL_ACCUM, 0.2);
timer.restart(); timer.restart();
} }
glAccum(GL_RETURN, 1); glAccum(GL_RETURN, 1);
*/
} }
void Graphics::beginClipping(const Rect& clipRect) void Graphics::beginClipping(const Rect& clipRect)

View File

@ -367,7 +367,10 @@ void X11Window::internalChooseGLVisual()
GLX_USE_GL, GLX_USE_GL,
GLX_RGBA, GLX_RGBA,
GLX_DOUBLEBUFFER, GLX_DOUBLEBUFFER,
GLX_STENCIL_SIZE, 1, GLX_ACCUM_RED_SIZE, 8,
GLX_ACCUM_GREEN_SIZE, 8,
GLX_ACCUM_BLUE_SIZE, 8,
GLX_ACCUM_ALPHA_SIZE, 8,
None None
}; };