A guide to var textures optimization

Guides A guide to var textures optimization

⚠ PLEASE:
  • If you like this resource, consider liking and reviewing it for the community
  • Take your time to read. I will not answer private messages asking questions about things that are actually explained in the tutorial.

texture-tutorial-title.jpg


Intro

VaM is hard, yeah. Creating content requires a lot of time to understand all the complex mechanics of the game. And optimization is something even harder because it's not the really fun part of the production of any type of content for VaM.

But I think that any type of optimization possible will improve the community and the great content we can get on the hub. Texture optimization is really important to optimize your var files.

I've just started fiddling around with clothes ( so bear with me, you might be able to see some glitches on that title shot ;) ). And I started to compare texture size ( the file size ) of my files to other releases to see if I was doing mine properly.

And, as you might suspect (since I'm writing this), a lot of textures on the hub are far from being optimized... so let's dive into this.


Benefits

This way of saving your textures will divide in most extreme cases the size of the png files by two. Here is an example with the current set I'm working on for Space Force.

Left, source files. Right, final recompressed files.
Source is 88.2mb of data. Final recompressed files are 44.3mb. That's almost a 50% SSD/HDD space gain.

sf_textures_source.gif
sf_textures_final.gif


And this, are two shots taken to compare the quality loss.

Left, uncompressed textures. Right, compressed textures. And yes, of course, these are two different images taken with different textures... i'm not writing this just for fun :]

delta-costume-uncompressed.jpg
delta-costume-compressed.jpg


Quantizing the file ( converting it to a 8bit color indexed image ), will obviously not be exactly the same as the original file and might have tiny differences. But even if you'd find a difference in the compressed version. It is not worth the 50% more data in our var files.

For instance, for transparent png with really subtle gradients, you might not want to quantize. Because gradients will be quantized and it will produce a subtle "noise effect".

Until we're on VaM 2 with native textures optimized by the engine, this is still the best solution to keep the highest quality possible while reducing the file size.


What do I need ?

To compress your png textures properly, you will need:
  • SuperPNG
  • Either Photoshop, or any software handling photoshop plugins. (Gimp does)


How do I do it ?

When you have the tools. Save your png file with SuperPNG.

super-png-config.gif


Be sure to have (1) on Smaller files. Quantize enabled at Highest Quality (2).

(3) Alpha channel: every VaM texture should be opaque (None) excluding decals textures (Channels palette or it will be the name of your alpha channel in the place of "Channels Palette"). This applies to both clothings or character textures.

clothings_textures_panel.gif


Opaque textures (No alpha / None) for:
  • _MainTex
  • _SpecTex
  • _GlossTex
  • _AlphaTex
  • _BumpMap
Transparent textures:
  • _DecalTex

You can if you want check "Clean transparent" if you encounter compression issues. Unless you have a problem, this option can be left unchecked.

Hit save you're done.


But it's tedious and long !

Yes! But this is where you use the batching system of Photoshop.
You save an action/script, and batch a complete folder without having to do every single file manually.

As said earlier, I know that Gimp handles photoshop plugins, but being a Photoshop guy, I have absolutely no clue if Gimp handles batch processing. If you don't have Photoshop, you will have to find out by yourself.

Another note: yes it is long and tedious. But people from the community will thank you for releasing awesome and optimized content. And saving 50% of disk space is worth it.


Further optimization

Compressing pngs is nice, but how about using jpgs ?
There is no short answer to that: it depends.

In a situation where you'd import your textures in the game engine and said game engine would compress to the final format, the ideal solution is to use lossless format (like png) and leave the engine do its magic.

In a situation like VaM where you have a native image format. You can push the optimization a bit further
You can pretty much compress anything to jpg with the exception of normal maps.


Understanding why you shouldn't compress normal maps

Normal maps look like images. But they aren't. They are data encoded as images. This picture contains the directions of the normals. We need to have the perfect original values to render the normals properly ingame.

Since lossy image format like jpg creates an approximation of the color values of the pixels and neighboring pixels. Your normals are changed during the compression process. If we translate that to basic numbers as an analogy to simplify the concept : if the first pixel of your image had the value of 1 for the normal direction, compressing as jpg could change it to 0.85.

And we don't want that since it can randomly create incorrect normals and result in artifacts.

Left, lossless indexed png optimized with SuperPNG (open in new tab). Right, jpg compression (open in new tab).

delta-costume-normal-png-compressed.jpg
delta-costume-normal-jpg-compressed.jpg


If you don't see the differences, here is a detail:
  1. Incorrect edge
  2. Loss of precision (the normal becomes blurry)
  3. Loss of "height" / "contrast"

delta-costume-normal-jpg-compressed-details.jpg


Depending on the situation (big details, tiny details etc...), the artifacts and losses in the normals can be widly different and drastically reduce the quality of the final textured model.

Also, with a base "high quality" setup of the jpg compressor, the size is not really far from the png file. You induce artifacts on your texture without real gain on the file size. You would have to reduce the compression quality to save more on the file size inducing even more artifacts.

Conclusion: don't compress your normal maps with a lossy format. Use png and SuperPNG.


So no jpg at all ?

For the other channels ( specular, glossiness, diffuse ) you can use jpg. Just don't sacrifice too much since jpg will still be an approximation of the original file. Find the good balance between file size and quality.

Several things to know when using jpg:
  • For simple png files (not a lot of colours), it is unlikely that compressing it to jpg will be a save. On that basic Space Force diffuse, the original indexed png file is 71Kb, the jpg targeting the same quality is 286Kb.
  • For grayscale or RGB png files, jpg will potentially be a save. Based on several tests, you can get up to 30% reduced filesize without a major quality loss.


Final words

Textures are optimized in the var file. But, there is one important thing to know: the way meshed cache texture files in VaM will NOT reduce the size of the cache file. If you prefer, it is kind of the same behavior as the crunch compression from Unity.

Still, your var file will be way tinier. So it still is really cool to do this process.

This works for any type of texture of course. I have a batch running on all my Substance textures before implementing them into the game.

I think that's pretty much it.
If you have any trouble, or if the guide is missing some information, don't hesitate to poke me, as usual.
Author
hazmhox
Views
5,209
First release
Last update
Rating
5.00 star(s) 2 ratings

More resources from hazmhox

Latest updates

  1. Further optimization update

    Added a section explaining when you can use jpg, and why you should not compress normal maps.

Latest reviews

Very helpful guide
Upvote 0
Thank you, many people could learn from this, I've seen some model sizes that are EXTREME, someone will upload a shirt and its like 800mb lol
hazmhox
hazmhox
Thank you Nawen!
And yeah haha 8'D this is some of these type of releases and my investigation in the clothing system that made me wanna do that article.
Upvote 0
Back
Top Bottom