Jump to content
  • entries
    944
  • comments
    5,899
  • views
    929,480

Terrain Compression


Josh

2,782 views

 Share

I wanted to see if any of the terrain data can be compressed down, mostly to reduce GPU memory usage. I implemented some fast texture compression algorithms for BC1, BC3, BC4, BC5, and BC7 compression. BC6 and BC7 are not terribly useful in this situation because they involve a complex lookup table, so data from different textures can't be mixed and matched. I found two areas where texture compression could be used, in alpha layers and normal maps. I implemented BC3 compression for terrain alpha and could not see any artifacts. The compression is very fast, always less than one second even with the biggest textures I would care to use (4096 x 4096).

For normals, BC1 (DXT1 and BC3 (DXT5) produce artifacts: (I accidentally left tessellation turned on high in these shots, which is why the framerate is low):

bc1.thumb.png.2a81c223276826d5ee98ab328e443f8d.png

BC5 gives a better appearance on this bumpy area and closely matches the original uncompressed normals. BC5 takes 1 byte per pixel, one quarter the size of uncomompressed RGBA. However, it only supports two channels, so we need one texture for normals and another for tangents, leaving us with a total 50% reduced size.

bc5.thumb.png.858fe92b0ec47bae741b82395946b3ca.png

Here are the results:

2048 x 2048 Uncompressed Terrain:

  • Heightmap = 2048 * 2048 * 2 = 8388608
  • Normal / tangents map = 16777216
  • Secret sauce = 67108864
  • Secret sauce 2 = 16777216
  • Total = 104 MB

2048 x 2048 Compressed Terrain:

  • Heightmap = 2048 * 2048 * 2 = 8388608
  • Normal map = 4194304
  • Tangents = 4194304
  • Secret sauce = 16777216
  • Secret sauce 2 = 16777216
  • Total = 48 MB

Additionally, for editable terrain an extra 32 MB of data needs to be stored, but this can be dumped once the terrain is made static. There are other things you can do to reduce the file size but it would not change the memory usage, and processing time is very high for "super-compression" techniques. I investigated this thoroughly and found the best compression methods for this situation that are pretty much instantaneous with no noticeable loss of quality, so I am satisfied.

  • Like 5
 Share

1 Comment


Recommended Comments

I was curious to see what would happen if I ran the compressable images through Crunch. The final result was 27 MB, which is 55% the size I got already and 25% the original uncompressed data size (with several minutes of processing time). This isn't a huge difference over the existing compression, but it's enough to consider working that into the pipeline in the future. For general texture data, it could definitely make your game install size quite a bit smaller, if you were using DXT but BC7 is so much better I don't see why you would want to.

Link to comment
Guest
Add a comment...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...