• Welcome to SC4 Devotion Forum Archives.

Calibrating Photoshop for gmax by gascooker

Started by BarbyW, July 13, 2008, 02:39:08 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

BarbyW

The aim of this document is to explain the process of colour correction from photoshop to SC4. It will show you one of the many procedures that can be applied to fix this problem and give more predictable rendering outputs.

Requirements and notes about this article

You will need a copy of photoshop 4.0 or greater and preferably two non-colour-blind eyeballs, attached to a small to medium-sized brain. The details shown in this article are specific to photoshop CS, however, as little has changed in the numerous upgrades to this version, (with the exception of the useless "leopard-skin brush" and the "automatic wedding invitation template button"), most of the info should apply to earlier versions.

I am going to explain the calibration process in detail so you can see some of the more powerful aspects of photoshop and use them in other situations. Some words and concepts have specific meanings in photoshop and will be accordingly defined. Don't be scared of this, you already speak "gmax".

The wonderful world of colour

We all know the problem. You make a texture in photoshop, render it to SC4 and it doesn't look like your original texture. The reason for this is that photoshop and gmax are effectively working in different colour spaces.

For the purpose of this exercise, colour space is a term used to show how colour, is described or modelled. The easiest colour model to understand is CMYK. (C)Cyan, (M)Magenta, (Y)Yellow and (K)Black and is used to describe the colour of light-reflecting objects such as squirrels, chairs or paintings, and is widely used in printing. It's like mixing paint in a primary school art class: mix 50% Cyan to 50% yellow and you get green.

RGB is the most difficult colour model to understand and is used in light-emitting devices such as monitors, gmax and in the dubious lighting effects of 1970s discotheques. Colour is defined as having (R)red, (G)green and (B)Blue components or channels. Its like having three coloured spot-lights shining onto a surface. If you shine all three at once you will get white, turn them all off and you will black. Shine only the red and green lights and you will get yellow.

A channel in photoshop is used to describe each of the colour components that make a colour space. ie: the red channel is said to be a component of the RGB colour model.



Under no circumstances ever use the CMYK colour space in making your textures - they are intended to be seen on RGB monitors playing RGB SC4. Ever wondered why your RGB digital photos come out the wrong colour when you print them to your CMYK inkjet printer?

Calibrating your eyeballs

Before you even think of doing anything related to this article, you need to make sure your photoshop is calibrated and set up correctly. You should only ever have to do these things once in your life:

