I'm building an iOS App using SceneKit and ARKit. I'm using SCNTechnique
to modify the rendering of SceneKit and draw a part of the scene in a stylized way. Currently, I'm using a simple metal fragment shader to draw the scene in black and white:
fragment half4 fragment_shader(VertexOut vert [[stage_in]],
texture2d<half, access::sample> scene [[texture(0)]]) )
{
constexpr sampler samp = sampler(coord::normalized, address::repeat, filter::nearest);
half4 color = scene.sample(samp, vert.texcoord);
constexpr half3 weights = half3(0.2126, 0.7152, 0.0722);
color.rgb = half3(dot(color.rgb, weights)) * 0.1;
return color;
}
I now want to encapsulate the sylization and use a CIFilter
instead of writing all the metal code myself. Is it possible to call CIFilters in Metal and for instance passing them a texture2d
? If so, how?