【发布时间】:2019-05-15 17:40:25
【问题描述】:
在 ARKit 2.0 中,我尝试使用 PBR 基础材料。使用.obj 文件格式的3D 模型。
问题:我看不到深色产品。我不确定是否与在 SceneKit 中设置适当的照明有关。请帮助我如何在ARKit/SceneKit中设置PBR基础照明。
试试下面的代码:
//Set lighting
let light = SCNLight()
light.type = .ambient
node.light = light
// if light estimation is enabled, update the intensity
// of the model's lights and the environment map
if let lightEstimate = self.session.currentFrame?.lightEstimate {
self.enableEnvironmentMapWithIntensity(lightEstimate.ambientIntensity / 1000.0)
} else {
self.enableEnvironmentMapWithIntensity(6)
}
// Call environment Map
func enableEnvironmentMapWithIntensity(_ intensity: CGFloat) {
if sceneView.scene.lightingEnvironment.contents == nil {
if let environmentMap = UIImage(named: "Models.scnassets/sharedImages/environment_blur.exr") {
sceneView.scene.lightingEnvironment.contents = environmentMap
}
}
sceneView.scene.lightingEnvironment.intensity = intensity
}
所需结果:http://prntscr.com/luwlax
作为参考,附上 PBR 材料:
【问题讨论】:
标签: ios swift scenekit augmented-reality arkit