PVRTC 压缩增加了 PNG 文件大小

发布于 2024-08-10 00:25:39 字数 413 浏览 9 评论 0原文

对于iPhone游戏开发,出于性能考虑,我从PNG格式切换到PVRTC格式。但是 PVRTC 压缩创建的文件比 PNG 文件大得多。因此,140 KB (1024x1024) 的 PNG 在 PVRTC 格式中会膨胀到 512 KB 或更多。我在某处读到,50 KB 的 PNG 文件被压缩为大约10KB,就我而言,它是相反的。.

它发生这种方式的任何原因以及我如何避免这种情况..如果PVRTC压缩盲目地进行4bpp转换(1024x1024x0.5),而不考虑透明度PNG,那么我们在这里实现的压缩是

多少。我的游戏中有 100 张这样的 1024x1024 图像,因为有许多角色,每个角色都在做一些复杂的动画。因此,按照每张图像 512KB 的速度,我的应用程序将获得超过 50MB ..这对我的客户来说是不可接受的..(使用 PNG,我可以让我的应用程序达到 10MB)..

For iPhone game development, I switched from PNG format to PVRTC format for the sake of performance. But PVRTC compression is creating files that are much bigger than the PNG files.. So a PNG of 140 KB (1024x1024) gets bloated to 512 KB or more in the PVRTC format.. I read somewhere that a PNG file of 50KB got compressed to some 10KB and all, in my case, its the other way around..

Any reason why it happens this way and how I can avoid this.. If PVRTC compression is blindly doing 4bpp conversion (1024x1024x0.5) irrespective of the transparencies in the PNG, then whats the compression we are achieving here..

I have 100s of these 1024x1024 images in my game as there are numerous characters each doing some complex animations.. so in this rate of 512KB per image, my app would get more than 50MB.. which is unacceptable for my customer.. ( with PNG, I could have got my app to 10MB)..

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

负佳期 2024-08-17 00:25:39

一般来说,未压缩的图像数据是 24bpp (RGB) 或 32bpp (RGBA) 平坦速率。 PVRTC 是 4bpp(或 2bpp)固定速率,因此与此相比有 6 或 8(12 或 16)倍的压缩。

图形硬件本地使用纹理的要求是纹理的格式必须可供硬件随机访问。 PVRTC 是这种格式,PNG 不是,这就是为什么 PNG 可以实现更大的压缩比。 PVRTC 是一种运行时、部署格式; PNG是一种存储格式。

PVRTC 压缩一次在 4x4 像素块上以固定比特率进行,因此很容易计算在内存中的哪个位置检索导出特定纹素值所需的数据,并且只需要对内存进行一次访问。图形核心中有一个专用电路,它将解码这个 4x4 块,并将纹素值提供给着色器/纹理组合器等。PNG

压缩不能以固定比特率工作,并且从中检索特定值更加复杂;需要从多个位置访问内存才能检索单个颜色值,并且每次发生纹理读取时都需要更多的内存和处理。因此它不适合用作本机纹理格式,这就是为什么在图形硬件使用纹理之前必须解压缩纹理的原因。与无需解压即可使用的 PVRTC 相比,这增加了带宽使用。

因此,对于离线存储(磁盘上应用程序的大小),PNG 比 PVRTC 小,而 PVRTC 比完全未压缩的小。就运行时内存占用和性能而言,PVRTC 比 PNG 更小、更快,而 PNG 由于必须解压缩,因此与未压缩纹理一样大且慢。您可能会在初始化磁盘访问时使用 PNG 获得一些优势,但随后您会失去解压缩的时间。

如果您想减少 PVRTC 的存储占用量,您可以尝试对纹理文件进行 zip 式压缩,并在从磁盘加载时扩展这些文件。

In general, uncompressed image data is either 24bpp (RGB) or 32bpp (RGBA) flatrate. PVRTC is 4bpp (or 2bpp) flatrate so there is a compression of 6 or 8 (12 or 16) times compared to this.

A requirement for graphics hardware to use textures natively is that the format of the texture must be random accessible for the hardware. PVRTC is this kind of format, PNG is not and this is why PNG can achieve greater compression ratios. PVRTC is a runtime, deployment format; PNG is a storage format.

