Skip to content

Instantly share code, notes, and snippets.

@rmirabelli
Last active March 9, 2018 20:40
Show Gist options
  • Save rmirabelli/ee99a6073a80ce493bebf337bbd46ef1 to your computer and use it in GitHub Desktop.
Save rmirabelli/ee99a6073a80ce493bebf337bbd46ef1 to your computer and use it in GitHub Desktop.
A shader library right in the playground source -- you can replace these shaders to experiment more!
// create a shader library in source (not precompiled)
let runtimeLibrary = try device?.makeLibrary(source: """
#include <metal_stdlib>
using namespace metal;
vertex float4 copy_vertex(
const device packed_float3* vertex_array [[buffer(0)]],
unsigned int vid [[vertex_id]]) {
return float4(vertex_array[vid], 1.0);
}
fragment half4 constant_color() {
return half4(0.75,0.95,0.35,1.0);
}
""", options: nil)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment