![swift shader swift shader](http://cdn.arstechnica.net/wp-content/uploads/2016/07/IMG_0020-640x480.jpg)
In our application code, we might have an array of these structures, one for each vertex. This is simply an example as in regular application code, a function is written to take whatever data it needs to do its job. In this struct, we’re packaging a (model-space) position and color together. Suppose we have a structure in our Metal shader file that represents the data associated with a single vertex: So how does data get into shader functions? To answer that, we need to first ask what do the data that we want to use in our shader functions look like? The Shape of Data This difference is a source of confusion for many newcomers to Metal. Metal shader functions likewise take parameters, but since these functions are “called” by the GPU while executing drawing commands, we don’t pass arguments directly to them. Since most functions operate on data supplied externally (as opposed to data generated procedurally), we need a way to get data into our functions. A fragment function transforms rasterized data into the final color of a fragment. For example, a vertex function transforms vertices from whatever space they originate in (often model space) into clip space. Generally speaking, the purpose of a function is to transform data. In order to discuss vertex descriptors, we need to go back to the fundamentals of data and functions.
#Swift shader download
You can download the sample project for this article here.
#Swift shader code
The sample code for most articles has been updated periodically, and most samples now use vertex descriptors, so it seemed fitting to write about them.
![swift shader swift shader](https://yghhcrj.weebly.com/uploads/1/3/3/9/133945972/833176162.jpg)
When I was writing the first articles for this site (over four years ago), I didn’t have a firm grasp on the purpose of vertex descriptors, and since their use is optional, this omission persisted for far too long. They describe the shape of data consumed by your shaders. Vertex descriptors are the glue between your application code (written in Objective-C or Swift) and your shader functions (written in the Metal Shading Language). The purpose of this article is to describe and explore a foundational concept in Metal: vertex descriptors.