有没有办法将压缩纹理与 SceneKit 背景 CubeMaps 一起使用?

Is there a way to use compressed textures with SceneKit background CubeMaps?

SceneKit 使用特定的 SCNMaterial 作为场景的 3D 背景。

我们必须使用 scnScene.background.diffuse.contents = 以下之一:

我的背景图片目前是JPG或PNG格式,但解压速度较慢,我想使用压缩贴图(PVRTC或ASTC格式)。

我不能使用垂直、水平条带和球形投影的压缩纹理,因为它们不是正方形图像,并且 PVRTC/ASTC 需要 iOS 下的正方形纹理。 我尝试用 PVRTC 压缩 6 个正方形图像的数组,但是 background.diffuse.contents 需要一个 6 个 UIImage 的数组,虽然日志中没有错误,但是当我分配一个 6 个数组时,我没有看到任何 3D 背景SKTexture 到 background.diffuse.contents.

我的问题如下:

我找到了解决方案。对于任何感兴趣的人:

您可以将模型 IO 纹理分配给 scnScene.background.contents 您可以使用函数 textureCubeWithImagesNamed 加载立方体贴图模型 IO 纹理:(6 个 PVRTC 压缩纹理的路径数组)

NSURL* posx = [artworkUrl URLByAppendingPathComponent:@"posx.pvr"]; 
NSURL* negx = [artworkUrl URLByAppendingPathComponent:@"negx.pvr"];
NSURL* posy = [artworkUrl URLByAppendingPathComponent:@"posy.pvr"];
NSURL* negy = [artworkUrl URLByAppendingPathComponent:@"negy.pvr"];
NSURL* posz = [artworkUrl URLByAppendingPathComponent:@"posz.pvr"];
NSURL* negz = [artworkUrl URLByAppendingPathComponent:@"negz.pvr"];

MDLTexture* cubeTexture = [MDLTexture textureCubeWithImagesNamed:@[posx.path,negx.path,posy.path,negy.path,posz.path,negz.path] ]; 
scnScene.background.contents = cubeTexture;