The RGB Matrix Process Effect

In my latest live stream, I did use the RGB Matrix Process effect quite a lot for changing the colors of fills ans symbols. I this article, I’ll dive a bit more into this effect and describe it in a bit more detail.

The effect itself is just a basic color-replacement effect, but all those text fields with numbers can look quite a bit daunting when you open it up for the first time, but you can use it to make some nice results. You can see some examples in this older blog article where I also touch briefly on this effect, but today I’m going to explain it in a bit more detail.

To understand this effects, you need to understand how the computer sees colors. To a computer, a color is just a number, which represents the amount of red, green and blue in the image. The computer would just see it as a large number, but for readability to humans we usually break it down into the individual components for red, green and blue. For example, the orange found as color number 8 in CC3+’s palette is simply known to the computer as 16738048, but it is usually displayed to us humans as RGB(255,103,0) or more verbose 255 red, 103 green and 0 blue. These values vary from 0 for none to 255 as the maximum, so you can see that the orange color from my example here is composed of a lot of red, a moderate amount of green and no blue. Do note that computer color mixing doesn’t work quite the same way as mixing them using paint in the real world, in particular you may have learned the the primary colors from which we mix all the others are red, yellow, and blue, but for a computer, using red, green and blue actually results in a larger possible color range. There are other color formats, such as HSL (Hue, Saturation, Lightness) that many programs allow you to work in, but for most applications this is just to provide a familiar interface to more color-savvy users, but internally it is usually simply translated to RGB. I’m not enough of a color expert to explain any of that any further, so let us just continue from here and just keep in mind that computers and displays uses RGB to identify their colors.

Now, the whole idea behind the RGB Matrix Process effect is to manipulate these color values in interesting ways. This can be anything from subtle changes to full reversals. This works by re-calculating those individual color values for the amount of red, green and blue. If you look at the dialog, you can see it is made up from 3 rows, one row for calculating the red color, one for calculating green, and the final row for calculating the blue color. The interesting thing here is that each color can be calculated based on the amount of the other components in the color.

If you look at each row, except from the first letter, they are identical. Each row is a number multiplied by R + a number multiplied by G + a number multiplied by B + a number. The R, G and B refers to the current color components before the change. The final number is multiplied by 255.

The current values shown in my screenshot above are the “do-nothing” values, with these values in place, nothing will change, and the effect won’t have any impact on your drawing at all. To prove this, we’re going to bring out our math skills. We’ll start by using our orange from above as the starting color before the effect is applied. As already noticed, expressed in RGB, the orange is RGB(255,103,0). We’ll now calculate row by row.

The first row is for calculating the new red color component. With the values currently in the dialog, it says to take the current red component value (255) and multiply it by 1, then adding the current green value (103) multiplied by 0, then the current blue value (0) multiplied by 0 and finally adding the number zero. Expressed as a formula, this becomes:

Red = 1*255 + 0*103 + 0*0 + 0*255 = 255 + 0 + 0 + 0 = 255

Continuing on, we have

Green = 0*255 + 1*103 + 0*0 + 0*255 = 0 + 103 + 0 + 0 = 103

Blue = 0*255 + 0*103 + 0*0 + 0*255 = 0 + 0 + 0 + 0 = 0

Assembling the new components leads to RGB(255,103,0), which happens to be the exact value as before. This happened because what we really did was to make the red component 1 times the old red component, the green component 1 times the old green component, and the blue components 1 times the old blue component. Multiply something by 1 just keeps the old value, that’s one of the most basic fundamentals of math.

So, that got us nowhere. Let us pick up a more interesting filter to use as an example. So, I am still just multiplying by 1 to make real simple calculations. But I have moved things around. Notice how the red component is now expressed as 1 times the old green component. This basically means that any green in the image becomes read instead. Blue becomes green, and red becomes blue. So let us throw up our calculations again:

Red = 0*255 + 1*103 + 0*0 + 0*255 = 0 + 103 + 0 + 0 = 103

Green = 0*255 + 0*103 + 1*0 + 0*255 = 0 + 0 + 0 + 0 = 0

