Home -> IRenderPassNode -> SetAttachmentClearData
Description
The SetAttachmentClearData method instructs the renderer to clear the specified framebuffer target with the supplied data when this pass begins rendering. If a clear operation has not been defined, framebuffer attachments have undefined content for regions that have not been drawn to previously in the current frame.
Important
Several overloads are provided to supply clear data in different data formats. All of them will work for any attachment target, and the type doesn't need to match the storage format used for the attachment. To make things simpler for the application however, and to avoid precision issues where unusual values are used, it is best to use the overload that most closely matches the actual storage format. Also note that where an attachment has less than four vector components, the supplied values in the excess vector components will be ignored.
Important
Clearing framebuffer attachments does incur a performance penalty, so it's advisable to avoid clearing buffers where possible. If you have a compositing pass for example which is guaranteed to generate new content for every fragment, a clear operation would not be required. In cases where only part of the image is being populated however, or for special buffers such as depth buffers, at least one clear operation should generally be defined per frame.
Warning
When a render pass is disabled using the SetIsEnabled method, attachment clear operations don't execute either. Where you are conditionally enabling render passes for a frame, it may be appropriate to use empty render passes that you leave enabled at the start of your frame to perform attachment clear operations. Empty render passes still perform clear operations, as long as the render pass has not been disabled.
Usage
void SetAttachmentClearData(IFrameBuffer::AttachmentType type, size_t index, const V4Float32& data);
void SetAttachmentClearData(IFrameBuffer::AttachmentType type, size_t index, const V4Int32& data);
void SetAttachmentClearData(IFrameBuffer::AttachmentType type, size_t index, const V4UInt32& data);
Argument list
- type [IFrameBuffer::AttachmentType]
- The type of the target framebuffer attachment
- index [size_t]
- The index of the target framebuffer attachment within the selected attachment type
- data [V4Float32/V4Int32/V4UInt32]
- The values to use to fill the target framebuffer attachment