Full HD 2D texture memory OpenGL

I am in the process of writing a full-fledged 2D 2D engine for an artist company, which I hope will be a cross-platform written in OpenGL and C ++.

The main problem I ran into is dealing with all these HD sprites. Artists draw graphics at 24 frames per second and they are exported as png sequences. I converted them to DDS (not perfect, because I need a directx header to download) DXT5, which significantly reduces the file size. Some scenes in the game can have 5 or 6 animated sprites at a time, and they can consist of 200+ frames each . I am currently loading sprites into an array of pointers, but it takes too long to load even with compressed textures and uses quite a bit of memory (about 500 mb for a full scene).

So my question is: do you have any ideas or tips on how to handle such large volumes of frames? There are a few ideas that I thought of:

  • Use SWF format to store frames from Flash
  • Implement a 2D skeletal animation system by replacing png sequences (I have problems with visible joints)

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

+6
source share
2 answers

24 frames per second hand-drawn animation? Have you considered reducing frame rates? Even cinema quality animation in cinemas is rarely found at only 24 frames per second. Even lowering it to 18 frames per second will save you 25% of your data.

In any case, you did not indicate where the loading time was long. Is loading from hard disk into memory a problem, or is it memory for texture loading, what is the problem? Do you often change texture datasets into the GPU, or do you just create a bunch of textures from it at boot time?

If this is a problem with disk loading, then the only real choice is to compress the texture data on the disk and unpack it into memory. S3TC compression is not compressed; It is designed to use hardware texturing compression technology. You can usually reduce it using a standard compression library like zlib, bzip2 or 7z. Of course, this means that you need to unzip it, but processors become faster than hard drives, so this is usually a gain.

If the problem is the throughput of loading the texture, then there are not many solutions for this. Well, depending on your equipment. If your hardware supports OpenCL, you can always transfer the compressed data to the GPU, and then use the OpenCL program to unzip it on the fly directly to the GPU memory. But OpenCL support will affect the minimum level of hardware that you can support.

Don't move 2D skeletal animation so fast. Games such as Odin Sphere are capable of achieving better animation of 2D skeletons, having several options for each arm position. The one that is painted, the one that matches the closest to the part of the body to which it is attached. They also use smart art to hide any defects, such as flared clothes, etc.

+2
source

Well, the first thing to keep in mind is that not all platforms support DXT5 (specifically mobile phones).

Besides the fact that you considered using something like zlib to compress textures? Textures are likely to have a fair degree of self-similarity, which will mean that they will compress a lot. This day and at the age of decompression is cheap due to the speed of the processors, and the time taken to get data from the disk can be much more useful than the time lost for decompression.

I would start there if I were you.

+4
source

Source: https://habr.com/ru/post/896797/


All Articles