Version 1.0
Outline to this version. I wrote (SNQQPY.DOG) the first description of the use of the 0xc9 command. Where I referenced certain colour ranges that could be used to change scenery colouring, including the track. Addie Walti then discovered that the 2nd and 3rd parameter references were actual pointers to the palette index, and that GP2 changed these using the HSB scale. At that stage we weren't positive as to how exactly the first two pointers were being used. This I have now uncovered and this tutorial is a combination of our efforts.
With 0xc9 (201) you can Set the Colours in the GP2-Palette
Each colour has a unique index number that GP2 uses to point the Graphics-Engine to.
In the above example index (186) is currently selected.
What is important to remember, is that Graphics used in GP2 (Bitmaps), are using these colour indexes to produce your pictures. The trees, the buildings and road etc. are all produced this way. The colours you see in the bitmaps are not necessarily the actual colours used in GP2, although they may be similar in certain cases. What GP2 does is to use these colours referenced by their indices, to change all occurrences of that colour index, to any colour mixed, using Hue, Saturation and Brightness values.
GP2 has determined that certain colours have been reserved for use within certain aspects of the simulation (Although not exclusively). I have listed these below
Description Palette Indices
Buildings & Walls 176-185
Gravel Traps 96-103
Scrubland 112-123
Sky 124-134
Tarmac 186-193
Trees & Bushes 194-213
Verges 104-111
This is not a definitive list, and I do know that certain colours indexed in the ranges above cover some colours in the horizon bitmaps.
So let's refer to them as Quasi-reserved index colours.
In practice this means that if you wish to produce the colours of tarmac to make a road, the bitmap has to be produced with these index values. These colour indices are then looked up by the Graphic-Engine (In GP2), and however the colour is defined there (Hue, Saturation, Brightness), it is changed to produce the desired colour. This method allows GP2 to produce far more colour types than that shown in the GP2 palette shown above.
Of course we could also produce new bitmaps (Jam Sets) for use within Gp2 and this method is used already. However, if you want to have different coloured grass, trees and scrubland. With the process described here, you can use the same bitmaps and change the colour through the Quasi-reserved index method.
There is also the HSB colour scale, H=Hue Angle; S=Saturation; B=Brightness.
You may also find HSL (L=Luminance) and HSV(V=value), the principle use is exactly the same but some may use 0-255 for the S&B values and others use a percentage.
Here are some examples of HSB Charts
All these colours below are the pure 100% colours in the scales mentioned but converted into the HSL Scale
CMYK Scale Matched to HSB (HSL;HSV)
H S B
Magenta 300;100;100 Pantone Process 148-1
Cyan 180;100;100 Pantone Process 232-1
Yellow 60;100;100 Pantone Process 1-3
RGB Scale Matched to HSB
H S B
Red 0;100;100 Pantone Process 73-1
Blue 240;100;100 Pantone Process 184-1
Green 120;100;100 Pantone Process 274-1
Black on any scale is 0; 0; 0
Although if you have the Brightness value near (0) it will tend to look black even if its Red or Green.
My reference has been using Corel Draw. I found this useful because having chosen a colour mix you are able to switch between the different colour scales to see what values are used to make up that colour. They also identify the exact Pantone Process Colour reference. So theoretically if the marketing department at Magnetti Marelli use Pantone Process Blue as their colour we are able to match that logo perfectly in GP2.
GP2 seems to work with the HSB (Hue Angle -Saturation - Brightness)
(At least when dealing with the cmd 0xc9).
When selecting a HSB-colour, we set a value for the Hue Angle, the Saturation and the Brightness. These three parameters define the colour.
So lets look at the chart in more detail
In the previous and above examples, the circle represents a colour scale of 360deg, 0-359. In the above chart, the pointer is at 240 on the Hue Angle Circle.
With Saturation and Brightness both set at 100%. If Saturation of colour is reduced the marker would move toward the circles centre. Brightness on here is shown by the separate Bar scale, and it can clearly be seen that a continual reduction in brightness will eventually produce a colour close to black. In fact no matter what colour we show the same would be true.
OK, so how do we transfer our chosen colour into Grand Prix2? Well the easy part is deciding the colour or range of colours to use.
From Track Editor 1.6
If you then double (left) click one of 0xc9 commands you will open the Command Editor.
From Track Editor 1.6
The arguments of the cmd 0xc9 are:
a1: always 0 ? (so Far)
a2: Pointer to Palette Index 1
a3: Pointer to Palette Index 2
a4: Hue angle 1
a5: Hue angle 2
a6: Saturation 1
a7: Saturation 2
a8: Brightness 1 (The Graphic shows Intensity Value - But Brightness is more appropriate)
a9: Brightness 2 (The Graphic shows Intensity Value - But Brightness is more appropriate)
The order that values are entered in the editor is important.
It is possible to enter Index Pointers as a range of indices (to change all colours in the range), or they can be changed individually.
If you are dealing with a an index range of colours, then you need to know that the arguments are grouped together thus;
a2; a4; a6; a8 - Starting point Index; Hue Angle at a2; Saturation at a2; Brightness at a2
a3; a5; a7; a9 - End point Index; Hue Angle at a3; Saturation at a3; Brightness at a3
Another Graphic may help
From Track Editor 1.6 - Colour Highlights for clarity Only
The yellow highlights show the group of Palette Index 1 - Start Pointer
The cyan highlights show the group of Palette Index 2 - End Pointer
If we are dealing with a Single Palette Index then the references change and become;
a2; a5; a7; a9 - Single point Index; Hue Angle at a2; Saturation at a2; Brightness at a2
and another Graphic to illustrate the point.
From Track Editor 1.6 - Colour Highlights for clarity Only
If you don't follow this protocol, and say entered the index (186) at a3, then GP2 would interpret it as meaning Range 0-186. I can assure you, this would produce a very strange result indeed!
I know this may be confusing but hey...we didn't right the GP2 Code we're just interpreting it!
OK one more Graphic but this one you won't find in Track Editor 1.6, its just to illustrate the point
(But if you like it, tell Paul!)
Not in Track Editor 1.6 - Just an illustration
Well because life is hard (In computer land), you can't simply insert the values from the example into the 0xc9 and get some nice colour blue. There has to be some calculating first.
Hue Angle
In the Hue Angle-Circle we have a range of 0-360 degrees, but in programming we have the byte, and the byte has a range of 0-255. So using the 240 (in the above example); we have the following math 240/360*256.
Where 240 is our desired Colour, 360 is the degrees of the Hue Angle-Circle and 256 is our maximum permissible value in our 0xc9 box (a4 & a5). We get an answer of 170appx.
Saturation & Brightness
Looking through all the 0xc9 entries in the original dat files, I discovered nothing in excess of 64 at these parameters.
exported with the "export track commands"-function of the track editor:
With some experimenting (Actually a lot), I came to the conclusion that 64 is probably equal to 100%. Apart from this figure being equivalent to eight bytes, I don't know why its 64, but I guess its just to give us a little more maths.
Therefore with Saturation and Brightness settings, we have a possible input range of 0-64. If you go beyond these values you can create unreliable results, with effects such as whiteout or colour substitution. If you stay within these guidelines everything is accurately produced the way you would want.
So if you want 75% Brightness, you have 75*.64=48; 33% is 33*.64 =21 and these values are then entered in the appropriate boxes. (Not too difficult really)
Now the bit we have been getting to. Lets enter some figures in the 0xc9 command editor.
a2; a3; a4; a5; a6; a7; a8; a9;
186; 191; 25; 33; 39; 19; 40; 60;
Here is the result
From Imola94 - down to Acque Minerale
If you haven't already realised, the Index values used here are generally reserved for the track. In other words the Dproad_.jam (Bitmap) that is used for the Tarmac has these Index values 186-193.
In this shot (Kindly produced for me by Addie Walti), the darkest caramel colour seen is that of index (186) and the lightest cream colour is from Index (190). Although six colours were referenced (191) cannot be seen in this shot, but trust me its there!
So how was this done.
Stage 1 - Choose an appropriate colour from the HSB Chart
In this case it's a cream colour, note in particular where the Saturation pointer is on the HA Circle.
Stage 2 - Do some math with the values above;
47/360*256=33 Hue Angle converted for GP2 use
29*.64=19 Saturation converted for GP2 use
94*.64=60 Brightness converted for GP2 use
Stage 3 - Choose a second colour from the HSB Chart
In this case it's a caramel colour, note in particular where the Brightness pointer is on the Bar and also how the HA circle has darkened.
Stage 4 - Do some more math with the values above;
35/360*256=25 Hue Angle converted for GP2 use
61*.64=39 Saturation converted for GP2 use
62*.64=40 Brightness converted for GP2 use
Stage 5 - Insert these values into the appropriate columns in the 0xc9 command-editor.
a2; a3; a4; a5; a6; a7; a8; a9;
186; 191; 25; 33; 39; 19; 40; 60;
and that's it.
If there isn't a Track 0xc9 (186-193), insert one by right clicking on Track Tree (0) and from the Command List Box, find and select the 0xc9 command, that will open the command-editor for 0xc9. Now you can make your entries.
So if we wanted to reverse the effect, to go from cream at (186) and caramel at (191), we cannot simply reverse the Indexes. Gp2 expects the references in numerical order, so 191-186 will not do!
What we have to do is change all the colour specifiers around like this;
a2; a3; a4; a5; a6; a7; a8; a9;
186; 191; 33; 25; 19; 39; 60; 40;
Now look at the result
So far we have discussed the input of a range of values, but as I have already said you can alter a single index too. Check the previous discussion about which arguments are used, it is important.
Lets now edit a single index. Using our previous 0xc9 (186-191) set the values to the ones in the highlights.
From Track Editor 1.6 - Colour Highlights for clarity Only
a2=186; a5=43; a7=50; a9=64
Now run your track again and you should see this effect.
Hue Angle 43 is Yellow
For the ones who are ahead me in the discussion, you may be wondering where the Cream/Caramel Track went. Well because we didn't specify a range of indexes for tarmac, GP2 defaulted to the standard index greys. Therefore the only colour that was specified at index 186 was the only one changed.
What is important is the order in which the 0xc9 commands are read from within the data. To illustrate this lets now insert a second 0xc9 command.
The command editor has been opened on the Single 0xc9(186) entry. The entry that changed a section yellow.
From Track Editor 1.6 - Colour Highlights for clarity Only
I will now open the second track entry to show that it has a range index.
From Track Editor 1.6
The values set are for the normal tarmac 0xc9 range (186-193) to greys, like this
0xc9 186; 193; 215; 215; 5; 3; 27; 35
Close and run your track;
Surprised of course you weren't. What has happened is that GP2 read the last 0xc9 (186-193) command after the yellow was inserted at Index(186) and wrote over it. Because the last command had a range that encompassed the (186) index.
However we could have done this;
0xc9 186; 0; 0; 43; 0; 60; 0; 60
0xc9 187; 193; 215; 215; 5; 3; 27; 35
and the yellow would still be there, try it an see!
So the 0xc9 Command can appear in any track sector but if another pointer with the same index is used, either in a range or individually, then it will be the last entry that will overrule all others.
However, there are great possibilities
open to creativity, that can only be briefly discussed here. The following
examples will begin to illustrate the power of the 0xc9 command. First
a little more on rules as promised. Have a look at the following HSB chart.
The origin marker in this illustration is pointing at Hue Angle 220, and the straight black line intersecting the circles centre splits the circle into two halves. The opposing Hue Angle ( at 180deg) is in an orange band and can be calculated exactly. If you continue anti-clockwise from 220 to 360, you have moved 140deg, and so adding another 40deg will give you the opposing Hue Angle. In this case Hue Angle 40. All other calculations can be performed this way. This becomes important, because 180 deg sets the position at which the range of colours will be used by GP2 when graduating the Colours across the specified Index Range. In other words, if the Hue Angles specified in each Index Range (a2;a3) is less than 180deg, the span of colours will be anti-clockwise from origin. If the Hue Angle difference is 180deg or more, then the span of colours to be used will be clockwise from origin.
OK that's confusing so lets use some more illustrations.
Here we have selected a Hue Angle 327 (which I have called Fashion Pink) as our origin Index (a2) and if we want to use the counter-clockwise colour range from there, then we need to determine that our 2nd index Hue Angle is less than 180degs away. OK, 360-327=33; 180-33=147, therefore our 2nd Index HA, has to be 146 or less. Just so we are sure you've got it, we will use our clockwise colour range from origin. This means we need the 2nd Index Pointer (a3) to have a Hue Angle greater than (or equal to) 147. Let's use 147 and convert the Hue Angle Values.
For Index(a2); 327/360*256=233 Which is the Origin Index
For Index(a3); 147/360*256=105 Which is our End Index
The above chart shows our second Index Hue Angle, and in our Colour Box on the chart, you also see the origin Index colour. These two colours will be used across our range of indices.
The next series of shots were made using a special road bitmap that contains sixteen colours, so you will only be able to follow the discussion and results through these examples.
Using our 0xc9 Command-Editor
From Track Editor 1.6 - Colour Highlights for clarity Only
We enter these value and look at our test-track. You shouldn't be confused about the values in a2 & a3. These indices are the ones that match my prepared road bitmap.
Here's the result
It should be exactly what you expected, because these were our target Hue Angles after all. While having a track of this nature is of no earthly use, you can begin to see the potential of the tool.
A little point about Saturation. Saturation is the degree of impregnation of the colour as determined by its Hue Angle. Specifying the amount of the chosen colour to be used, irrespective of its brightness.
I now want to change the Saturation balance in (a6) this change will begin with Index 214.
And the result
Because we left our end index settings alone , you can clearly see the point about the intensity of colour. The Hot Pink in the previous picture has now become much softer in colour. This is because the target index is set at 64 (100%) for saturation and the Gfx-engine is graduating colours from origin-to-end remember!
Next step, altering the Brightness value.
A point about brightness. In the previous version of the TRACK EDITOR the arguments a8 & a9 are described as intensity. This I believe is inaccurately described because intensity could be confused with Saturation. Brightness deals with the overall lightness of the subject, irrespective of its Saturation (Intensity) of colour. Having determined the subjects Hue Angle and Saturation (Its Colour type), adjusting this setting alters how light or dark the subject will be.
As you can see if you compare the previous two images, saturation altered its colour type and this image altered its brightness without effecting its colour type.
And finally putting both alterations together.
You can still see that the target Vivid Lime colour is still met even though the origin index was changed. What you would have noticed across these last three images, is that the colours in-between were affected in the process, as the Gfx engine graduated the colours.
This is the Bitmap used in the tunnel at Monaco. There are three GP2 Index colours in this, Index 9; 192; 193. To make this tarmac bitmap dark, the latter two indexes are changed with an 0xc9 command. They are changed to;
a2; a3; a4; a5; a6; a7; a8; a9;
192; 192; 0; 0; 0; 0; 19; 19;
193; 193; 0; 0; 0; 0; 21; 21;
You will also find these same commands at Silverstone, and likewise they make the tarmac dark there also. The first point to note is that the Index references used appear at (a2) & (a3), and as we now know from our discussion, that means a range of 192-192 or 193-193. In other words a single index change. I have not found it necessary to do this and it will work simply like this;
a2; a3; a4; a5; a6; a7; a8; a9;
192; 0; 0; 0; 0; 0; 0; 19;
193; 0; 0; 0; 0; 0; 0; 21;
This is because the only value that is being changed is brightness and in the above cases these are equivalent to 30%;33% respectively.
Of course if you want to make use of bitmaps like this, you can choose different shades and colours if preferred. The point to remember is that there are three Index values in the bitmap (Index9 also) and all need equal consideration to produce a satisfactory result.
It is probable that you have at some time ( If not currently) used a different sky bitmap, to create different weather conditions. The problem for most is that they have relied on the use of newly created bitmaps using say Indexed greys to generate that stormy appearance. This is usually the result.
You will notice that while the exterior sky is dull and overcast, the sun is blazing down through a beautiful blue sky in your wing mirrors L .
Ok this is how we do it properly with an 0xc9 command. Make sure you have your original clouda.jam file in place first. Then insert an 0xc9 command and enter the following values;
a2; a3; a4; a5; a6; a7; a8; a9;
124; 134; 144; 142; 6; 6; 40; 29;
That's how to create a stormy sky scene J .
The reason this worked is that I used the quasi-reserved indices for the sky and wing mirrors. The wing mirrors index pointer for the sky colour is (124). The actual index colour used by GP2 to create the mirror effect is Grey (16). Which in the case of the Mirror sky is converted to index (124). This is why when Cockpit designs contain rear wing graphics, with colours other than index (16) they are displayed in GP2 as is! So you change the reference of index 124 to match your sky type (within clouda.jam) you no longer have to drive with overcast skies and wing mirrors depicting a brilliant blue sky J !
So what does all this mean in practice? Well the important message should be that you do not necessarily have to spend hours of work producing special bitmaps. In fact you have potentially far more flexibility with the 0xc9 command, if used correctly. I suppose herein lies the biggest potential problem yet. When you are altering the Palette Index, you should be aware that any index you change the colour of, is changed wherever it occurs. For the most part this shouldn't present too much of a problem, because used sensibly you will just be customising individual tracks to make them look more authentic. Certainly the current detailed work I have seen, seems to be the desired objective. If the trend continues we can expect far more realistic tracks from now on.
This is the message for all GP2 graphic artists. You need to be aware that there is quasi-reserved Index values in use and if you don't want recipients of your work to end up with huge headaches. It would be best that this discussion is born in mind and have all the potential offending pixels removed first.
I would suggest when developing your bitmaps for use within Grand Prix, that you think more about how the colours/textures may be manipulated to even greater effect within GP2, than how they appear outside of that environment.
If you want to check out some of the effects described here, you can get hold of Stormy_Autumn_Imola94 at most Track Web Sites.
I would like to give special thanks to Addie for his patience and effort in producing all the 'In-Game' shots that have been reproduced in this tutorial!
Appendix 1
Version 1.0
A GP2 reference chart showing all the GP2 index colours converted to the HSB scale