![](/img/trans.png)
[英]SceneKit. How to achieve default scene light behavior without autoenablesDefaultLighting?
[英]SceneKit's instance property “autoenablesDefaultLighting” doesn't work
我嘗試通過.autoenablesDefaultLighting
實例屬性在SCNView中打開和關閉默認光照但是不起作用(既不在UI中也不在編程上)。
當沒有光線時,我需要所有物體都是黑色的。
如何關閉默認照明 ?
這是一個代碼:
import SceneKit
import QuartzCore
class GameViewController: NSViewController {
override func viewDidLoad() {
super.viewDidLoad()
let scnView = SCNView(frame: NSRect(x: 0,
y: 0,
width: 450,
height: 300))
view.addSubview(scnView)
scnView.autoenablesDefaultLighting = false // DOESN'T WORK
scnView.allowsCameraControl = true
scnView.backgroundColor = NSColor.blue
let scene = SCNScene()
scnView.scene = scene
let sphereGeo = SCNSphere(radius: 2)
sphereGeo.segmentCount = 4
sphereGeo.materials.first?.diffuse.contents = NSColor.lightGray
let sphereNode = SCNNode(geometry: sphereGeo)
sphereNode.name = "Sphere Node"
scene.rootNode.addChildNode(sphereNode)
}
}
它似乎只有在我使用Physically Based Rendering
着色模型時才有效。
let material = SCNMaterial()
material.lightingModel = SCNMaterial.LightingModel.physicallyBased
sceneView.autoenablesDefaultLighting = false
如果我使用.physicallyBased
類型屬性來着色我的模型,那么照明就像假設一樣。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.