PVRTC compression is carried out on 4x4 blocks of pixels at a time and at a flat bit rate so it is easy to calculate where in memory to retrieve the data required to derive a particular texel's value from and there is only one access to memory required. There is dedicated circuitry in the graphics core which will decode this 4x4 block and give the texel value to your shader/texture combiner etc.

PNG compression does not work at a flat bitrate and is more complicated to retrieve specific values from; memory needs to be accessed from multiple locations in order to retrieve a single colour value and far more memory and processing would be required every single time a texture read occurs. So it's not suitable for use as a native texture format and this is why your textures must be decompressed before the graphics hardware will use them. This increases bandwidth use when compared to PVRTC, which requires no decompression for use.

So for offline storage (the size of your application on disk), PNG is smaller than PVRTC which is smaller than completely uncompressed. For runtime memory footprint and performance, PVRTC is smaller and faster than PNG which, because it must be decompressed, is just as large and slow as uncompressed textures. You might gain some advantage with PNG at initialisation for disk access, but then you'd lose time for decompression.

If you want to reduce the storage footprint of PVRTC you could try zip-style compression on the texture files and expand these when you load from disk.

你在看孤独的风景 2024-08-17 00:25:39

PVRTC(PowerVR 纹理压缩)是一种纹理压缩格式。在使用 PowerVR 的设备上,例如大多数高端手机,包括 iPhone 和其他基于 ARM 的设备(如 iPod),绘图速度非常快,因为绘图是硬件加速的。它还使用更少的内存,因为图像以压缩形式表示并在每次绘制时进行解码,而 PNG 需要在绘制之前解压缩。

PNG是无损压缩。

PVRTC 是有损压缩,意味着它近似图像。它有完全不同的设计标准。

PVRTC 将“压缩”(通过近似)任何类型的艺术品,为每个纹理像素提供固定的位,包括摄影图像。

PNG 并不近似图像,因此如果图像包含很少的冗余,则它根本无法压缩。另一方面,统一的图像(例如插图)使用 PNG 压缩效果最佳。

它的苹果和橙子。

PVRTC (PowerVR Texture Compression) is a texture compression format. On devices using PowerVR e.g. most higher end mobile phones including the iPhone and other ARM-based gadgets like the iPod it is very fast to draw since drawing it is hardware accelerated. It also uses much less memory since images are represented in their compressed form and decoded each draw, whereas a PNG needs to be decompressed before being drawn.

PNG is lossless compression.

PVRTC is lossy compression meaning it approximates the image. It has a completely different design criteria.

PVRTC will 'compress' (by approximating) any type of artwork, giving a fixed bits per texel, including photographic images.

PNG does not approximate the image, so if the image contains little redundancy it will hardly compress at all. On the other hand, a uniform image e.g. an illustration will compress best with PNG.

Its apples and oranges.

合约呢 2024-08-17 00:25:39

将多个帧平铺到单个图像上,并位图纹理的子矩形。这将显着减少您的内存消耗。

如果您的图像尺寸为 64x64,那么您可以将其中 256 个图像以 16x16 的排列方式放置在 1024x1024 纹理上。

只需付出一点努力,图像就不需要全部具有相同的大小,只要您跟踪每个图像所在纹理中的矩形的代码即可。

iPhone 游戏开发商就是这么做的。

Place more than one frame tiled onto a single image and blit the subrectangles of the texture. This will dramatically reduce your memory consumption.

If you images are, say, 64x64, then you can place 256 of them on a 1024x1024 texture in a 16x16 arrangement.

With a little effort, images do not need to be all the same size, just so long as you keep track in the code of the rectangle in the texture that each image is at.

This is how iPhone game developers do it.

夜空下最亮的亮点 2024-08-17 00:25:39

我同意威尔的观点。这个问题没有任何意义。这个问题我看了三遍,但我还是不知道桑卡想知道什么。这只是抱怨,没有疑问。

我唯一可以建议的是,如果您介意使用 PVRTC,请不要使用它。它可以提高性能并节省 VRAM,但在这种情况下它不会为您提供帮助。因为你想要的只是减少游戏体积,而不是考虑性能和质量之间的权衡。

I agree with Will. There is no point in the question. I read the question 3 times, but I still don't know what Sankar want to know. It's just a complain, no question.

The only thing I can advice, don't use PVRTC if you mind to use it. It offers performance gain and saves VRAM, but it won't help you in this case. Because what you want is just reducing game volume, not a consideration about trade-off between performance and quality.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文