Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

RGB is the natural color model for OpenGL. But a lot of other color models exist. For example, CMY(K) for printers, YUV for JPEG, the little cousins YCbCr and YCoCg, HSL & HSV from the 70's, and so on. All these models tend to share a common property : they are based on 3 components.

Therefore my question is : Does it exist a 2-components color model ? I'm surprised to not find any. I was expecting something along the line of Hue+light could exist. I guess it cannot be as "complete" as a true 3-components color model, but a fine-enough approximation will be good for my usecase.

The end objective is to store the 2 components into a single BC5 texture (GL_COMPRESSED_RED_GREEN_RGTC2 in OpenGL). The 3rd component requires a second fetch into a second texture, which hurts performance.

share|improve this question
    
"The end objective is to store the 2 components into a single BC5 texture (GL_COMPRESSED_RED_GREEN_RGTC2 in OpenGL)." A RG_RGTC1 (and that's the correct enumerator) takes up 128-bits per pixel. An S3TC-compressed RGB texture using DXT1 takes up 64-bits per pixel. It makes no sense to use a larger compression scheme for something even if it would work. Existing S3TC compressors are pretty good as is, and BC6 is also much better without being larger. So there's no point. –  Nicol Bolas Nov 3 '12 at 18:36
    
is GL_COMPRESSED_RED_GREEN_RGTC2 an ARB_only extension ? –  Cyan Nov 4 '12 at 18:27
1  
No, there is no such enumerator. There is GL_COMPRESSED_RED_GREEN_RGTC2_EXT. But, as the EXT suffix suggests, that comes from EXT_texture_compression_rgtc. Which you shouldn't bother using. And I made a mistake; the correct enumerator was RG_RGTC2, not RGTC1. –  Nicol Bolas Nov 4 '12 at 18:59
add comment

2 Answers

up vote 13 down vote accepted

Humans have trichromatic color vision, so the space of colors we can see is fundamentally three-dimensional.

(Well, for most of us, it is. Colorblind people may only have dichromatic or monochromatic vision, and there may be a small number of people who can (barely) distinguish an extra dimension. Also, technically, even normal humans do have a fourth type of photorector — the rods — but those are only active in low light conditions where normal color vision starts to fail, and are not believed to contribute to it in any significant way.)

You can encode the position of a color in this three-dimensional space in different ways, which gives us various color representations like RGB, YUV, HSL, Lab, XYZ, and so on. But the one thing all these color spaces have in common is that, in order to be able represent all colors humans can see, they need at least three coordinates.

(The reason CMYK uses four coordinates comes down to the limitations of printing technology, and specifically the fact that it's hard to get a good black just by mixing colored inks. The extra channel is, strictly speaking, redundant to the other three, but exposing it to the graphics software allows more detailed control of the printing process.)

Certainly, if you only wanted encode a subset of the colors, you could pick some two-dimensional surface within the three-dimensional color space and encode your colors as their position on that surface. A simple way to do that would be to take one of the existing three-dimensional color encodings and fix one of the coordinates at a constant value (or at some value that changes as a function of the other coordinates). For example, if you wanted all your colors to be maximally saturated, you could take the HSV or HSL color spaces and fix the S channel at 100%, leaving you the two other channels.

share|improve this answer
    
Thanks very much, this is very clear. –  Cyan Nov 3 '12 at 14:27
add comment

I know this is an old and already answered question, but I have a different opinion than @Ilmari Karonen.

"Humans have trichromatic color vision, so the space of colors we can see is fundamentally three-dimensional."

If you compare human vision to digital color model, our vision would be closest to L-RGB, therefore it is a 4-component color model (it is very difficult to actually define color). This is because we have two types of cells: rods and cones. It is true that considering only cones, we have similar model to RGB, because there are three types of cones, sensitive to wavelengths that we call blue, green and red. But we also have rods, which are very sensitive to green wavelengths and our brain doesn't interpret this as green, but as light/dark. Cones are more active when there is more light, rods takes over in the dark, but both work together (you can't shut them down). It's one of the reasons some camera chips have 4 componets on a pixel (blue, red, 2x green). Of course the others and more significant reasons are spectral sensitivity, which peaks around the "green" light wavelength:

Spectral sensitivity

And also the fact you have square pixels that you cut into 4 subpixels...

Digital color models probably can capture "all colors humans can see". Different scientists will give you different answers. But 24-bit color space is more than enough. And we can't distinguish close colors next to each other anyway.

Computer screens always considered RGB human vision model to give us the most natural picture. CRT screens have three phosphore dots, LCD panels three sub-pixels. Some screens have 4 (with extra yellow I think).

Therefore three component RBG model is most natural and easiest to use and other models are just encodings of this model to allow subsampling and other manipulations. E.g. subsampling in YCbCr works, because human vision is more sensitive to light/dark contrast than color change (again we have more light/dark sensitive cells and also human brain works that way).

IMHO a better 3-component 24-bit color model would encode Green using 10 bits and blue and red using the remaining 14 bits, then a better TV would use bigger green subpixel than the red and blue...

The reason why there is no 2-component color model is because there is no need for it. You can create arbitrary color model, for 2-components "lightness and hue+saturation combined". Then create an 8-bit pallete for the hue+saturation combined channel. With 256 lightness values, you will have pretty good model. But it will be quite useless, hard to manipulate and unnatural and you will have to provide quite complex formula RGB->Your model->RGB.

So instead of trying to save bits using 2-components model, we just use 3-component model with subsampling.

Note that the old 256 palette can be considered a 1-component model. If you increase the palette storage to 16-bits, you will get 65536 palette 1-component model and so on.

Conclusion

It doesn't matter how many components your model has! The most important thing is that naturally you capture RGB with our current technology and you reproduce RGB with current technology. This feels natural to human eye. Whatever you do between capturing and reproducing is upto you. We just invented color models that are easy to manipulate, encode or somehow useful.

share|improve this answer
    
Thanks for this very complete answer. This gave me a few more ideas to try out :) –  Cyan Jun 5 '13 at 9:19
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.