1

Some of the NASA .usdz spherical models, when displayed in an iOS SceneKit app, show "holes" in the rendered textures, apparently at vertices in the model.

The models display correctly with NO holes in QuickLook (on both iOS 12.3.1 and MacOS 10.14.6 Beta), which I believe are also using SceneKit.

However, Xcode (10.2.1 and 11.0 Beta 2), like an iOS app, show holes when editing the .usdz file as well as in an exported .scn file.

Is there some SceneKit option that will resolve this problem? In other words, what magic is QuickLook doing to "fix" this?

Here's an example model of Mars from NASA: https://solarsystem.nasa.gov/resources/2372/mars-3d-model/

Here's a screenshot of the Mars model via QuickLook on MacOS: enter image description here

Here's a screenshot of the Mars model with holes as viewed in Xcode and which looks the same in a SceneKit app on iOS: enter image description here

LenK
  • 2,944
  • 2
  • 20
  • 26

1 Answers1

2

this can happen when subdivision surfaces are used but the SCNSceneSourceLoadingOptionPreserveOriginalTopology wasn't specified when importing the model. Make sure you set this option to YES when loading a scene.

This could also be an issue with the exporter. If the model is already sufficiently detailed then subdivision surfaces were probably not intended. If nothing is specified in the USDZ file then Catmull-Clark subdivision is the default setting but several exporters don't explicitly specify none when they should.

mnuages
  • 13,049
  • 2
  • 23
  • 40
  • Setting subdivisionLevel to zero on the geometry of each loaded node seems to resolve the problem. Thanks very much! Does it seem "reasonable" to do this for all user-loaded models (i.e., do you think QuickLook does that)? – LenK Jun 19 '19 at 00:53
  • It depends on the model. If you know your data you know if you want subdivision or not. If the models come from an unknown source you can't know for sure if the default behaviour is intended or if there's a bug in the exporter. Quick Look uses `SCNSceneSourceLoadingOptionPreserveOriginalTopology`. – mnuages Jun 19 '19 at 01:13
  • I've tried the following, but it doesn't seem to solve the problem without specifically setting the subdivisionLevel to zero in the nodes: ` let options = [SCNSceneSource.LoadingOption.preserveOriginalTopology: true] if let url = url, let modelSource = SCNSceneSource(url: url, options: options) { do { let node = try modelSource.scene(options: options).rootNode` – LenK Jun 19 '19 at 23:11
  • It's possible that the model has duplicated vertices for adjacent faces. In this case subdivision will lead to gaps and you can't do anything about it but fix the model. That said if your model isn't meant to be subdivided just set the `subdivisionLevel` to 0 or fix the USDZ file so that it specifies that the subdivision scheme should be `none`. – mnuages Jun 20 '19 at 19:28