1.5 KiB
title | date | weight |
---|---|---|
Framebuffer | 2021-01-26T17:58:24-08:00 | 7 |
A framebuffer is a collection of render targets. When we want to draw things, we "bind" the framebuffer so that it can be drawn to. You can create a framebuffer for a single render target, but you can also create a framebuffer consisting of up to 4 color targets and a depth/stencil target. This is useful for techniques such as deferred rendering, because it is much cheaper to render to a bunch of render targets all at once instead of switching them out.
To create a framebuffer, we must provide dimensions, a Render Pass, and some render targets.
var myFramebuffer = new Framebuffer(
GraphicsDevice,
1280,
720,
myRenderPass,
myColorTarget
);
This will create a framebuffer of size 1280x720 that uses myColorTarget
as its color target and is based on myRenderPass
. There is a concept of "render pass compatibility" that will let you use a framebuffer with multiple different render passes, but it's usually easier to just make framebuffers you need per render pass that you will be using.
var myMultiTargetFrameBuffer = new Framebuffer(
GraphicsDevice,
1280,
720,
myGBufferRenderPass,
myPositionTarget,
myNormalTarget,
myAlbedoTarget,
myMetallicRoughnessTarget,
myDepthTarget
);
This will create a multiple render target framebuffer. That's pretty much all there is to say about framebuffers for now.