SceneKit使用特定的SCNMaterial作为场景的3D背景。
我们必须使用scnScene.background.diffuse.contents =以下之一:
我的背景图像目前是JPG或PNG格式,但解压缩速度慢,我想使用压缩纹理(PVRTC或ASTC格式)。
我不能使用压缩纹理使用垂直,水平条和球投影,因为他们不是方形图像,和PVRTC/ASTC需要方形纹理下的iOS。我试图压缩6平方图像的数组,但是background.diffuse.contents需要一个6 UIImages的数组,虽然日志中没有错误,但当我将6 SKTexture的数组分配给background.diffuse.contents时,没有看到任何3D背景。
我的问题如下:
发布于 2018-05-29 21:22:02
我找到了解决办法。对于任何感兴趣的人:
您可以将模型IO纹理分配给scnScene.background.contents,您可以使用函数textureCubeWithImagesNamed:(6 PVRTC压缩纹理的路径数组)加载多维数据集映射模型IO纹理。
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;https://stackoverflow.com/questions/50379365
复制相似问题