ios - Scenekit 中的法线贴图

标签 ios swift xcode scenekit arkit

我正在尝试使用 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)

这是我得到的输出

Screen Shot

我期待这样的事情 Screenshot

最佳答案

我得到了解决方案。由于我没有启用 DefaultLighting,因此场景中没有灯光。将此添加到代码中。

sceneView.autoenablesDefaultLighting = true

关于ios - Scenekit 中的法线贴图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59468037/

相关文章:

ios - UIBarButtonItem 在 UIToolBar 中不可点击

ios - 是否可以对 Swift 协议(protocol)进行哈希处理?

iphone - NSMutableArray/NSMutable 字典未在 writeToFile 上保存数据

php - 在带有 AFnetworking 的 iOS 应用程序上使用 cookie

ios - Facebook 像素事件购买未注册 iOS 销售

ios - 将 UI 图像更改为字符串数组

ios - 在不从对象库中删除和添加的情况下将 UILabel 更改为 UITextView

xcode - 在 Playground 上使用 Alamofire 延迟发出 http 请求

ios - UIImagePicker 中所选视频的方向

ios - 防止 Tab Bar 切断 WKWebView 文本