I have a basic ARSCNView that detects images and displays information about them.
The image detected is currently covered in a slightly transparent black with the text overlaid in a transparent white colour.
Ideally I'd like the background behind the text to be a blur view with that transparent black tint, so it blurs the image that is being detected.
I started trying to implement a UIVisualEffectView with a UIBlurEffect but that didn't work. I also looked up SKEffectNode with a CIFilter but that resulted in nothing changing.
Can you use UIBlurEffect or an alternative blur view to apply to the plane or planeNode?
All solutions appreciated.
The image detected is currently covered in a slightly transparent black with the text overlaid in a transparent white colour.
Ideally I'd like the background behind the text to be a blur view with that transparent black tint, so it blurs the image that is being detected.
I started trying to implement a UIVisualEffectView with a UIBlurEffect but that didn't work. I also looked up SKEffectNode with a CIFilter but that resulted in nothing changing.
Can you use UIBlurEffect or an alternative blur view to apply to the plane or planeNode?
All solutions appreciated.
Code Block Swift func renderer(_ renderer: SCNSceneRenderer, nodeFor anchor: ARAnchor) -> SCNNode? { guard let imageAnchor = anchor as? ARImageAnchor, let name = imageAnchor.referenceImage.name, let datum = data[name] else { return nil } let spacing = Float(0.005) let node = SCNNode() let plane = SCNPlane(width: imageAnchor.referenceImage.physicalSize.width, height: imageAnchor.referenceImage.physicalSize.height) plane.firstMaterial?.diffuse.contents = UIColor.black.withAlphaComponent(0.99) // add blur to this plane with the black tint let planeNode = SCNNode(geometry: plane) planeNode.eulerAngles.x = -.pi / 2 node.addChildNode(planeNode) let titleNode = textNode(datum.title, font: UIFont.boldSystemFont(ofSize: 10)) titleNode.pivot = SCNMatrix4MakeTranslation(titleNode.boundingBox.min.x, titleNode.boundingBox.max.y, .zero) titleNode.position.x -= Float(plane.width) / 2 - spacing titleNode.position.y += Float(plane.height) / 2 - spacing planeNode.addChildNode(titleNode) let descriptionNode = textNode(datum.description, font: UIFont.systemFont(ofSize: 4), maxWidth: Int(imageAnchor.referenceImage.physicalSize.width * 500)) descriptionNode.pivot = SCNMatrix4MakeTranslation(descriptionNode.boundingBox.min.x, descriptionNode.boundingBox.max.y, .zero) descriptionNode.position.x -= Float(plane.width) / 2 - spacing descriptionNode.position.y = titleNode.position.y - titleNode.height - spacing planeNode.addChildNode(descriptionNode) return node } private func textNode(_ string: String, font: UIFont, maxWidth: Int? = nil) -> SCNNode { let text = SCNText(string: string, extrusionDepth: 0.5) text.flatness = 0.1 text.font = font text.firstMaterial?.diffuse.contents = UIColor.lightText if let maxWidth = maxWidth { text.containerFrame = CGRect(origin: .zero, size: CGSize(width: maxWidth, height: 100)) text.isWrapped = true } let textNode = SCNNode(geometry: text) textNode.scale = SCNVector3(0.002, 0.002, 0.002) return textNode }