全高清 2D 纹理内存 OpenGL

发布于 2024-12-03 15:39:46 字数 504 浏览 1 评论 0原文

我正在为一家艺术家公司编写一个支持全高清的 2D 引擎,该引擎有望是跨平台的,并且是用 OpenGL 和 C++ 编写的。

我遇到的主要问题是如何处理所有这些高清精灵。艺术家以 24fps 的速度绘制图形,并将它们导出为 png 序列。我已将它们转换为 DDS(不理想,因为它需要 directx 标头才能加载)DXT5,这大大减少了文件大小。游戏中的某些场景一次可以有 5 或 6 个动画精灵,并且每个动画精灵可以包含 200 多个帧。目前,我正在将精灵加载到指针数组中,但即使使用压缩纹理,加载时间也太长,并且使用相当多的内存(整个场景大约 500mb)。

所以我的问题是,您对如何处理如此大量的帧有什么想法或技巧吗?我想到了几个想法:

  • 使用 swf 格式存储 Flash 中的帧
  • 实现 2D 骨骼动画系统,替换 png 序列(我担心关节可见)

像这样的游戏如何Castle Crashers 加载速度如此之快,而且高清显卡出色?

I am in the process of writing a full HD capable 2D engine for a company of artists which will hopefully be cross platform and is written in OpenGL and C++.

The main problem i've been having is how to deal with all those HD sprites. The artists have drawn the graphics at 24fps and they are exported as png sequences. I have converted them into DDS (not ideal, because it needs the directx header to load) DXT5 which reduces filesize alot. Some scenes in the game can have 5 or 6 animated sprites at a time, and these can consist of 200+ frames each. Currently I am loading sprites into an array of pointers, but this is taking too long to load, even with compressed textures, and uses quite a bit of memory (approx 500mb for a full scene).

So my question is do you have any ideas or tips on how to handle such high volumes of frames? There are a couple of ideas i've thought've of:

  • Use the swf format for storing the frames from Flash
  • Implement a 2D skeletal animation system, replacing the png sequences (I have concerns about the joints being visible tho)

How do games like Castle Crashers load so quickly with great HD graphics?

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

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

发布评论

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

评论(2

梦幻的心爱 2024-12-10 15:39:46

首先要记住的是,并非所有平台都支持 DXT5(特别是移动设备)。

除此之外,您是否考虑过使用 zlib 之类的东西来压缩纹理?纹理可能具有相当程度的自相似性,这意味着它们会被压缩很多。在当今时代,由于处理器的速度,解压缩很便宜,并且从磁盘上获取数据所节省的时间可能比解压缩所损失的时间有用得多。

如果我是你,我就会从那里开始。

Well the first thing to bear in mind is that not all platforms support DXT5 (mobiles specifically).

Beyond that have you considered using something like zlib to compress the textures? The textures will likely have a fair degree of self similarity which will mean that they will compress down a lot. In this day and age decompression is cheap due to the speed of processors and the time saved getting the data off the disk can be far far more useful than the time lost to decompression.

I'd start there if i were you.

回忆躺在深渊里 2024-12-10 15:39:46

24 fps 手绘动画?有没有考虑过降低帧率?即使是电影品质的赛璐珞动画也很少以全 24 fps 绘制。即使降至 18 fps,也会丢失 25% 的数据。

无论如何,您都没有指定加载时间较长的位置。是从硬盘到内存的负载有问题,还是内存到纹理负载有问题?您是否经常将纹理数据集交换到 GPU 中,或者只是在加载时从中构建一堆纹理?

如果是磁盘负载问题,那么您唯一真正的选择是压缩磁盘上的纹理数据并将其解压缩到内存中。 S3TC式的压缩并没有那么压缩;它被设计为一种用于纹理硬件的可用压缩技术。通常可以通过在其上使用标准压缩库(例如 zlib、bzip2 或 7z)来使其更小。当然,这意味着必须对其进行解压缩,但 CPU 的速度比硬盘更快,因此总体而言这通常是一个胜利。

如果问题出在纹理上传带宽上,那么解决方案并不多。好吧,取决于您感兴趣的硬件。如果您感兴趣的硬件支持 OpenCL,那么您始终可以将压缩数据传输到 GPU,然后使用 OpenCL 程序将其即时解压缩到 GPU 内存中。但需要 OpenCL 支持将影响您可以支持的最低硬件级别。

不要这么快就放弃 2D 骨骼动画。像 Odin Sphere 这样的游戏能够通过每个手臂位置的多个版本来实现更好的 2D 骨骼动画。被绘制的那个是与其所附着的身体部分最接近的那个。他们还使用巧妙的艺术来隐藏任何缺陷,例如喇叭形的衣服等。

24 fps hand-drawn animations? Have you considered reducing the framerate? Even cinema-quality cel animation is only rarely drawn at the full 24-fps. Even going down to 18 fps will get rid of 25% of your data.

In any case, you didn't specify where your load times were long. Is the load from harddisk to memory the problem, or is it the memory to texture load that's the issue? Are you frequently swapping sets of texture data into the GPU, or do you just build a bunch of textures out of it at load time?

If it's a disk load issue, then your only real choice is to compress the texture data on the disk and decompress it into memory. S3TC-style compression is not that compressed; it's designed to be a useable compression technique for texturing hardware. You can usually make it smaller by using a standard compression library on it, such as zlib, bzip2, or 7z. Of course, this means having to decompress it, but CPUs are getting faster than harddisks, so this is usually a win overall.

If the problem is in texture upload bandwidth, then there aren't very many solutions to that. Well, depending on your hardware of interest. If your hardware of interest supports OpenCL, then you can always transfer compressed data to the GPU, and then use an OpenCL program to decompress it on the fly directly into GPU memory. But requiring OpenCL support will impact the minimum level of hardware you can support.

Don't dismiss 2D skeletal animations so quickly. Games like Odin Sphere are able to achieve better animation of 2D skeletons by having several versions of each of the arm positions. The one that gets drawn is the one that matches up the closest to the part of the body it is attached to. They also use clever art to hide any defects, like flared clothing and so forth.

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