Thanks for your replies and ideas
A couple of points:
- That's tricky. Only 2 GiB? Seems a bit low - 32 bit textures should require >4 GiB of VRAM (1920x1080x4x500).
Yeah, it's actually 4GB. I just eye-balled 2GB on the task manager incorrectly. So this means that that RAM also becomes a problem.
- Do you really mean the white background should be transparent, or rather alpha channel and alpha blending? Can you post the video or at least a single, representative PNG frame?
I just want the white background to be fully transparent (alpha=0 on those pixels).
- If you really have to do it with PNGs, my first idea would be a ring buffer of n Images and a background thread that loads the image data while the animation plays.
- and as they are "used up", keep requesting loading new ones from storage
The whole thing takes a minute to load but only plays for 10 seconds, I don't think a ring buffer that's loading things from storage is going to help much here. One image takes 0.12s to load up on my SSD, that means we can load 80 images images in 9.6 seconds. So in the best situation we're only going to keep 80 less frames in memory which isn't super significant.
- There's compressed texture formats that would require less memory at runtime
I might try these to at least reduce the RAM usage, the loading can be done in a thread before the level loads at least. So then having 2 of these animations in memory will be hopefully less than 8GB.
- you might be able to use a shader to replace that specific color with transparency
I thought about this as well, but it just seems super hacky and would rather explore other options.
edit: I'll try loading up the images in multiple different threads, maybe the loading was a bit CPU bound by processing the image on load instead of storage bound. Although if it's CPU bound it wouldn't really matter since lua is single threaded.
edit edit: coroutines make absolutely no difference