簡體   English   中英

在scenekit中的obj模型上應用適當的飾面?

[英]Apply proper finishes on obj model in 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()
            })
        }

    }
}

在此處輸入圖片說明 在此處輸入圖片說明

DiffuseMapUrl 在此處輸入圖片說明

法線貼圖網址在此處輸入圖片說明

metalnessMapUrl 在此處輸入圖片說明

粗糙度貼圖網址在此處輸入圖片說明

您應該確保不同的材料屬性( diffusemetalness roughnessroughnessnormal )對wrapSwrapT使用相同的 包裹模式 這里SCNWrapModeRepeat很可能是您正在尋找的。

注意問題中的代碼設置了specular材質屬性,但SCNLightingModelPhysicallyBased並未將其考慮在內。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM