Framebuffer size

Hi,

I’m sure I’m getting confused with setting up FBO’s.

Is the size normally the same as the screen display? For instance 1024x768.

If I have an image that is 96x96 and the FBO’s are set up to be the screen size, when doing final batch draw from the fbo, this will mean it will draw 1024x768 and thus fps suffers.

I’ve tried setting FBO width and height to be 96x96 the same as the image but then the image isn’t visible as it is scaled down so much.

I guess I’m getting this or muddled up?!

I set up a FBO:

fbo = new FrameBuffer(Format.RGBA8888, 1024, 768, false);

Then I render a sprite of 96x96 to this fbo, then do some preprocessing, get the Texture binded to this FBO and render:

batch.draw(fboRegion, 0,0); // <— Meaning will draw of size 1024x768 :frowning:

Thanks

[UPDATE]

I now set the fboRegion up to be the size of the image texture and this works, thus, draws the size of the image.

Just want to set the transparency now, this with the alpha channel?

Thanks

When drawing to a framebuffer you have to remember that the camera is still thinking you’re drawing to the actual screen - so a 96x96 buffer should have a camera with that viewport size bound to the projection matrix when drawing to that buffer.

As for transparency, you can just clear the buffer with alpha 0 (Gdx.gl.glClearColor(0, 0, 0, 0)) first and render your partially-transparent texture on the buffer.

Ok, I’ve sorted so my landscape is drawn, problem was is I used the same camera for the fbo/blur shader as my game/landscape so fix was
to create an OrthoGraphicCamera for the fbo - simple as that.

Also fixed the transparency issue, was my pixel shader! The two lines below are the fix.


vec4 texColor = texture2D(u_texture, vTexCoord);       // added this line to get the alpha channel    
gl_FragColor = vColor * vec4(sum.rgb, texColor.a);      // use alpha channel color from texture

You can see the round space ship has been put through my blur shader.

Learnt a lot doing this. Next is to create bloom shader for the world map.

Thanks