Skip to content

Instantly share code, notes, and snippets.

@MasDennis
Created May 3, 2019 20:53
Show Gist options
  • Save MasDennis/1bed62f42c6923d668901b86e684c2c1 to your computer and use it in GitHub Desktop.
Save MasDennis/1bed62f42c6923d668901b86e684c2c1 to your computer and use it in GitHub Desktop.
#include <metal_stdlib>
using namespace metal;
// Define the Vertex data structure. This corresponds to the TriangleVertex struct
// that was defined in Swift
struct Vertex
{
float4 position [[position]];
float4 color;
};
// The vertices aren't transformed.
vertex Vertex passthrough_vertex(device Vertex *vertices [[buffer(0)]],
uint vid [[vertex_id]])
{
return vertices[vid];
}
// No fancy effects, just use the vertex color that was defined.
fragment float4 passthrough_fragment(Vertex inVertex [[stage_in]])
{
return inVertex.color;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment