Mason Ballowe
Mason Ballowe

Reputation: 1866

SceneKit Node Lighting

I have a scenekit node that I want to add a glow effect to.

let newScene = SCNScene(named: "art.scnassets/cubeOne.scn")!
let newNode = (newScene.rootNode.childNode(withName: "cubeOneNode", recursively: false))!

newNode.geometry?.firstMaterial?.selfIllumination = UIColor.red
newNode.geometry?.firstMaterial?.ambientOcclusion = UIColor.red

sceneView.scene.rootNode.addChildNode(newNode)

Upvotes: 0

Views: 292

Answers (1)

ZAY
ZAY

Reputation: 5040

You could achieve this by using a so called CIFilter and attach it to you node - but I personally don't recommend this, because it is incredibly performance intense and uses like three times more memory.

I recommend configuring this on your camera. It will also cost you more GPU performance and some memory, but not as much as a CIFilter does. Give it a try:

camera.wantsHDR                     = true
camera.bloomThreshold               = 0.8
camera.bloomIntensity               = 2
camera.bloomBlurRadius              = 16.0
camera.wantsExposureAdaptation      = false

and then use the emission.intensity property of the node material. Set it between 2.0 to 5.0, depending on how much you want the effect to be visible. I usually use the .physicallyBased lighting option as my rendering engine.

PS: Using the red color does not add a very intense effect. Really intense is cyan or green. Using the red color you might crank up the emission.intensity value to 20.0 or higher.

Upvotes: 2

Related Questions