问题描述
我想在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
No CIFilter
使用CIFilter
With 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)
先前的堆栈溢出问题表明无法在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可将节点变成白盒的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!