Heuristic42
Blog
Opengl
Meta
Rendering
1
comment
Dec 15 at 4:39
Matrices
Hello! Are you looking to elevate your online business with a p…
–
anonymous
comment
Nov 27 at 0:30
DerBard: Custom Split Mechanical Keyboard Prototype
hello
–
anonymous
comment
Nov 19 at 15:47
Matrices
[deleted]
–
anonymous
created
Oct 20 at 20:30
Iterators: pointers vs cursors
You're already doing both of these by hand. This post emphaisze…
–
pknowles
comment
Oct 10 at 10:27
Matrices
[deleted]
–
anonymous
comment
Oct 4 at 19:12
Matrices
[deleted]
–
anonymous
comment
Sep 30 at 18:51
Matrices
[deleted]
–
anonymous
comment
Sep 23 at 16:15
Matrices
[deleted]
–
anonymous
comment
Sep 21 at 6:52
Contributing
I kind of predicted what was bound to happen when my favourite …
–
anonymous
comment
Sep 7 at 1:21
Route contention when running docker and a VPN
Thank you for this. Between this and the overwriting of iptabl…
–
anonymous
comment
Sep 6 at 17:57
Making a real EMF Reader
Sorry for the random quoted text comments. I am one of those p…
–
anonymous
comment
Sep 6 at 17:48
Making a real EMF Reader
["ove! Play a tone with a buzzer and has 5 LEDs to show the “EM…
–
anonymous
comment
Sep 6 at 17:47
Making a real EMF Reader
["easure direction Measure the magnetic fie"](#q107-644-685)
–
anonymous
comment
Aug 20 at 17:01
Matrices
[deleted]
–
anonymous
comment
Aug 11 at 22:32
Matrices
[deleted]
–
anonymous
edited
Jun 8 at 22:29
Rethinking writing files with memory mapping and C++
This post introduces the motivation behind the [decodless C++ o…
–
admin
created
Jun 8 at 22:16
Rethinking writing files with memory mapping and C++
This post introduces the motivation behind the [decodless C++ o…
–
pknowles
comment
Jun 5 at 13:36
Contributing
[deleted]
–
anonymous
comment
Apr 19 at 11:24
Matrices
[deleted]
–
anonymous
comment
Apr 13 at 0:25
Matrices
[deleted]
–
anonymous
comment
Apr 5 at 9:43
Matrices
[deleted]
–
anonymous
comment
Mar 27 at 17:19
Matrices
[deleted]
–
anonymous
comment
Mar 25 at 4:59
Matrices
[deleted]
–
anonymous
comment
Mar 5 at 15:39
Matrices
[deleted]
–
anonymous
…
View All
Log in
The Framebuffer
leave this field blank to prove your humanity
Slug
*
A URL path component
Parent page
<root>
rendering/:Article2:3D Rendering (Computer Graphics)
--- rendering/cameras/:Article11:Cameras
--- rendering/matrices/:Article12:Matrices
------ rendering/matrices/projection/:Article14:Projection Matrix
--- rendering/vectors/:Article13:Vectors
--- rendering/geometry/:Article62:3D Geometry
------ rendering/geometry/triangle_meshes/:None
--- rendering/shading/:Article64:Shading
------ rendering/shading/transparency/:Article70:Transparency and Alpha Blending
--- rendering/lights/:Article65:Lights
--- rendering/rasterization/:None
------ rendering/rasterization/deepimage/:Article72:Deep Image
--- rendering/shadows/:Article67:Shadows
--- rendering/spaces/:Article68:Vector Spaces
------ rendering/spaces/tangent_space/:Article69:Tangent Space
------ rendering/spaces/clip_space/:Article89:Clip Space
--- rendering/rotations/:None
--- rendering/images/:Article74:<unset>:Images
------ rendering/images/mipmapping/:Article75:<unset>:Mipmapping
--- rendering/materials/:None
opengl/:Article3:OpenGL Tutorials
--- opengl/oit/:Article7:Order Independent Transparency (OIT)
--- opengl/framebuffer/:Article71:The Framebuffer
meta/:Article4:Pages About This Site
--- meta/contribute/:Article5:Contributing
--- meta/bugs/:Article9:Bugs
--- meta/about/:Article10:Why does this website exist?
The parent page this belongs to.
Article title
*
Article revisions must have a non-empty title
Article body
*
A frame is one rendered image in an animated sequence. A common measurement of animation smoothness or speed is frames per second (FPS). A buffer is a block of memory used as temporary storage while moving and processing data. GPUs use many buffers internally, but a well known one is the *framebuffer*, which buffers each frame as it's rendered. It simply stores pixel data, like an image, but holds the partial state and intermediate values during the rendering process. For example blending may continually update certain pixels as more geometry is rendered. A *deep framebuffer*, with ties to G-buffers in deferred shading[^DWS+88][^ST90], is typically implied by just “framebuffer” and stores many attributes per pixel. For example depth as well as RGBA colour. This may also be considered a collection of image buffers, one per attribute, which are grouped to form the deep framebuffer. Note that this is different to a [*deep image*](https://www.heuristic42.com/22/), such as a *deep G-buffer*[^MMNL14]. When creating an OpenGL context, the application typically requests a "default" framebuffer, with RGBA colour and depth for example. This holds the final image that ends up shown on the screen. The framebuffer is continually updated as geometry is rendered. If shown directly, the updates would appear as flickering. Geometry that should be occluded may briefly be visible during the render. To avoid this, rendering is performed off-screen to a hidden *back* framebuffer. When a frame is ready, the back framebuffer is swapped with the *front* framebuffer to show only the final results all at once. This is called *double buffering*. The back framebuffer allows off-screen rendering in one sense, but often two or more images need to be rendered and then combined to form the final result; or one is a pre-requisite for another, such as a dynamic texture. There are other fixed framebuffers that allow this, but most are deprecated and superseded by framebuffer objects. # Framebuffer Objects Framebuffer objects (FBOs) allow off-screen rendering, render-to-texture and creating many different configurations of deep framebuffers. A primary example is rendering a [shadow map](/17/rendering/shadows/#shadow-maps). The scene is first rendered to a depth texture from the point of view of a light (1024×1024 for example). During the main 1920×1080 rendering recording RGB colour, the depth texture can be used to determine which fragments are in shadow. Different resolutions and pixel attributes are used to emphasize different FBO configurations, discussed next. An FBO doesn't actually store any image data by itself. It serves as a hub for connecting *attachments*, the actual buffer memory. Attachments can store colour, depth and stencil results from rendering. Although called colour by OpenGL, you can really store whatever data you want. The attachments themselves can be textures, render buffers, pixel buffers, buffer objects via texture buffers etc. They can also be 1D, 2D, 3D, array textures, cube maps, levels of the above and mipmaps. Example usage is as follows: int fbohandle; // allocate an empty framebuffer and get a handle to it glGenFramebuffers(1, &fbohandle); // from now on, I'm modifying the FBO fbohandle glBindFramebuffer(GL_FRAMEBUFFER, fbohandle); // attach a texture to store colour when rendering int texture = createTexture(...); glFramebufferTexture2D( GL_FRAMEBUFFER, //target. i.e. fbohandle from glBindFramebuffer GL_COLOR_ATTACHMENT0, //attachment GL_TEXTURE_2D, //texture target texture, //texture ID 0 //mipmap level ); // zero the uninitialized texture glClear(GL_COLOR_BUFFER_BIT); // adjust the viewport to match the texture size glViewport(...); // render to the texture drawScene(); // go back to rendering to the default framebuffer glBindFramebuffer(GL_FRAMEBUFFER, 0); glViewport(...); A handy function is `glBlitFramebuffer`, which is a very fast way to copy between framebuffers and convenient to view the results of off-screen renders, such as the above, without setting up further rendering passes. glBindFramebuffer(GL_READ_FRAMEBUFFER, fbohandle); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); glBlitFramebuffer(x0, y0, w0, h0, x1, y1, w1, h1, GL_COLOR_BUFFER_BIT, GL_NEAREST); glBindFramebuffer(GL_READ_FRAMEBUFFER, 0); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); [^DWS+88]: M. Deering, S. Winner, B. Schediwy, C. Duffy, and N. Hunt, “The triangle processor and normal vector shader: A vlsi system for high performance graphics,” SIGGRAPH Comput. Graph., vol. 22, no. 4, pp. 21–30, 1988. [^ST90]: T. Saito and T. Takahashi, “Comprehensible rendering of 3-d shapes,” SIGGRAPH Comput. Graph., vol. 24, no. 4, pp. 197–206, 1990. [^MMNL14]: M. Mara, M. McGuire, D. Nowrouzezahrai, and D. Luebke, “Fast global illumination approximations on deep g-buffers,” NVIDIA Corporation, Tech. Rep. NVR-2014-001, 2014, p. 16.
Toggle Preview
Edit message
*
A description of the changes made
Discard Draft
Save Draft
leave this field blank to prove your humanity
Flag
the thing you clicked
for moderator attention.
Reason choice:
Spam, promoting, advertising without disclosure
Rude, inappropriate, generally offensive
Too arrogant or demeaning to others
Other
Reason:
The reason for raising the flag
Error