在SceneKit中,我正在构建一个由线条组成的节点,用于绘制场景中心的XYZ轴,就像在Cinema4D中一样。

我希望这三个节点不参与全球照明,即使光线暗/不存在/太强,也是可以看到的。在下面的图片中,你可以看到Z轴看上去太轻了,看不见。

是否有办法阻止一个节点参与场景的照明,就像物理上的类别面具一样?
在这种情况下,如何减轻节点以使其出现?
发布于 2017-03-29 13:14:24
SCNLight有一个categoryBitMask属性。这允许您选择受光线影响的节点(尽管环境灯忽略了这一点)。你可以有两个光源类别,一个为你的主要场景,另一个只影响你的线条。
下面是一个有两个节点的简单例子,每个节点都有不同的色光:
struct LightType {
static let light1:Int = 0x1 << 1
static let light2:Int = 0x1 << 2
}
class GameViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let scene = SCNScene(named: "art.scnassets/scene.scn")!
let lightNode1 = SCNNode()
lightNode1.light = SCNLight()
lightNode1.light!.type = .omni
lightNode1.light!.color = UIColor.yellow
lightNode1.position = SCNVector3(x: 0, y: 10, z: 10)
lightNode1.light!.categoryBitMask = LightType.light1
scene.rootNode.addChildNode(lightNode1)
let lightNode2 = SCNNode()
lightNode2.light = SCNLight()
lightNode2.light!.type = .omni
lightNode2.light!.color = UIColor.red
lightNode2.position = SCNVector3(x: 0, y: 10, z: 10)
lightNode2.light!.categoryBitMask = LightType.light2
scene.rootNode.addChildNode(lightNode2)
let sphere1 = scene.rootNode.childNode(withName: "sphere1", recursively: true)!
sphere1.categoryBitMask = LightType.light1
let sphere2 = scene.rootNode.childNode(withName: "sphere2", recursively: true)!
sphere2.categoryBitMask = LightType.light2
let scnView = self.view as! SCNView
scnView.scene = scene
}
}

发布于 2019-04-07 23:37:03
我认为将材料的闪电模型设定为常数会容易得多。
yourNode.geometry?.firstMaterial?.lightingModel = SCNMaterial.LightingModel.constanthttps://stackoverflow.com/questions/43094456
复制相似问题