问题描述
我想在 ARKit 中显示的 SCNNode
添加一个 CIGaussianBlur
.
I'd like to add a CIGaussianBlur
to a SCNNode
that is being displayed in ARKit.
但是,添加该过滤器会将节点变成白盒".这是没有和有过滤器的节点.
However, adding that filter turns the node into "a white box". Here is the node without and with filter.
无CIFilter
使用 CIFilter
相关代码如下:
let gaussianBlurFilter = CIFilter(name: "CIGaussianBlur")!
gaussianBlurFilter.name = "blur"
node.filters = [gaussianBlurFilter]
let material = node.geometry?.firstMaterial
material?.diffuse.contents = UIColor.blue
node.position = SCNVector3(x: 0, y: 0, z: -0.39)
camera.addChildNode(node)
之前的 Stack Overflow 问题表明在 Metal 上添加 CIFilter
是不可能的,但我相信现在从 iOS 11 开始是可能的.
Previous Stack Overflow questions have suggested that adding a CIFilter
isn't possible on Metal, but I believe that is now possible as of iOS 11.
此外,我正在尝试在 SCNNode
上实现 UIVisualEffectView
类型的效果,所以如果您知道另一种实现方式,请告诉我!
Also, I'm trying to achieve a UIVisualEffectView
-type effect on an SCNNode
, so if you know of another way to accomplish that please let me know!
推荐答案
你可以试试这个:
let gaussianBlur = CIFilter(name: "CIGaussianBlur")
gaussianBlur?.name = "blur"
gaussianBlur?.setValue(15, forKey: "inputRadius")
node.filters = [gaussianBlur] as? [CIFilter]
并像这样配置SceneView:
and configure the SceneView like so:
sceneView.antialiasingMode = .none
sceneView.isJitteringEnabled = false
这篇关于将 CIFilter 添加到 SCNNode 将节点变成白盒的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!