SceneKit – Adding vignette to SCNView has no effect
Asked Answered
T

1

1

I'm trying to set up a vignette effect within a SCNView. I did this following this tutorial using more or less the same code as I'm unexperienced with the range of the values. But when I apply that to my SCNViews camera object, nothing happens.

The docs about vignette read that it is necessary to set wantsHDR = true so I did that without any noticeable difference.

// scene setup (light, models, etc.)
...
sceneView.backgroundColor = .gray
sceneView.allowsCameraControl = true
let camera = sceneView.scene?.rootNode.camera
camera?.wantsHDR = true
camera?.vignettingPower = 0.6

camera?.bloomIntensity = 1.4
camera?.bloomBlurRadius = 1.0
    
camera?.fStop = 20.0
camera?.fStop = 5.0
camera?.focusDistance = 1.0

I've only changed the parameters which were marked as deprecated but that wasn't the issue.

I've instanciated the SCNView with the Storyboard and I'm accessing it by having an Outlet in my ViewController and I can use lot of functions with success.

Further I experienced problems setting up MSAA4x with sceneView.antialiasingMode = .multisampling4X. No difference in the outcome. And some more methods/parameters with skybox/environment lighting not doing anything (see this post).

No errors shown in the console.

Tillfourd answered 20/4, 2022 at 15:47 Comment(0)
M
1

If you added a new camera to the scene, it would render a vignette.

let cameraNode = SCNNode()
cameraNode.camera = SCNCamera()
cameraNode.position.z = 10
cameraNode.camera?.wantsHDR = true
cameraNode.camera?.vignettingPower = 1
cameraNode.camera?.vignettingIntensity = 1
sceneView.scene?.rootNode.addChildNode(cameraNode)

enter image description here

Your approach doesn't work because you're accessing the default camera.

cameraNode.camera = sceneView.scene?.rootNode.camera
Maiamaiah answered 21/4, 2022 at 7:28 Comment(3)
Thank you very much again for your reply Andy Jazz! So I added a new Camera object to the scene but I think it's still using the default camera for rendering (still no vignette and when I set position values of the new cameraNode nothing changes). Any ideas what could cause the scene not to use the new camera in the scene?Tillfourd
About positions (everything works fine). Set position not only for a new camera but for model too. As you can see, my vignette is rendered (macOS and iOS versions present the same result).Maiamaiah
Alright there was something messy with the way I loaded the models into my scene. Now i got a minimal example working as shown in your post. Not exactly sure what was causing this issue but I'm gonna drop it here if I find out.Tillfourd

© 2022 - 2024 — McMap. All rights reserved.