在scenekit中对obj模型应用适当的完成?

时间:2018-02-27 10:44:01

标签: ios swift scenekit

我正在尝试使用scenekit(ARIkit iOS)在.obj模型上应用金属度贴图。不幸的是,它显示垂直线条。

请参考下面的代码,我也附上截图以便正确理解。

对模型进行UV展开以解决模型中的平铺问题,并附上所有材料以供审核。

对象网址https://s3.ap-south-1.amazonaws.com/p9-platform/product/4f800e4c-52cd-4167-a7c3-6ba5703df7e7.obj

func loadTexture(forMaterial material: SCNMaterial, withFinish finish:FinishModel, forDispatchGroup disPatchGroup:DispatchGroup) {

    concurrentQueue.async {
        if material.lightingModel != .physicallyBased {
            material.lightingModel = .physicallyBased
        }
    }
    if let finishMap = finish.finishMap {
      if let diffuseTexturePath = finishMap.diffuseMapUrl {
            disPatchGroup.enter()
            self.dataProvider.fetchTextureFile(forpath: diffuseTexturePath, successBlock: { (success, imageObject) in
                //self.viewController?.report_memory()
                material.diffuse.contents = nil
                material.diffuse.contents = imageObject
                disPatchGroup.leave()
            }, failureBlock: { (error) in
                disPatchGroup.leave()
            })
        }

       if let metalTexturePath = finishMap.metalnessMapUrl {
            disPatchGroup.enter()
            self.dataProvider.fetchTextureFile(forpath: metalTexturePath, successBlock: { (success, imageObject) in
               // self.viewController?.report_memory()
               material.metalness.contents = nil
                material.metalness.contents = imageObject
                disPatchGroup.leave()
            }, failureBlock: { (error) in
                disPatchGroup.leave()
            })
        }

        if let roughnessTexturePath = finishMap.roughnessMapUrl {
            disPatchGroup.enter()
            self.dataProvider.fetchTextureFile(forpath: roughnessTexturePath, successBlock: { (success, imageObject) in
               // self.viewController?.report_memory()
                material.roughness.contents = nil
                material.roughness.contents = imageObject
                disPatchGroup.leave()
            }, failureBlock: { (error) in
                disPatchGroup.leave()
            })
        }

        if let normalTexturePath = finishMap.normalMapUrl {
            disPatchGroup.enter()
            self.dataProvider.fetchTextureFile(forpath: normalTexturePath, successBlock: { (success, imageObject) in
                material.normal.contents = nil
               // self.viewController?.report_memory()
                material.normal.contents = imageObject
                disPatchGroup.leave()
            }, failureBlock: { (error) in
                disPatchGroup.leave()
            })
        }

    }
}

enter image description here enter image description here

DiffuseMapUrl enter image description here

NormalMapUrl enter image description here

metalnessMapUrl enter image description here

roughnessMapUrl enter image description here

1 个答案:

答案 0 :(得分:1)

您应该确保不同的材料属性(diffusemetalnessroughnessnormal)对wrap mode使用相同的wrapSwrapTSCNWrapModeRepeat可能就是您要找的地方。

注意问题中的代码会设置specular材质属性,但SCNLightingModelPhysicallyBased不会将其考虑在内。