I have encountered two solid grey textures, #303030 and #1b1b1b, being put through BCn texture compression and coming out as #313031 (changed) and #1b1b1b (unchanged), presumably due to the 32-bit (8:8:8) to 16-bit (5:6:5) stage. For a texture with many colors I understand that texture compressor could pick arbitrary endpoints for the palette and I am effectively at the mercy of chance regarding which colors change how much. However, with single solid color textures, I am hopeful that there is some modern equivalent of web-safe colors that I could at least somewhat rely on. Does this exist?
-
2$\begingroup$ I dont see any reason why you can not pick colors that dont change in the 5:6:5 change. But seriously your neglecting to tell what compression yor using. Diferent compressions have different features. Theres no generic rule as how all compressions work. Also be a bit careful when talking about 32 bit color and 16 bit color. In general we are past using total bits per color and instead talk about bits per channel. $\endgroup$– joojaaCommented Jan 18, 2022 at 11:54
-
1$\begingroup$ @joojaa I am not choosing a compression. Engines and drivers and hardware are doing it, in the same way that web designers don't get to choose the web browsers their colors appear in. $\endgroup$– SparrCommented Jan 20, 2022 at 15:06
-
$\begingroup$ @joojaa Would you elaborate on how to pick such a color in an answer, please? I am not aware of a standard mapping of 8:8:8 to 5:6:5 colors that would make such a selection straightforward or reliable. $\endgroup$– SparrCommented Jan 20, 2022 at 15:10
-
1$\begingroup$ Normally webdesigners would compress the image and then view it on several simulations. Websafe hasnt been a thing in ages. $\endgroup$– joojaaCommented Jan 20, 2022 at 16:09
-
1$\begingroup$ and different monitors. $\endgroup$– joojaaCommented Jan 21, 2022 at 6:12
1 Answer
There are two possibilities: you either are in control of the image format or you're not.
If you are in control of the image format, and you need a color to be exact, then use an image format that gives you that exact color. If the color you want cannot be represented in a 5:6:5 format, don't use them.
If you have no control over the image format, then you're going to have to look at what image format you're told to use and find something that's good enough. For basic 5:6:5, that's not too hard. But if you're being forced to use actual texture compression... you're out of luck.
Note that JPEG does not care about "web-safe colors"; it will do whatever it wants to the image. The same goes for texture compression schemes. By using texture compression, you have decided to sacrifice image accuracy for smaller space. That's just the nature of the beast.
-
$\begingroup$ I have updated the question to more explicitly specify hardware compression. This is about compression happening after my image is loaded, as part of sending it to the GPU, not about storing the image in a compressed image format. $\endgroup$– SparrCommented Jan 20, 2022 at 15:09
-
1$\begingroup$ @Sparr: Then you've already made a mistake. You should compress your images before loading them. Not only will you be able to see the results before sending them (and thus modifying the image if it is not satisfactory), you'll be able to use better compressors than ones that have to sacrifice quality for reasonable performance. $\endgroup$ Commented Jan 20, 2022 at 15:12
-
$\begingroup$ I don't have control over all the image processing pipelines that my textures might go through. Someone will JPEGify them. Someone will apply hardware texture compression. Someone will downsample them. This post is about proofing them against one of those operations. This is not a mistake, it's simply a use case you refuse to acknowledge. $\endgroup$– SparrCommented Jan 21, 2022 at 2:23
-
$\begingroup$ @Sparr: "I don't have control over all the image processing pipelines that my textures might go through." Then you have no control over your image, and you therefore must accept that it can be changed in ways you cannot control and therefore cannot account for. Even if there were some answer for one compression technique, who's to say that someone wouldn't invent a new one tomorrow that such a technique doesn't work for? At the end of the day, if you have no control over manipulations to your image, then you're out of luck. Lossy compression techniques are called "lossy" for a reason. $\endgroup$ Commented Jan 21, 2022 at 3:07
-
$\begingroup$ Your argument would declare web-safe colors useless and pointless, despite their clearly demonstrated usefulness. Do you have an argument that does not apply equally to web safe colors as to my request? $\endgroup$– SparrCommented Feb 7, 2022 at 15:09