- Home /
Why does DXT1 compression saturate my lightmaps?
When I import a lightmap and select DXT1 compression (either by script or by selecting it in the Inspector under the 'Advanced' Texture Type), it becomes saturated; all low values go black, all medium to high values go white. Unity defaults to using DXT5 compression for lightmaps, but in my case I'm importing 8-bit grayscale images and the DXT5 compression actually makes the image consume more RAM, not less. The DXT5 compressed lightmap looks correct, but it consumes too much memory.
My understanding is DXT5 supports alpha channels, but my imported lightmaps don't contain any alpha information, so I would think of the two schemes DXT5 would cause problems. Alas, I am wrong.
Any insights?
I know this is super old now, but it seems pretty simple: It's interpreting your image as an alpha image with no RGB data. As noted, DXT1 has no alpha channel, so... Well, I don't know why it does that specifically, but it's just a sideeffect of the algorithm getting data it found completely bizarre.
I might go and find a recent question to answer now and see if I can be actually useful.
Answer by taoa · Mar 15, 2011 at 09:20 AM
Actually lightmaps aren't like normal (understand 'usual') textures. They have a much higher range of color and hence are coded on more than 8 bits per color. DXT1/5 compression works only on 8bits per channel textures, so when you apply such a compression on lightmaps, you bork this higher range of colors, and everything gets clamped to a 0-255 range. That's why everything is broken in your DXT1/5 compressed lightmaps.
Leave lightmaps as they are. If they take too much space in memory, reduce the resolution per world unit when you generate them.
I was not generating lightmaps, but importing them. Loss of detail was not acceptable. "Leave lightmaps as they are" is not helpful. In addition, the original lightmaps Do use 8-bits per color. The extra dynamic range of Unity's built-in lightmaps does not give me anything.
Lightmaps generated in Unity appear to make use of the alpha channel. Although I'm not certain to what purpose Unity needs what is in the alpha channel, it definitely makes use of it. By compressing your texture in DXT1, you implicitly create a texture where all alpha data = 1, for DXT1 compression does not support more than the RGB channels. However if you're telling us that your greyscale lightmaps don't have alpha data (so all is = 1) and they do work fine in DXT5, but not in DXT1, then I don't know...
Answer by Simon-F · Mar 15, 2011 at 08:55 AM
I know this is an old question but, FWIW, for opaque-only textures, DXT1 should be better than DXT5 for two reasons:
It has two choices for representations for each 4x4 region (4 colour and 3 colour modes) so there is a chance it might use the 3 colour if that happens to be a better representation. For some reason the additional mode is not officially available in DXT5.
The compression rate is better with DXT1 (@4bpp) than DXT5 (@8bpp).