[TUTORIAL] Optimizing Textures and Images

I commonly see games ignoring the effect of using lots of fancy graphics and how it affects game performance. Why is it important?

When you upload images they are uncompressed. This can dramatically affect the loading times and memory usage of your game. If you want to avoid this, you have a couple options:

  • Take advantage of parts (ignoring CSG)
  • Cut down heavily on unique assets
  • Heavily optimize assets

Here’s an personal recent example:

Bunch of fantasy gear.
Texture sizes range from 720x720 to 3840x3840 and take up 800kb on average. That’s a lot.

How do you fix this?


Photoshop method

1.) Put all the textures in a folder

2.) Open up Photoshop (I use CC 2018)

3.) Go to File > Scripts > Image Processor

4.) Choose folder you created earlier
image

5.) Choose save location
image

6.) Copy settings and change 420x420 to whatever you want to downscale to (lower the better).
image
You can also change the JPEG quality from 1-12 (lower = more compressed)

7.) Run it!
image
turn off ‘Include ICC Profile’ if you run into errors


Online method

1.) Go to either compresspng.com or tinypng.com (tinypng makes you pay for more than ~10 images)

2.) Drop in textures you want to compress

3.) Download results

4.) Bulk resize image to 420x420 (or lower) using Resize multiple images at once!


Before:

(Example asset)

image (24 textures)


After:

(Example asset)

image (24 textures)


Let me know if this helped you!

75 Likes

So I think you had the right idea when posting this, but then you say a few things that contradict each other

Correct, the on-device memory for textures is about the actual size of the image, not about file type or compression methods used.

So, these sites will certainly decrease the file size and that may improve loading times, but if you don’t decrease the canvas size of the images, the on-device memory usage is still just as high. Compression won’t help with on-device memory because, as you said, images are not compressed on-device.

The same here: changing the file size will reduce both on-device memory and may reduce network usage, but changing JPEG quality may only affect network usage, and will not affect on-device usage.

Disclaimer: I don’t know how images are sent over the network (uncompressed vs compressed). I’m assuming compressed above but it may not be the case (in which case, all the more reason to reduce canvas size vs compressing your images).

Minor note: if your image has any dimension over 1024, it is scaled down to 1024. So 3840x3840 will be turned into 1024x1024 once uploaded to Roblox.

13 Likes

This is correct, I’ll edit post with disclaimer or alternative method.

Compression is to lower file size and download time. Shrinking the canvas size lowers the memory taken up by the image.

I believe this only affects decals. Let me know otherwise!

4 Likes

This affects any image asset, so also textures of meshes. (disregarding some stricter requirements of i.e. badges/clothing templates that require a specific size)

3 Likes

Last I checked (which was some time ago) images uploaded to roblox are re-encoded, and with sub-optimal compression. Have you compared with images downloaded from the actual roblox CDN?

Here ya go

Roblox (before)

Roblox (after)

Source (before)

Source (after)

5 Likes

I don’t think “optimizing” textures manually is going to be something you’ll have to do in the coming future, as Roblox is adding in an auto-compression thing for quality levels, according to the Roadmap.

3 Likes

90% chance that’s not going to affect loading times, I think it’s more of an LOD thing.

1 Like

Very nice, thanks for the tutorial!

That is a good point.

Still though, thanks for the tutorial.

I never really realized how much of a hit textures are on loading times. Luckily, though, a lot of my textures are below the 200kb mark.

Very good tutorial. In some of my large games graphic textures take upwards of 500mb of storage.

There are additional ways to save on MBs.

For textures that have no holes, you can use JPG compression to save even more space due to its lack of Alpha channels, unlike PNG.
Resampling in Bilinear also further reduces file size (for PNG, it has no effect on JPG).

If having the alpha channel (texture transparency) is important, but you still want to save even more memory on your textures, you could convert your PNG images to PNG-8 (rather than the standard PNG-24). It does reduce the maximum colours the file can have, but it doesn’t matter for a lot of textures as it won’t be too noticeable in games, especially on smaller objects.

PNG-24 vs PNG-8
image

I’d still advise using JPG over PNG-8 wherever possible.

6 Likes

Also I gave your method a shot, and the results were extremely good. Other devs should definitely consider optimizing their textures in game.

(Before)
image

(After)
image

I think the difference in texture quality if definitely worth it, its not overly noticeable at all.

(Before)

(after)

4 Likes

Nice textures. I can definitely see some issues with the red blurring and merging together due to compression and jpeg exporting. I plan on providing texture detail in my game so players can choose what quality to play at. (Ex. 1024, 512, 256) This will allow for players with a wide range of hardware to play. I am also creating a model quality selection to further enhance playability from devices so I can have more users able to play the game. I think this is why a lot of lower poly games are trending on Roblox right now because a wider variety of hardware can run and I am going to be honest, a good portion of Roblox has weaker hardware.

I was planning on using 2048 too until I just figured out in this post that Roblox does not support higher resolution textures.

2 Likes

Thing is, when I turn on voxel lighting (FIB) the lesser detail in the textures becomes even less apparent.

1 Like

I haven’t compared results yet but it sounds promising.