I'm looking for just a working Metal shader that works in SceneKit with SCNProgram.
Can someone show me the correct method declarations/how to hook this up?
let program = SCNProgram()
program.vertexFunctionName = "myVertex"
program.fragmentFunctionName = "myFragment"
material.program = program
and then the shader
//MyShader.metal
vertex something myVertex(something)
{
return something;
}
fragment float4 myFragment(something)
{
return something
}
I'm just looking for the most basic example please.
I clipped out all the 'unnecessary' stuff, this is about as basic as it gets and pretty much what my first Metal shader was.
Next I'd start looking into wiring up the other vertex attributes (colour, normals), and maybe do some basic lighting calculations.
Apologies for any typos, edited it down on my phone...
@lock's answer above is great, so I wanted to expand on it by providing an example of texturing, as OP requested in the comments.
Here's how you'd configure your material to make use of the shaders and wire up the custom texture:
and here are the modified shaders that sample from the texture: