Monday 8 April 2013

Frame Buffer Objects (FBO's)

Glad to see you back on our travels through the adventure of graphics in games. Today we're going to explore more magic known as frame buffer objects. FBO's are really cool and useful tools when it comes to graphics as they allow for many fancy shader effects to be done. When I think about an FBO I think magic because as simple as they sound in theory, the actual implementation and integration into a game can be buggy.
In short, the theory behind a frame buffer object is that you take a screen shot of your rendered scene and save the data. Then from there you take the data and work wonders. Countless options could be approached and followed through with once FBO's are working in game. I've noticed that many people in our class have been struggling with this concept of a frame buffer object and it is delaying their production of certain shaders because they rely on FBO's. It has certainly put my group behind on the production of the shaders we want because of FBO problems. Anyways, we got them working recently, to a hacky extent, and are ready to make use of our new tool.
The reason why our FBO is hacky is because we have fixed numbers when creating the frame buffer. If the generation of the framebuffer wasn't hard coded then our game could be displayed in any screen size rather than the one we initially created. We found this out the hard way as we attempted to project our game onto the screen and the framebuffer caused it to be very zoomed in from the smaller resolution.
Now if the framebuffer is generated more dynamically it could solve this problem and give more power to the FBO because it can be properly downsized and resized to support bloom. This could be done through the proper use of the viewport so it can be resized according to the screen's size and resolution of the screen.
Currently, our game needs to be dynamic for Level Up Showcase on Wednesday so we have for now temporarily removed FBO's until after level up.
A frame buffer can be used in many different ways other than simply taking the image and displaying it on screen since it is just data.  Thinking way outside of the box here, but since the FBO is just a long stream of data, we could store whatever information we want so we can send it to the GPU for processing of that data. This method can be done the same way a vbo can be manipulated to send data to the gpu. Normally a vbo would send information about the vertices of a model but it is just another way to store and transfer long streams of data in the end of the day.
Other ways I have used FBO's so far in my FBO career is using frame buffers for edge detection with my cel shading program, more framebuffers for motion blur on the GPU, and bloom having a frame buffer for the bright pass, the blur pass, and finally the end resulting composite of the effects.

No comments:

Post a Comment