I'm making a 2d game and am using 64x64 textures to draw my characters. It basically looks like super mario brothers, each character has about 10 frames that make up their entire animation sequence.
我正在进行2D游戏并使用64x64纹理来绘制我的角色。它基本上看起来像超级马里奥兄弟,每个角色有大约10帧构成他们的整个动画序列。
The pvr tool sounded promising, it crushed my images down to 4kb each which was great. However the quality is very poor. I don't think there's anything I can do about this, but wanted to double check. Each frame is the character in some pose, and transparent pixels filling the rest of the 64x64 space. I somehow get filled pixels in the transparent regions, strange artifacts that make the output pvr kind of useless (this isn't an error, I think it's just the way pvr works). I could probably get away with some mudy-ness in the character themselves, but not random pixels popping up in transparent areas.
pvr工具听起来很有前途,它将我的图像压缩到每个4kb,非常棒。但质量很差。我不认为我能做些什么,但想要仔细检查。每个帧都是某个姿势中的字符,透明像素填充64x64空间的其余部分。我以某种方式在透明区域中填充像素,奇怪的工件使输出pvr变得无用(这不是错误,我认为它只是pvr的工作方式)。我可能会在角色本身中获得一些研究,但不会在透明区域突然出现随机像素。
Are there any tricks around this? I think we only have about 10mb of memory to play with on the iPhone, so if each of my images is 64x64 pixels uncompressed, I'll run out of space somewhat quickly as each will be an astounding 16k.
这有什么窍门吗?我认为我们在iPhone上只有大约10mb的内存,所以如果我的每张图像都是64x64像素未压缩的话,我会稍微耗尽一些空间,因为每个都会是惊人的16k。
Thanks
2 个解决方案
#1
At least you should half required memory by using 16 bit textures. In Cocos2D you can do it using
至少你应该通过使用16位纹理一半需要内存。在Cocos2D中,您可以使用它
[Texture2D setDefaultAlphaPixelFormat:kTexture2DPixelFormat_RGBA4444]; // add this line at the very beginning
More about pixel format in Cocos2D
有关Cocos2D中像素格式的更多信息
Check out Cocos2D sources if you are programming in raw OpenGL
如果您使用原始OpenGL进行编程,请查看Cocos2D源代码
#2
One thing that I found improved things slightly was to use images larger than they needed to be, and then scale them down to actual size. This hides some of the artifacts, but obviously your not going to be saving as much memory.
我发现稍微改进一件事的一件事是使用比他们需要的更大的图像,然后将它们缩小到实际尺寸。这隐藏了一些工件,但显然你不会节省太多的内存。
That said in the end we gave up with using pvr textures for 2d sprites, as we just couldn't get the image quality we required, and no matter how hard we tried there were always some artifacts visible.
那说最后我们放弃了为2d精灵使用pvr纹理,因为我们无法获得我们所需的图像质量,无论我们如何努力,总会看到一些工件。
Also I believe you actually have 24mb of video memory to play with, so you probably have more space than you think for uncompressed sprites.
另外我相信你实际上有24MB的视频内存可供使用,所以你可能有比你未经压缩的精灵更多的空间。
#1
At least you should half required memory by using 16 bit textures. In Cocos2D you can do it using
至少你应该通过使用16位纹理一半需要内存。在Cocos2D中,您可以使用它
[Texture2D setDefaultAlphaPixelFormat:kTexture2DPixelFormat_RGBA4444]; // add this line at the very beginning
More about pixel format in Cocos2D
有关Cocos2D中像素格式的更多信息
Check out Cocos2D sources if you are programming in raw OpenGL
如果您使用原始OpenGL进行编程,请查看Cocos2D源代码
#2
One thing that I found improved things slightly was to use images larger than they needed to be, and then scale them down to actual size. This hides some of the artifacts, but obviously your not going to be saving as much memory.
我发现稍微改进一件事的一件事是使用比他们需要的更大的图像,然后将它们缩小到实际尺寸。这隐藏了一些工件,但显然你不会节省太多的内存。
That said in the end we gave up with using pvr textures for 2d sprites, as we just couldn't get the image quality we required, and no matter how hard we tried there were always some artifacts visible.
那说最后我们放弃了为2d精灵使用pvr纹理,因为我们无法获得我们所需的图像质量,无论我们如何努力,总会看到一些工件。
Also I believe you actually have 24mb of video memory to play with, so you probably have more space than you think for uncompressed sprites.
另外我相信你实际上有24MB的视频内存可供使用,所以你可能有比你未经压缩的精灵更多的空间。