[英]Apply proper finishes on obj model in scenekit?
I am trying to apply metalness map on .obj Model using scenekit (ARIkit iOS).我正在尝试使用 Scenekit (ARIkit iOS) 在 .obj 模型上应用金属度贴图。 Unfortunately, It's displaying vertical lines.
不幸的是,它显示的是垂直线。
Please refer below code and also, I have attached screenshot for proper understanding.请参考下面的代码,我还附上了截图以便正确理解。
Model is UV unwrapped to resolve tiling issue in the model, and all materials are attached for review purpose.模型经过 UV 展开以解决模型中的平铺问题,并附上所有材料以供查看。
Obj URL : https://s3.ap-south-1.amazonaws.com/p9-platform/product/4f800e4c-52cd-4167-a7c3-6ba5703df7e7.obj对象网址: 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()
})
}
}
}
You should make sure the different material properties ( diffuse
, metalness
, roughness
and normal
) use the same wrap mode for wrapS
and wrapT
.您应该确保不同的材料属性(
diffuse
、 metalness
roughness
、 roughness
和normal
)对wrapS
和wrapT
使用相同的 包裹模式。 Here SCNWrapModeRepeat
is likely what you are looking for.这里
SCNWrapModeRepeat
很可能是您正在寻找的。
Note The code in the question sets the specular
material property, but SCNLightingModelPhysicallyBased
does not take it into account.注意问题中的代码设置了
specular
材质属性,但SCNLightingModelPhysicallyBased
并未将其考虑在内。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.