Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is a color attachment in Metal?

Tags:

metal

I assume color attachments exist in other API's other than Metal (I know OpenGL for sure), but I'm new to graphics programming and I'd like to know what exactly a color attachment is conceptually. All the drawing I've done involves setting properties on the first in an array of color attachments and then making a render pass. Is a color attachment literally just a buffer? Would the sole point of using multiple in a render pass be to draw the same image to multiple buffers / textures?

Edit: Pipeline states have arrays of color attachments as well, as I just recalled. If they are essentially buffers, what does that have to do with setting pipeline state?

like image 402
Sam Claus Avatar asked May 08 '17 18:05

Sam Claus


1 Answers

Seeing as you have some knowledge of OpenGL, I'll put it in those terms:

A Colour attachment is a texture which attaches to a frame buffer as a render target, used for off-screen rendering.

Colour attachments are used in several techniques, including reflection, refraction, and deferred shading.

In terms of a graphics pipeline, buffers with attachments will tend to be either sources of texture data, or end point render targets.

When you change the bound buffers you change the state of the pipeline, as computer graphics hardware is state based. You queue up state changes for the entire pipeline(use shader x, bind buffer y, set uniform z), execute those changes, then observe the result as rendered to the screen.

like image 94
Ian Young Avatar answered Oct 24 '22 18:10

Ian Young