我正在尝试使用 SCNMaterial 属性快速为 3D 模型添加法线贴图。漫反射属性有效,但在屏幕上看不到包括法线属性在内的其他属性。当我调试以检查节点的 Material 是否包含正常属性时,它显示该属性与我添加的图像一起存在。 我还在 SceneKit 编辑器中检查了我使用的正常图像是否正确,它工作正常。 我已经添加了我正在使用的代码。
let node = SCNNode()
node.geometry = SCNSphere(radius: 0.1)
node.geometry!.firstMaterial!.diffuse.contents = UIColor.lightGray
node.geometry!.firstMaterial!.normal.contents = UIImage(named: "normal")
node.position = SCNVector3(0,0,0)
sceneView.scene.rootNode.addChildNode(node)
这是我得到的输出
最佳答案
我得到了解决方案。由于我没有启用 DefaultLighting,因此场景中没有灯光。将此添加到代码中。
sceneView.autoenablesDefaultLighting = true
关于ios - Scenekit 中的法线贴图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59468037/