我正在使用SceneKit和ARKit构建一个iOS应用程序。我正在使用SCNTechnique修改SceneKit的渲染,并以风格化的方式绘制场景的一部分。目前,我正在使用一个简单的金属碎片着色器来绘制黑白场景:
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;
}我现在想封装sylization并使用CIFilter,而不是自己编写所有的金属代码。有没有可能在金属中调用CIFilters,例如传递给它们一个texture2d?如果是这样的话,是怎么做的?
发布于 2020-08-23 19:25:16
似乎可以通过filters属性直接将CIFilters赋值给SCNNodes。从文档中:
当此数组不为空时,SceneKit将节点(及其子节点层次结构)渲染到图像缓冲区中,然后在将过滤器的输出合成到渲染的场景中之前应用过滤器。
https://stackoverflow.com/questions/63524272
复制相似问题