4
\$\begingroup\$

I'm creating sprites and tilemaps for 2D games. I might just use Unity.

What is the impact of choosing different options when saving as a .png?

enter image description here

\$\endgroup\$
  • \$\begingroup\$ Are you using an API like OpenGL or software rendering? If the former, PNG may not be the optimal format. \$\endgroup\$ – Maximus Minimus Oct 3 '17 at 19:40
  • \$\begingroup\$ What engine/platform are you using? It's pretty common for engines and editors to read formats like PNG, but then convert them to other formats that work better on the GPU. The same is likely true if you're rolling your own -- you're probably pushing the raw data to the GPU so it won't impact gameplay. At that point, it's a matter of whether you prefer your game to be a little smaller, or load (as opposed to run) a little more quickly. If it's an HTML web game where you're just displaying PNGs in browser then that tradeoff is more important. Web is also only time I'd consider interlacing... \$\endgroup\$ – A C Oct 4 '17 at 0:08
5
\$\begingroup\$

The compression rate of your graphical resources directly affects loading times and size of your game. "No compression" will result in a bigger PNG file, but the file will be opened extremely fast. "Smallest compression" will result in a smaller sized file, but will take considerably longer to decompress and open. Being a lossless format, PNG quality won't be degraded even if compressed (as opposed to, say, JPEG). EDIT: as @Le Comte du Merde-fou has pointed out, the loading times will vary depending on the platform. For example, on some platforms disk I/O will be a bigger bottleneck than decompression process, therefore a smaller file will be processed faster than a larger one. Find out the capabilities of your target platform prior to making the decision.

"Interlaced" option is tricky, though. Depending on your render methods it may or may not have a real impact on your game, so I'd check how your graphical engine handles interlaced/non-interlaced PNG files. There are examples of using either of them out there: for example, you may have noticed how sometimes in some games textures are blurry/low-res, and then gradually improve their quality while loading the full file - that is "interlaced" file in action. Some games simply won't let you see the game world while the textures are still loading: they're likely to use non-interlaced resources, which undergo a different loading process.

The image below may provide a better idea of the differences between the interlaced / non-interlaced PNG files.

Interlaced SimulationNonInterlaced Simulation

\$\endgroup\$
  • 5
    \$\begingroup\$ Depending on the target platform disk IO may be a bigger bottleneck than compute: In other words, getting a smaller file off disk faster may actually be preferable and load faster overall. \$\endgroup\$ – Maximus Minimus Oct 3 '17 at 20:11
  • \$\begingroup\$ That is indeed a very good point. I will update my answer to better elaborate on that. \$\endgroup\$ – altskop Oct 3 '17 at 20:15
  • \$\begingroup\$ I think the "fast/slow" there refers primarily to the speed of saving. I've never observed a significant performance hit due to decompressing a png — it's not an especially complicated operation. In fact, modern dev PCs haven't given me any trouble with saving compressed either, though that might creep in on extremely large images. \$\endgroup\$ – DMGregory Oct 3 '17 at 21:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.