1. Ideally you should have run the Adobe gamma set- up program which starts up when you first install photoshop, so both your eyeballs and the lighting conditions of the room you are working in are taken into account. (See Adobe's help files on this issue)

2. Make sure image interpolation is set correctly in the photoshop preferences (CTRL-K) to bicubic(Better). Sometimes low-level re-sampling can adjust colours.



3. Obviously, make sure any textures or new documents you are working on are in RGB format!



Finding the gmax colour shift

Create a new photoshop document:



We are going to create a "control" texture which consists of 5 RGB "grey" or neutral strips. The colour of each strip is very important and must be entered numerically in the colour pallette or colour picker. Use the marque tool to draw the rectangles, set the colour you need, then hit good-old SHIFT-F5 (or choose FILL from the edit menu) to fill the selected areas to end up with the texture below.

You should note that the "lighter" the colour, the higher the RGB values; 0 0 0 is black, 255 255 255 is white.

Also note that Photoshop describes tones, that is, how light or dark a colour is, in terms of shadows, midtones and highlites. These terms are used throughout the program in various adjustment functions.

Neutral is a specific photoshop term used to desribe a colour whose individual components are set at equal or nearly equal values and does not neccessarily mean grey.



Save the texture as a JPEG with the following settings. It is important that quality is set to maximum as no colour distortion will occur at JPEG setting 12.



Now import the texture into gmax, make a large cube and apply the texture with a UVW map. Using the gmax preview function, render a view of the cube at HIGH quality to the screen. (South is my personal favourite).Take a screenshot.

Go back into photoshop and paste the screenshot into a new document. (you may want to use a coloured neutral background so you can easily see the colours). Delete all of surrounding screenshot mess as we are only interested in the side face of the model. Drag your texture file into this document as well.

Make a rough selection of the model's side face to include all of the strip texture including the black bit. Copy it to a new layer (CTRL-J), scale it up (CTRL-T) and place it near your original photoshop texture, so you end up with the following:



Oh dear. What a disaster. You can now see the colour shift. (if not please consult your nearest optician). Contrary to popular belief, the gmax colours are not just "lighter": t hey have been mapped to a different colour space.

I can tell you from experience, using only my highly skilled eyeballs, that there is roughly a 10% shift towards yellow, an increase in luminosity (lightness) and a general saturation (colours moving further apart in the midtones).This offset effect increases towards the highlights and midtones, but effects the shadows less. You should in the very least notice it is lighter and more yellow.

You now have two options: You can note this in your head and remember to make your textures, darker, less yellow and more desaturated. Point proven, end of story.

Or you can take this issue further and get the problem fixed once and for all.

Fixing the gmax colour shift

You will now need a pen and some paper because we are going to take some accurate colour readings with the most under-rated photoshop tool of all: The Eyedropper and his faithful friend The Info Pallette. We are going to fix the colour shift so that textures apearing on the front face view of a SC4 model will match their photoshop originals. The shaded and roof parts will dealt with in another document.



Now, we already know what the RGB colour values of our original texture are, as we chose them. All we need to do now is use the eyedropper to read the values of the gmax texture.
Record all of the five RGB values on paper, by holding the eyedropper over each colour. The RGB value will appear in the info pallete as shown above. The following tables show how the colours have changed in my gmax:



As you can see from the numbers, if gmax was rendering the textures only "lighter", then they would have all increased proportionally by the same amount. They do not. The darker colours have altered by less. Look at the black - it's unchanged. The midtones have altered most, and the white only slightly. And on top of this, the red and green components have increased in value and the blue component has decreased! "Oh my God, how ever I am gonna fix that, the values are all over the place!" I hear you cry.....

Welcome to Photoshop Curves

Fortunately, this is all a piece of cake for photoshop. What we are going to do now is create a mapping curve so photoshop "knows" what gmax is doing to its colours. The principle behind this is that we are going to work in reverse, ie; apply a set of changes to the gmax texture to get it back to the photoshop texture. We will then be the proud owners of a set of offset values. We can then apply these to all of our textures, let gmax ruin them by the offset value and end up with what we wanted, because photoshop pre-empted it.

There are, as usual with photoshop, hundreds of ways to do this. All of the colour / mapping functions are found in the IMAGE > ADJUSTMENTS sub menu. They virtually all do the same thing in different ways. Curves are most appropriate for our current situation.

In your photoshop sketchpad document containing the gmax and photoshop textures next to each other, use the rectangular marquee tool to roughly select all of the gmax texture image you scaled up. Then, open a new curves window. (CTRL-M). This is what a curves window looks like:



We are now going to add in our values from the colour readings we took to the input and output boxes to create a curve.



1. Firstly we are going to adjust all of the red components of the RGB colour space. Select this from the pull-down menu. Make sure that "RGB" is not selected (the default) or you will be working on all channels similtaneously!

Using the colour readings table we created we are going to map the red components: 0 to 0, 68 to 64, 138 to 128, 209 to 192 and 255 to 255

The first colour in our strip (black), requires no adjustment. (0 to 0)

2. The second colour (dark grey) does. Add a point to the curve by clicking on it roughly on the dotted grid point.

3. In the input box, type in the value of the gmax red component for this strip: 68. In the output box type in the colour it is supposed to be: 64.

Translated into English, we are saying to photoshop "the gmax red colour component of value 68 should be 64"



Now onto the next strip: the mid grey...


4. Still working in the red channel, add another point on the curve for the medium grey strip colour.

5.In the input box, enter the gmax colour reading 138 and in the output box enter the value it was supposed to be before gmax ruined it: 128.

6. Repeat this until all the red components have been mapped and you will end up with a red component or channel curve like shown.

Translated into English, we are saying to photoshop "the gmax red colour component of value 68 should be 64, the gmax red colour component of value 138 should be 128, and the gmax red colour component of value of 209 should be 192"



Now we need to move onto the green channel.

1.Select the green channel from the pull-down menu.

Using the colour readings table we created we are going to map the green components: 0 to 0, 67 to 64, 134 to 128, 201 to 192 and 255 to 255

The first colour in our strip (black), requires no adjustment. (0 to 0)

2. The second colour (dark grey) does. Add a point to the curve by clicking on it roughly on the dotted grid point.

3. In the input box, type in the value of the gmax green component for this strip: 67. In the output box type in the colour it is supposed to be: 64.

Translated into English, we are saying to photoshop "the gmax green colour component of value 67 should be 64"

Repeat steps 2 and 3 until all the colours of each strip have been mapped to create the green channel curve.



Now you should be getting the hang of this. It may seem tedious but once we have finished you will never have to do this again.

1.Select the blue channel from the pull-down menu.

Using the colour readings table we created map the blue components: 0 to 0, 62 to 64, 123 to 128, 188 to 192 and 249 to 255


When you are finished save the curves as a .acv file somewhere convient on your computer.

If you did all of this while your gmax texture enlargement was selected you should have witnessed the colours returning to very near their original intention. Take colour readings with the eyedropper to prove this.

You are now the proud owner of a very important .acv file!

Testing and using your .acv file

Now that you have created your special gmax colour shift file it can be re-called and applied to all textures that you wish to display correctly on your SC4 models. To test this, open your original strip texture file used in gmax.

Open a new curves window (CTRL-M). Press the load button and locate your .acv file to import your curves.
Hit OK to apply the colour shift. You should notice that photoshop moves your colours by the offset values to pre-empt gmax. They will move towards blue (opposite of yellow) and get darker.

Save your strip texture as a JPEG - maximum quality or setting 12.

Now re-import the texture into gmax, and render your model to screen.Take a screenshot.

Go back into photoshop and paste the screenshot into your photoshop sketchpad document and extract a slice of the model image to compare to your previous textures:



If you take colour readings, then you should have a near-perfect match. Some of the values will be one or two increments out. This is likely to be because when taking the screenshots the colours are transplanted to another RGB colour space (Windows) before being pasted into photoshop's RGB colour space (Adobe RGB or sRGB). For the purposes of SC4 this really is irrelevant.

More importantly you will notice that the white strip does not match. Gmax will always offset pure white (255 255 255) to this colour cast as in the game white (255 255 255) is used as an alpha channel, and is reserved to display the LODs, i think.

You will also notice that the top of the model has a different colour cast. This is because of the lighting effects used in rendering. You may want to create a special .acv file for roof items, but be careful not to offset the textures so much that any 3D form is lost. I find that for pitched roofs the .acv file used for the side also works.

You can use your .acv file in a number of ways and even integrate it permanently into photoshop. If you use templates to create textures, you may find applying an adjustment layer will rid you of the need to ever load your .acv again. If you use photoshop Actions to output textures directly to your gmax material libraries, then the .acv can be incorporated into these scripts.

I use my .acv file as a general colour correction tool. However, it should be noted that this does not exempt you from making sensible design decisions when srutinizing your textures. There are a few other tricks which you can use to get your BATs matching the SC4 pallette which I will need to explain in another, hopefully shorter and less technical, document.

Posted by BarbyW for gascooker
Inside every old person is a young person wondering what happened. TP



Barbypedia: More alive than the original

cogeo

#1
Thanks Barby for posting this great tutorial on SC4D!

I have used it in my BATs and I have to admit that I totally agree. If your texture looks "different" ingame (red components intensified, blue suppressed), this is the way to fix it!

I would also like to add my €0.02:
Gmax/BAT affects textures in another way too, it increases luminosity. Also BATters should also take into account that amost all Maxis models are quite "dull" (having colours/textures with a low degree of saturation), that is try to imagine how your BAT will look amongst those low-saturation buildings. Most probably it will be more saturated than the others, with the players complaining about textures being "too bright". Therefore, am additional step is needed, to counterbalance these effects.

So in total:
- Add a colour adjustment layer, reducing luminosity by 10-25% (unless the texture is quite dark already).
- Add another layer (or modify the settings of the layer above, if your image editing program allows it), reducing saturation too (you have to tell if this is needed, and the amount of reduction).
- Add a Curves adjustment layer, as described in gascooker's tutorial - this should preferably be on top of the other layer(s).
- Save your texture as a .psd (or .psp) file (not as a merged image) and save a copy of (or "export") the merged image for your BAT. This way you can change the parameters if the result is not satisfactory. Never work on the merged (modified) image.
- Use this "merged" or "exported" image in your BAT, no matter how bad it may look at first glance - it will look much better ingame!

I would strongly recommend BATters to use the above quidelines, and I would also like to add that:
- The procedure is not as tiresome as it firstly looks! Yes, adjusting the colour curves is tedious, but this step actually has to be performed only once. Then you can copy and paste the Curves layer to the other textures too.
- The same procedure applies to PaintShop Pro as well.

All the Best!

SimFox

#2
I have somewhat mixed feelings about this article/tutorial.

I absolutely applaud the theoretical portion of it as it provides essential knowledge that no one even remotely linked to the world of 3d graphics, or any graphics for that matter, should be without, but the practical application of that knowledge is a bit more questionable.

Since the theoretical part gets my thumbs up as is I'll share my thoughts on application. IMHO the proposed fix isn't quite what it seems to be... I would even go as far as say that it is not so much a solution, but rather new problem.

The core of the issue is that the articles theoretical part doesn't cover entire "life cycle" of the bitmap texture in 3d application. Instead approach is strictly 2d. It omits hugely important part of 3D workflow - lights. As a result the shift occurring during the rendering process is presented as sort of accident, mishap, flaw in the program and, naturally, as something that has to be fixed. This is where it all falls apart. Because that sort of view distorts the reality.

Of course, what is reality, isn't it all just a perception?.. Well, perception is a right word here as well.

The "Shift" occurs as a result of interaction of bitmaps with lights.  What this tutorial suggests is, in effect, just making those lights color neutral. Or at least the "Sun" lights. Making them white instead of warm orange-peachy. But big question is WHY?.. All the models have been produced with same of very similar lighting (at least if we talk of hue component of it). Colors, as we see them, aren't environment neutral. What is white in one would look blue in another, and vice versa. "Fixing" color cast independently, out of the environment, will only ruin consistency. Effectively you'll have building light by daylight florescent lights in the warm glow of late afternoon (the game day). And even if such a fix is desired it would be much more efficient to do it from the Lights - once and for all, instead of tinkering with each and every texture.

Lighting in GMAX BAT (or default Bat4Max) setup has many problems but color cast isn't really one of those. As I have mentioned above it is very instrumental as it provides integration of new model into it's environment. I would understand if some people will be a bit perplexed by hearing me say things like that.. Given my push for new and non-orthodox (in BATing world) approaches in custom content generation. So, I think, I should clarify my position. Before I do that I want to stress that this is my personal view of the situation, so every and anyone are free to express their attitudes, suggest alternative points of view and some such , preferably argumented ones, of course...  So, back to the color shift.  "Fixing" it will deny biggest benefit of existing lightning setup, without addressing real problems like shadow definitions and for instance. And as such a very questionable move. You lose something of real value without gaining anything of meaning. Another point is that there are far more obvious issues are evident in respect of colors when we look at a lot of BATs. Those mentioned by Codeo - saturation and luminosity of bitmaps or plain colors are particular scourge of the BATing.

Of course, I understand, that people are writing about topics they are personally interested about. So my rambling here are sort of "suggestions for further research"...

All in all, I would hope to see much more of such meaningful discussions.


callagrafx

This tutorial was written for use with Photoshop and BAT (GMAX) and was designed for less advanced users to "neutralise" their grays.  The theory behind it is well thought out and in graphic design circles, this type of colour correction is fundamental.  It makes sense to "correct" the bitmap to match the desired effect, as if you alter the lighting, you affect everything in the scene...If I want a particular part of a building to be less saturated or have a more cyan cast, I'd change the bitmap, not the lighting.  Remember the lighting rig was designed to mimic the game's lighting.

Jason: 
The trouble with having an open mind, of course, is that people will insist on coming along and trying to put things in it

sam

Thanks for posting this tutorial Barby. I'm starting to try to use it on some of my textures.

I have a question though. I'm using paintshop pro 7 but I can't find how to add an adjustment layer to adjust the luminosity as Cogeo describes. Is it called something else in psp 7?

callagrafx

There's a good chance that adjustment layers are unique to Photoshop (not used PSP for eons).
The trouble with having an open mind, of course, is that people will insist on coming along and trying to put things in it

sam

PSP 7 has (some) adjustment layers, probably just not one for luminosity. The only feature relating to luminosity anywhere is a check box to preserve luminosity on the colour balance adjustment layer. I had to use an adjustment layer for the callibration, as there is no save option on the normal curves adjustment in psp 7. (So I did it as an adjustment layer over the test strip, and saved it, so now I just have to copy that layer to any texture image I want to use). It seems to work reasonably well so far. But I think psp 7 is considered ancient technology now. I looked at XI but it didn't put my favourite tools in easy to reach places.

cogeo

#8
Sam, all needed features are available in PSP 7 as well. There are (at least) two adjustment layer types that can adjust luminosity: the Brightness/Contrast and the Hue/Saturation/Lightness ones. The latter can adjust both luminosity and saturation (keep the Hue setting to 0).

I have attached an example of a texture adjusted as described above. It contains the base texture (replace it with yours - sorry max file size is only 300K), a Hue/Saturation/Lightness and a Curves adjustment layer on top of them. In addition there are two layers that imitate the light effects for walls (Dodge and Burn). They use a simple Black-White gradient, and masks that limit the effects to the top and bottom repsectively (otherwise the effect would be more mixed and less apparent to the viewer). You can try deleting the masks (do not merge the mask to the image upon deletion) to see what I mean. As said above, these were produced using a Black-White gradient, but you can experiment with more advanced gradients if you wish. The masks where produced by the image's luminance (make all others layers invisible, switch to the layer in question, and temporarily set mode to normal and opacity to 100%, and then select Mask->New->From Image), so you can easily create yours.

The values for Luminosity, Saturation, Dodge and Burn may not be optimal, you may need to experiment to get the best possible results. Different textures may need different values. Plop your BAT next to other BATs (mostly Maxis), and it will be easy to tell what you need to change.

Hope this helps.

EDIT:
PhotoShop Users: I have been informed that the PSD file in the attachment didn't work (actually I had saved it from within PaintShop Pro). So if you had downloaded it, please DO NOT use it! The attachment now contains only a PSP file (for PaintShop Pro 7 or later) and this does work!

sam