简体   繁体   English

全高清2D纹理存储器OpenGL

[英]Full HD 2D Texture Memory OpenGL

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++. 我正在为一家艺术家公司编写一个完整的高清2D引擎,希望这是一个跨平台的,用OpenGL和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. 艺术家以24fps的速度绘制图形,并将它们导出为png序列。 I have converted them into DDS (not ideal, because it needs the directx header to load) DXT5 which reduces filesize alot. 我已将它们转换为DDS(不理想,因为它需要加载directx标头)DXT5可以减少文件大小。 Some scenes in the game can have 5 or 6 animated sprites at a time, and these can consist of 200+ frames each . 游戏中的一些场景一次可以有5或6个动画精灵, 每个可以包含200多个帧。 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). 目前我正在将精灵加载到一个指针数组中,但这需要很长时间才能加载,即使使用压缩纹理,也会占用相当多的内存(大约500mb用于完整场景)。

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 使用swf格式存储Flash中的帧
  • Implement a 2D skeletal animation system, replacing the png sequences (I have concerns about the joints being visible tho) 实现2D骨架动画系统,替换png序列(我担心关节是可见的)

How do games like Castle Crashers load so quickly with great HD graphics? Castle Crashers等游戏如何通过高清显卡加载速度如此之快?

Well the first thing to bear in mind is that not all platforms support DXT5 (mobiles specifically). 首先要记住的是,并非所有平台都支持DXT5(专门用于移动设备)。

Beyond that have you considered using something like zlib to compress the textures? 除此之外,您是否考虑使用像zlib这样的东西来压缩纹理? 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. 如果我是你,我会从那里开始。

24 fps hand-drawn animations? 24 fps手绘动画? Have you considered reducing the framerate? 你考虑过降低帧率吗? Even cinema-quality cel animation is only rarely drawn at the full 24-fps. 即使是电影质量的cel动画也很少以24-fps的速度拍摄。 Even going down to 18 fps will get rid of 25% of your data. 即使降至18 fps也会消除25%的数据。

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? 您是否经常将一组纹理数据交换到GPU中,或者您是否只是在加载时从其中构建一堆纹理?

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; S3TC式压缩不是那种压缩的; 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. 通常可以通过在其上使用标准压缩库来缩小它,例如zlib,bzip2或7z。 Of course, this means having to decompress it, but CPUs are getting faster than harddisks, so this is usually a win overall. 当然,这意味着必须对其进行解压缩,但CPU比硬盘更快,所以这通常是一个整体的胜利。

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. 如果您感兴趣的硬件支持OpenCL,那么您始终可以将压缩数据传输到GPU,然后使用OpenCL程序将其直接解压缩到GPU内存中。 But requiring OpenCL support will impact the minimum level of hardware you can support. 但是需要OpenCL支持会影响您可以支持的最低硬件级别。

Don't dismiss 2D skeletal animations so quickly. 不要那么快地消除2D骨架动画。 Games like Odin Sphere are able to achieve better animation of 2D skeletons by having several versions of each of the arm positions. 像Odin Sphere这样的游戏可以通过拥有每个手臂位置的几个版本来实现更好的2D骨骼动画。 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. 他们还使用巧妙的艺术来隐藏任何缺陷,如喇叭形衣服等。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM