Adding CIFilter to SCNNode turns node into white box

末鹿安然 提交于 2020-02-28 20:25:24

问题


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.

No CIFilter

With CIFilter

Here is the relevant code:

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)

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.

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!


回答1:


You can try this:

let gaussianBlur    = CIFilter(name: "CIGaussianBlur")
gaussianBlur?.name  = "blur"
gaussianBlur?.setValue(15, forKey: "inputRadius")
node.filters        = [gaussianBlur] as? [CIFilter]

and configure the SceneView like so:

sceneView.antialiasingMode    = .none
sceneView.isJitteringEnabled  = false



来源:https://stackoverflow.com/questions/48999812/adding-cifilter-to-scnnode-turns-node-into-white-box

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!