Blue = 1*255 + 0*103 + 0*0 + 0*255 = 255 + 0 + 0 + 0 = 255

So, what does that net us. Collecting the components, and we have RGB(103,0,255), resulting in a strong purple.

Of course, so far we have only worked with a single color. This effect is far more interesting when applied to any kind of texture, since it will manipulate each pixel in that texture individually. For example as you can see in this image showing the standard field fill, applying the RGB Matrix Process effect changes every color a bit differently.

To get the desired result, you do have to be a bit familiar with the RGB colorspace, but even if you aren’t, you can get good results with some simple experimentation. There are a few important details you should be aware of here though. First of all, each component needs to be between 0 and 255. If the calculation ends up with a value higher than 255 it becomes 255, and if lower than 0 it will be come 0. There is no wrap-around here. This means that the values you want to use in this dialog is generally small, be especially aware of the last box which is multiplied with 255 which can very easily push the component to max unless you are careful. Decimal numbers are quite fine in the dialog, and you probably want to use those, especially for more subtle changes, just look at the values I used for those fields. Lastly, negative numbers are also fine. Do remember that you don’t need negative numbers to reduce a component though, if you put 0.5 in a box, that means half of the old value, which is a big reduction. Keep in mind that reducing is important, because since you can’t get above 255, adding adding additional blue if blue is already a 255 won’t do anything, you need to compensate by reducing the other components instead so it is more blue relative to them.

Now, with this in mind, let us try making a snowy version of our fields. It helps to keep in mind that pure white is RGB(255,255,255), so even if we don’t aim to make everything pure white, it is clear that we need to more or less increase all the colors. So, what I did to achieve the result below was first to balance the colors a bit. You’ll notice that I’ve expressed every component as a combination of all three components. When starting out, the fields were green, so they naturally had a rather high green component compared to red and blue. But when going for white, I needed more similar values, just trying to increase them all wouldn’t have gotten the result I wanted. So, I did experiment a bit to find the perfect mix, but in the end, I found that mixing each component as 0.6 of itself plus 0.3 of each of the other two worked very fine. It got a bit grayish, but I also know that going from grey to white just means adding a fixed value to each component, so I entered 0.1 in the final field for each component. And voila, snowy fields on a lush green grassland.


Special considerations for symbols

Note that if you try to use this effect on symbols, you may find that it doesn’t seem to work. This is caused by how symbols are processed in the effects calculation, but the good thing is that you can easily change this behavior. If you just type DELAYDRAWSYM on the command line followed by enter, CC3+ will ask you if this should be enabled or not. Answer with 0 for disabled, 1 for enabled. 1 is the default value, but also what prevents this effect from working with symbols. So, answer with 0 to turn off this behavior, and you’ll find that this effect now works fine with symbols. Note that this is a temporary command which will only last until you close CC3+. This command just changes CC3+ behavior, and does not change anything in your actual map. To always have this disabled when opening the map, you can add it to the OnOpenMacro map note for the map.



For a final example, I am going to leave you with this rendering of the example map from the CC3+ manual, with some rather drastic color change applied. All this is simply done by a single RGB Matrix Process as a whole-map effect.

If you have questions regarding the content of this article, please use the ProFantasy forums. It can take a long time before comments on the blog gets noticed, especially for older articles. The forums on the other hand, I frequent daily. Also, to see this effect in action, I recommend watching the live stream recording I linked to in the beginning of the article.

3 Responses to “The RGB Matrix Process Effect”

  1. Bravo! Thank you for this, Remy 🙂

  2. The predefined “Gray” setting is the standard RGB to luminance (grayscale) transform. The predefined “Sepia” setting is pretty much the same as the Gray setting, but with a little bit added to the red and green to get a warmer orangish color.
    Setting everything to 0 and then putting the RGB value to a desired color value is a way to set everything on a sheet to the same color without changing the fills of everything. Setting the diagonal to something like 0.5 (instead of the 1 of the unity transform) and then adding the desired RGB down the last column is a way to get a somewhat-controllable colorize effect.

  3. That’s great, Remy! I’ve been trying for some time to apply a specific RGB matrix that work in my map to the symbol set, and now I finally know how to. Thanks.