Motion Detection + FBO Ping Pong for Huge Real Time Blur

You will find all the Information on the Vimeo Video:
http://vimeo.com/1322283

I might post a Code example of my FBO class as soon as I cleaned it up a little bit.

hi moka.

thats looks very interesting.

and if you can it would be really nice to post the code for the fbo. i’ve never used it and it seems very usefull :slight_smile:

Hi pelintra,

I plan to make an example on monday! so check back in a few days!

Cheers

moka

sweet!! cant wait :slight_smile:

Puh, just on time:

You can download a simple example of my FBO Ping Pong class here:
http://code.google.com/p/mokacode/downloads/list

I decided agains extending any OF class since I like to write all the OpenGL code myself. I used some parts from the FBO class zach gage posted here allready.

If you want to apply a shader you simply have to start it as you are used to and than draw to the FBO as show in the example. The good thing is that the FBO class has two Textures attached to it so that you can read and draw from one FBO at the same time.

If anybody has suggestions or changes please let me know since I am new to c++ & openGL myself!

awesome! looking forward to playing with it!

i get this error:
GL_EXT_framebuffer_object extension is unavailable!

thats because you seem to have a really old GFX card which does not support Frame Buffer Objects.

Hi moka!

I’m working with FBOs and I need to add more than one texture… right now it’s for ping pong stuffs but I remember having the sames problems some weeks ago when I was working on DOF shaders…

Would be great if you could re-share your code so I can have a look on how you implemented the fbo!

Thanks a lot!

hey,

back then I didnt really know what I was doing so the code is not a good example. basically adding textures to your FBO is easy:
basically you create your FBO as always and then add the textures like this:

  
  
	  
		glBindTexture(GL_TEXTURE_2D, texture0);  
		glTexImage2D(GL_TEXTURE_2D, 0, _internalFormat, (width), (height), 0, _format, _pixelType, NULL);  
		glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, _filtering);  
		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, _filtering);  
		glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);  
		glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);  
  
		glBindTexture(GL_TEXTURE_2D, texture1);  
		glTexImage2D(GL_TEXTURE_2D, 0, _internalFormat, (width), (height), 0, _format, _pixelType, NULL);  
		glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, _filtering);  
		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, _filtering);  
		glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);  
		glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);  
  
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, texture0, 0);  
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT1_EXT, GL_TEXTURE_2D, texture1, 0);  
  
//switch to texture you want to draw to using glDrawBuffer()  
//for multiple render targets use glDrawBuffers()  
  

the textures bound to one FBO need to be identical in width, height and all their properties though (that might change in the future but right now you have to stick to that) so that most of the time it only makes sense to use multiple textures at one FBO if you want to draw to them at the same time.- if you want to ping pong you usually have different resolution FBOs that you switch (so you would use two or more FBOs that only have one texture attached)

Okay! great!

Thanks! I just misunderstood the “attachment” part… Now it’s a bit more clear.
Does it make sense to attach the texture to any other attachments? Like having a fbo that render at the same time on two texture, one for the color and another one for the depth for example? I tried that but it make the application crash directly! Would be even better with three textures, one for the color, one for the current depth and the last one for the previous depth of the scene.

With this kind of setup we could easily make greaat shaders (motion blur? ssao? scattering? etc, etc…).

Anyway thanks a lot! I keep saying that and I will quickly sound boring but this forum ROCKS! I’m starting to deeply found in love with this community :slight_smile:

Cheers!

Simon.

I think I’ve found the problem!
I guess it’s because I was at the same time attaching the depth texture and the depth buffer to the same GL_DEPTH_ATTACHMENT_EXT attachment…
I remove the line for the depth buffer and now it’s working… that’s great!
Thank you for your help!