ios - 使用基于图像的光照在 3D 模型上应用 PBR 纹理

标签 ios swift scenekit augmented-reality arkit

在 ARKit 2.0 中,我尝试使用 PBR 基础 Material 。使用 .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

enter image description here

作为引用,附上 PBR Material :

enter image description here

漫反射:https://prnt.sc/luwc40

粗糙度:https://prnt.sc/luwcl7

正常:https://prnt.sc/luwcuw

金属度:https://prnt.sc/luwdaz

最佳答案

如果您有一个分离的几何体(屏幕与框架分开),很容易将纹理分配给这些部分。

如果您有一个组合几何体(所有部分作为一个整体),对此类模型进行纹理处理的唯一方法是分配 pre-made UV-mapped texture .

关于ios - 使用基于图像的光照在 3D 模型上应用 PBR 纹理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53779925/

相关文章:

ios - 如何在不耗尽电池的情况下监控 MPMoviePlayerController 播放进度?

ios - NSURLConnection 在下载大部分数据时导致内存警告

Swift,是否可以有一个 IBInspectable block ?

ios - 如何在 iOS 中单击按钮打开带有 YouTube ID 的 YouTube 应用

ios - 如何以特定顺序显示数组中的项目?

java - iOS 上的 LibGDX : Rotate screen programmatically using Robovm

ios - OAuth 集成错误

ios - 两个对象没有相互接触,但 contactTestBetween() 返回结果

ios - 如何在 SceneKit 中将 pipe 切成两半?

ios - iOS 上的 SCNRenderer 分配时出现错误