Colors by Addition

Hi there,
I am making a color match game but adding colors to total a target color is a bit of a nightmare.

I have tried everything so instead of describing my various attempts for a solution, let me give you my goal and perhaps someone will undertstnad what I mean and know of a solition.

In short, the game works as this:

  1. Player given a target color, example Red
  2. Player given an array of Color Units, example blue, green, yellow, magenta
  3. Task, Player must select the colors (Color Units) that will mix properly to become Red.

Simple right???

Not so much, at least at the moment.

If someone can see what I am aiming for and how to achieve it, please pass on your superiour knowledge!!

Thank you

Red is a primary color (for light) so it can’t be created by adding any of these, Are you using some subtractive color scheme or something?

Actually not that simple. You seem to assume some color model where adding multiple colors together would lead to red, without actually specifying that color model. And if you read the text below, you will see why exactly what you’re trying to accomplish is confusing, to say the least.


First things first, humans perceive colors through photo-receptive cells at the back of the eye. There are three types, each detecting a relatively narrow frequency band with varying sensitivity. Thus humans can only really perceive red, green, and blue hues and combinations thereof. Lacking in any one (or even two) of these types of cells is why some people have color blindness.

Then there are several major color models, with the most important ones being additive and subtractive, really as two major concepts of color reproduction for typical human consumption, if nothing else.

Additive model is used with screen technologies, given that the screens either fire electrons onto some phosphor deposit directly (that part is actually called the screen), or are transparent but backlit with balanced white illumination (modern screens are like sandwiches of various materials that can filter, polarize, or emit photons), then the set color frequencies reach our eyes without bouncing off of some medium, however mixing is not really required if the different color constituents are small enough (again the pattern of dots that we call subpixels) so only red, green, blue suffice in producing the desired color perception. It is an additive process because we add to the black base. This model is known as RGB.

Subtractive model is used in the printing technology. You take a “white” paper (although nothing is ever truly white or else it might hurt your eyes, so it’s an approximation of balanced hues among those that we can normally perceive) and remove particular frequencies until what gets bounced off is perceived as a color. Process printing for example uses patterns of small dots and just 4 colors of which 3 are considered primary. These are typically transparent and that’s why they mix together when layered on top of each other. In this model, we apply red, green, and blue frequencies, however we perceive them backwards as the light gets bounced off of the paper, hence the colors appear as cyan (white - red), magenta (white - green), and yellow (white - blue). If these colors all get applied at once in heavy saturation they appear muddy and washed because they’re transparent, so we also use pure black (which is more opaque) to attenuate these indeterminate areas and/or to produce a sharp black contrast (for example in typography). It is a subtractive process because we take from the white base. This model is known as CMYK.

What you’re possibly referring to could be the RYB model, which is the legacy approximation to modern CMY(K). This is also a subtractive model used for developing intuition for mixing artistic (physical) paints.

However, even if you did refer to RYB, here the color red is also considered as a primary (just like in RGB), and so the only model where you would arrive to red by mixing several components is CMY(K), but this isn’t how screens work, so nobody uses that in relation to computers. In Photoshop and Illustrator and similar programs for prepress and print design CMYK color model is very much present as a concept, but it’s entirely simulated, and there are many parameters to such a simulation, based off of measurements of “pure white”, “human color perception” and so on. Such applications exceed the normal usage of Unity and would be likely expensive (in performance terms) and/or highly sensitive to various physical parameters to little to no practical benefit. This is because the color gamut of CMY is smaller than RGB, and RYB is even worse.

Here you can read more about the color models and the history regarding them because it’s a deep topic in itself.

Finally, if you wanted to build a game in which you would simply present some pure colors and allow the user to combine them in a subtractive (CMY) fashion, then this question should’ve been phrased differently, because it has nothing to do with colors per se. You can equally make a game in which selecting 3 symbols from the same family is registered as a match, and later switch to colors in place of symbols, so I’m not sure why you would fixate on colors in the first place.

Hey,
so I am swapping RGB into HSV, then back.

This appears to work.

I did not know HSV even existed until yesterday!

Sure, I guess you never used Photoshop or a similar software before (like Gimp)?

But then I don’t understand how do you mix colors with HSV. It is just a model of all hues radially distributed over a cylinder. Adding two colors makes very little sense in this context. Do you add two angles or find an average angle between them?

The latter makes sense, but the result is effectively the same as doing an average between two RGB colors (effectively a lerp), so I don’t get what you gain from HSV. It is honestly only useful for a couple of things: 1) nicer gradients and animated color cycling, 2) user color picking, 3) color randomization that lands on aesthetically pleasing choices, 4) changing color value without changing hue or shifting hue without changing saturation, etc. It is extremely useful, just not when mixing colors together.

Edit:
Although HSV does help if you want to logically distinguish colors by hue. Maybe that’s what was bothering you?