iOS:USDZ文件中存在闪电问题



我正在尝试用QLPreviewController显示AR内容。除了照明外,一切都很好。如果我使用Xcode或macOS的快速浏览预览文件,照明是自然的,但当我使用QLPreviewController预览时,对象太暗了!。是否有任何可能的方法来调整照明、比例和其他设置?

创建模型时,请确保3D网格具有UV布局。如果没有UV,3D对象在iOS设备和QLPreviewController中会显示为深色,尽管在使用3D或ARQuickLook时,它在MacOS上可能会显示良好。

有关更多信息,请参阅下面提到的链接:

https://forums.developer.apple.com/thread/107094

例如:如果你用Blender创建模型,这可能会有所帮助:

https://blender.stackexchange.com/questions/1022/adding-uv-mapping-to-mesh

如果你在XCode中打开usdz对象,检查材质检查器,你会发现照明颜色设置为黑色。这就是为什么它在AR世界中看起来很暗,但在ARQuickLook中看起来会很好。

设置UV贴图将解决您的问题。

我尝试过的其他黑客是(不推荐(:

1( 创建USDZ模型时更改emissiveColor。使用基于Python的工具(USDPython(生成usdz文件。

https://developer.apple.com/download/more/?=USDPython

usdzconvert Model.obj -diffuseColor modelDiffuse.png -normal modelNormal.png -metallic 1 -roughness 1 -occlusion 1 -emissiveColor 0.5,0.5,0.5

2( 将照明颜色设置为白色。

首先将.usz转换为.scn->更改照明->将.scn转换为.usz

let scnScene = SCNScene(named: "sceneName", inDirectory: "art.scnassets", options: nil)
scnScene!.write(to: fileUrl.appendingPathComponent("Model.usdz"), delegate: nil)

你可以从这个WWDC演讲中获得帮助(从Scenekit导出USDZ(:

https://developer.apple.com/videos/play/wwdc2019/602/

在Xcode 13/12中没有这样的问题

AR QuickLook框架基于RealityKit渲染引擎。CCD_ 4具有用于控制AR场景的最小参数。没有用于控制照明的参数。AR QuickLook从RealityKit继承了自动Light Estimation。在Xcode 12.1和更高版本中,我没有看到出现未发光(黑色(模型的错误。您可以使用以下代码快速测试它:

import QuickLook
class ViewController: UIViewController,
QLPreviewControllerDelegate,
QLPreviewControllerDataSource {
override func viewDidAppear(_ animated: Bool) {
let previewController = QLPreviewController()
previewController.dataSource = self
previewController.delegate = self
present(previewController, animated: true, completion: nil)
}
func numberOfPreviewItems(in controller: QLPreviewController) -> Int {
return 1
}
func previewController(_ controller: QLPreviewController,
previewItemAt index: Int) -> QLPreviewItem {

guard let path = Bundle.main.path(forResource: "path/to/gramophone",
ofType: "usdz")
else {
fatalError("Couldn't find a file.")
}
let url = URL(fileURLWithPath: path)
return url as QLPreviewItem
}
}

p.S.

如果您仍然遇到未点亮PBR模型的问题——这不是AR QuickLook的问题,而是USDZ模型的问题。

最新更新