FBO Question

I have tried to use ofFBOTexture to create an FBO. I need to capture the full screen and render that to the FBO. That would create a very large texture and slow down my graphics instead of speeding them up. Is there a way to grab the screen and create a low res version and write it to the FBO?

actually you should directly render to the FBO at full resolution. afterwards you can simply bind the FBO as a texture and do whatever you want with it.
An FBO works pretty much the same as the main Framebuffer so you can use all almost all openGL commands within an FBO.-

That makes sense. I am still at a loss why it is more than halving my frame rate.

posting source could help alot. but I am guessing that you are copying the framebuffer into the FBO which is really expensive in terms of performance.

using the ofFBOTexture extension:

  
  
	myOffscreenTexture2.swapIn();  
	myOffscreenTexture2.setupScreenForMe();  
	oilOB -> draw();  
	myOffscreenTexture2.swapOut();  
	myOffscreenTexture2.setupScreenForThem();  
myOffscreenTexture2.draw(0,0);  
  

The idea is to draw the OilOB and add something like a bloom shader over it so it blooms out over the screen. I need the FB for the bloom shader and to accelerate the graphics; the bloom shader does slow things down a bit without one.

please post the link to the addon, its important how it works internally. From what you posted I can’t really tell you anything, sorry.

To do bloom, usually the steps are:

1.Render scene to Texture (FBO)
2.Find out which parts of the texture (from step 1) are brighter than the threshold(usually done with a shader).
3. blur those parts(also done with a shader, most of the time in 3-5 passes)
4. ToneMapping, which means adding the texture from step one with the one(s) from step 3.

I got the class from here

http://www.openframeworks.cc/files/FBOManagerExample-Xcode-00573.zip

hmm as far as I can tell everything in the Class looks correct. Are you sure that the FBO is slowing things down and not the way you draw your stuff?

Get Rid of all Shader stuff for now and just render things to the FBO and directly to the Screen and compare the performance. Usually it should be almost the same.

using ofGetFrameRate

Without the FBO: around 220 (using a display list)
With FBO: 110

Not sure what is going on here. I just recently learned about framebuffers.

Not that 110 is bad but I haven’t put all the graphics in.
With the other graphics and shaders is slows to 50.

The swapIn() in supposed to be called in the main draw function. correct?

Adding the bloom shader murders the framerate something fierce. I must be doing something wrong.

you’re on a high-end gfx card, right? OpenGL will always render what you tell it to, even if the hardware doesn’t support it – if you try and pull some trick that your gfx hardware can’t handle it might pull the entire pixel/vertex shader pipeline back to the CPU, rather than the GPU, which will, yes, murder the framerate.

hey, you might want to try applying the bloom shader to a lower resolution fbo.

So you render your stuff into a full-res fbo without using the shader

enable the shader and render that fbo into another fbo which is half res (or even lower, depending on how high the original is).

then you can render the lower res fbo at full size (it will be slightly blurred as it’s lower res, but thats ok, its a blurred image anyway).

A fragment shader works on the pixels of the output, not the input. So if you render a 100x100 texture into a 1000x1000 area with a fragment shader, the shader will run for each of the 1000x1000 pixels. If you render a 1000x1000 texture into a 100x100 the fragment shader will only run on each of the 100x100 pixels.

With the LOW res FBO, how to I capture the whole screen at a lower resolution?

My graphics card is not high end but it is fully openGL 2.0 compatible. I have tested my bloom shader in the OpenGL Shader Builder and it runs fine. I just need a low res capture of my screen. Blurring the picture is fine because the bloom shader is already burring it. :slight_smile:

I reduced the size of the texture in the FBO and changed the value to glViewport in the SwapIn function. That seemed to do the trick. I get about a 152 value from ofGetFrameRate. Now I just have to get the bloom fragment shader working correctly.

Hi there
I am using theo FBO Manager example (http://forum.openframeworks.cc/t/render-to-texture/371/0)
at my MacBook Pro with Leopard 10.5.8 and working perfect.
I bought a new MacBook Pro with Snow Leopard 10.6.4, i download x-code FAT (10.6) and i take the errors

‘struct ofTextureData’ has no member named ‘textureName’

at the lines:
ofFBOTexture.cpp

glGenTextures(1, (GLuint *)texData.textureName); // could be more then one, but for now, just one
glBindTexture(texData.textureTarget, (GLuint)texData.textureName[0]);
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, texData.textureTarget, (GLuint)texData.textureName[0], 0);
if (texData.textureName[0] != 0){
glDeleteTextures(1, (GLuint *)texData.textureName);
}

ofTextureAdv.cpp

texData.textureName[0] = 0;
glBindTexture( texData.textureTarget, (GLuint)texData.textureName[0] );

I appreciate your help.

git repository with source code:
http://github.com/igoumeninja/UnaCiudadSonada

Thank a lot

http://igoumeninja.org

Finally i am running my project on snow leopard using topic http://forum.openframeworks.cc/t/snow-leopard—sticky-thread/2749/0

Special thanks theo

Aris