Ground texture, normal maps and aplha channel

BuilderBob

New member
I am trying to tweak some ground textures, and I am having a lot of trouble understanding the concepts involved with the alpha channel of the normal map. This is the description from the manual:

"The alpha channel provides per-pixel control of the specular highlight. White gives a strong specular, suitable for metals and water. Black gives no specular, more suitable for dark earth. Grays are a mid-strength specular."
http://online.ts2009.com/mediaWiki/index.php5/KIND_Groundtexture

That just doesn't make sense to me.

Is it the apha channel of the normal map that controls the specular highlight, or is it the color of the map?

The statement seems fairly clear that it is the alpha channel, but I do not understand how the alpha channel can be 'black', 'white' or 'gray'. The apha channel is a number - 0 to 255. The normal map color is in the other three channels. The colors used as an example imply that the map should be shades of grey - equal values in the three color channels - but the sample image is shades of purple!

If it is the alpha channel that is used, and the color of the map is not relevant, then what values correspond to 'black', 'white' or 'gray'?
 
I'm somewhat of a novice at normal maps too, but as I understand it, the RGB components of a normal map tell the graphics card what direction each pixel is tilted at for the purposes of rendering apparent bumps and dips in the surface. The graphics card sees the RGB values as the X, Y and Z components respectively of a vector (the "normal" vector) which is perpendicular to the plane of the pixel. So for example if the normal vector is calculated from its RGB values to be projecting out of the plane and tilting to the 'north east', then it's pixel will be treated as if it is on the side of a bump facing north east. If that makes no sense, just accept that the RGB colours of the normal map code for bumps or cavities, not colours on your texture.

The alpha channel in a normal map, as far as I know, can only be a gray scale value. It's sole purpose is to code how much of a specular highlight, that is, a level of brightness, is associated with each pixel when the light is shining on it. It helps to accentuate the bumps and cavities coded in the RGB part of the normal map.

As to why the RGB part of a normal map looks purple and pink to us, I don't know. Those colours have no influence on the colours you see in the texture, they are determined only by your "diffuse" image. The normal map is readable only by the graphics engine and is used to add effects like dynamic highlights and shadows to the texture in the game to give the impression of bumps/cavities when there are none actually there in the mesh.
 
Last edited:
Thanks for the reference, but that description only explains what a grey-scale image is. That isn't the problem. I'm trying to determine how to create the normal to generate the specular effect I require, and the description of how to create the normal just doesn't seem to make sense. I can't even tell whether the normal color is part of the process, let alone whether it needs to be a grey-scale image or not - the description implies that it is, but the examples aren't.
 
The only bit there that touches on the problem is the statement " Most images do not need Specular so you set the Alpha Channel to pure black." which certainly indicates that it is the alpha chanel, not the color, that matters. But I still have no idea what 'pure black' means for an alpha channel. Alpha normally controls transparency, so referring to it as a color seems meaningless. Does 'pure black' mean fully transparent (viewed on a black background) or no transparency (image is black and opaque)? The samples don't appear to have any transparency!
 
Thanks for that. I understand what a normal map is, but it's not clear that the normal map is used like that for ground textures. There is no mention of this functionality of the normal map in the description of the normal texture image under the GroundTexture entry. But perhaps it is. That's not the problem.

Perhaps the sample images have no normal information in order to demonstrate the alpha channel information, and the color is arbitrary.

The description of the alpha channel in the normal map is "The alpha channel of the normal map is typically used to provide per-pixel control of the specular highlight. White gives a strong specular,...". What does the term 'white' mean for an alpha channel? I need to specify the alpha channel value of a pixel in a TGA image as a number between 0 and 255, and when we are talking about transparency I have no idea what 'white' or 'black' means.
 
0= pure black
255=pure white

1 > 244 geys progressing from very dark to very light

EDIT: Oops- typo: should be 1 > 254, thanx Deane!
 
Last edited:
OK. So I'll take the description to actually read:
"The alpha channel provides per-pixel control of the specular highlight. Transparent gives a strong specular, suitable for metals and water. Opaque gives no specular,...'

Is there some source you know of that provides this sort of translation?

For instance, I also need to figure this one:
"Tile=stTiling refers to the ability for texture coordinates outside the range of (0.0 .. 1.0) to be treated as valid coordinates on an infinitely tiled texture. With tiling active, coordinates which pass the right side of the texture effectively wrap back onto the left side, and so on. Valid options include 's', 't', 'st', and 'none'."
http://online.ts2009.com/mediaWiki/index.php5/Texture_file

I can guess that 'none' means no tiling - the image is stretched to the paint area. But what does 's', 't', or 'st' mean?
 
SailorDan

You are getting confused between what the alpha channel does in a visible texture image and what it does in a normal map. They are very different effects.

The grayscale alpha in a visible texture image controls the opacity/transparency. Pure black parts of the alpha will make the corresponding parts of the visible image purely transparent. Grays will make them partially transparent and pure white will make them perfectly opaque.

The grayscale alpha in a normal map has nothing to do with transparency. It only controls the amount of specular highlighting. Black parts of the alpha will have no specular highlights, grays will be muted highlights and pure white areas will give very strong/bright highlights.

A transparency alpha will generally look quite different from a specular alpha. Imagine you are modelling a wire screen door. The alpha in the visible image will have black around the frame of the door and in the holes between the wires to render those parts invisible, while the frame and wires will be white areas in the alpha because they must be visible. The specular alpha in the normal map might only have white for the door knob to give it a bit of a highlight, the rest of the alpha being black.

As for tiling, Windwalkr once told us what the letters 's' and 't' stand for in a forum thread, but I forget. However I do recall that 's' means horizontal tiling, 't' is vertical tiling, and 'st' of course means tiling in both directions. Something like that.

~ Dean
 
Last edited:
I am not confused about the use of the alpha channel in a normal. What has confused me is the use of a term such as 'black' or 'white' in reference to the alpha channel value. These terms are quite meaningless in respect of the alpha channel, whether the alpha channel is used to indicate opacity/transparency in a visible texture image, or it is used to denote the amount of spectral highlighting in a normal map. Whatever function it performs, 'white' and 'black' mean absolutely nothing in that context, and I have found it very confusing that those terms should be used in the description of the normal map to describe the amount of spectral highlighting, with no indication of the corresponding alpha channel values.

Your comments such as ""Black parts of the alpha..." and "The alpha in the visible image will have black around the frame of the door..." depend on a particular assumption about how an image happens to be displayed. Alpha is not black, white or 'grayscale' and the reference to it as such is the reason for the confusion.

Thank you for explanation of the use of 's', 't' and 'st'. I would be grateful for any information about a source for this critical information that simply doesn't seem to be anywhere in the manual. I will assume that 's' comes from 'horiZontal' and 't' from 'verTical'. It's a pity that 'black' as zero and 'white' as 255 does not have a similar obvious connection.
 
Perhaps the source of some of the confusion is that although an alpha channel can contain all greyscale values, for most Trainz applications the alpha needs to composed of only two values, 0 (pure black) and 255 (pure white). Greys in the alpha tend to cause sorting and transparency issues. The situation is not quite as ' black and white' as that (woeful pun) but that may explain part of the terminology issue. Transparency issues in trees for example can be 'fixed' by editing all grey pixels out of the alpha. Even a single pixel with a value 1 > 244 will cause issues...
 
With respect, that is just adding to the confusion.

You have not made it clear whether these intermediate values for the alpha channel cause problems when they are used in the image (indicating an intermediate level of transparency) or they are in the normal (indicating an intermediate level of spectral highlighting). If there are issues with intermediate values, I would expect those issues to be different between the two usages.

But a statement such as '0 (pure black) and 255 (pure white)' in respect of the alpha channel is meaningless. There is no concept of color that applies to the alpha channel, so it makes no sense to call one value black and another value white. I am beginning to see that this is a common usage within Trainz, but it's certainly not helpful when this type of argot is included in a manual without any explanation.

Also, I would very much appreciate any available input for this thread, which is a similar topic:
http://forums.auran.com/trainz/showthread.php?85424-Texture-Shadowing-Problem
 
I do not understand how the alpha channel can be 'black', 'white' or 'gray'. The apha channel is a number - 0 to 255.

Modern ground textures are a combination of...

Diffuse Map - e.g. a picture of some grass

and

Normal Map - in other words bump map, which provides the illusion of relief or in other words, bumps.

The alpha channel is an extra image layer in a 32 bit .tga file. It is not simply a single numeric value, it is a black and white image. For normal scenery objects, the alpha channel in the diffuse map is used for controlling opacity, and should contain only black or white information, white for opaque areas, black for transparent areas, no shades of grey.

Where ground textures are concerned, the alpha channel in the diffuse map isn't used for opacity, it's used for controlling reflection and may use various shades of grey for different details.

In the normal or 'bump' map, the alpha channel is used for controlling specular highlights and may also use various shades of grey, ranging black to white. For example's sake, let's say you have a ground texture resembling pieces of metal on some dirt. In the specular map you'd want the areas of dirt to be dark, since dirt isn't shiny, and the pieces of metal to be light, since metal is shiny. The shininess is being controlled per pixel by the image in the alpha channel.

HTH,

~R~
 
Last edited:
I still maintain it is nonsense to refer to the alpha channel as an image or as 'black', 'white', or 'shades of grey'. Nowhere does the information contained in the alpha channel correspond to a color. It corresponds to a degree of transparency, a degree of reflectivity, or a degree of specular highlighting. None of those things is a color, and it only creates confusion to refer to the values in the alpha channel as a 'black' or 'white'.

The only time that the alpha channel can be characterised as a color is if it is separated from the rest of the image and converted into a displayable format using some arbitrary conversion rule to apply a color to each value. For some reason, published examples of this conversion seem to use shades of purple rather than shades of grey, so even in this context terms like 'black' and 'white' would be meaningless.

Your attempt to equate black with dull and white with shiny amply demonstrates the irrelevance of using a color to indicate these values.

I take it from your explanation that the reference in the previous post to issues related to attempting to use values other than 0 and 255 for the alpha channel applied to transparency in a [normal] non-ground texture image. In that case it's not relevant to ground textures, and I assume that any value for the alpha channel in a ground texture (reflectivity or specular highlighting) is valid.

<Edit>I am beginning to see where this incorrect use of color terms for the alpha channel comes from. It seems that some modeling programs can create the alpha channel for a texture from a separate image. This image can be created from any source, but 'special effects' routines in a graphics editor are a common source. Usually, such an image retains the color of the original (such as 'pixellation', or 'watercolor') but some effects create a monochrome image, and sometimes shades of purple are used. These are the sorts of images sometimes used to control specular highlighting.

When an image is used as the definition of the specular highlighting, it is converted from an image (eg, 24 bit RGB) to an 8 bit alpha channel . The conversion process is unique to each modelling application, but it could use a brightness calculation, so the actual color of the source image is irrelevant. So if the image was shades of grey, then the color of the image corresponds to brightness, and that corresponds to the calculated specular highlight. So there is a correlation between a color and the alpha channel value.

That's only one way of creating an image with the required alpha channel, and it is not used with ground textures which are not modelled. For ground textures the alpha channel should be created by hand as a separate 8-bit channel. If a graphical editor is used, this might involve coloring pixels as shades of grey. But there are many other ways of doing it, including algorithmic processes.

If someone followed the process from start to end and if that process involved creating a monochrome image as the source of the specular highlights then they would equate a color from their original image with a specular effect in the final image. But that simply reflects the process used to create the image. The actual color in the original image could have been anything at all, or there may not have been an original image if the alpha channel was calculated by hand or with code. That's why it is incorrect to label specualr highlights as 'black' or 'white' or any other color. But it is possible to see why some people make that connection.</Edit>
 
Last edited:
Here's an example of an image that I used in the alpha channel for specular highlighting of a normal map. Yes, the value for any individual pixel in this image could be described as a number from 0 - 255 (not 244 Dermmy!). But surely you can see why most people describe the alpha channel, as a whole, as an image not a number. And it does have white, black and everything in between. How else would you describe it?

controlbox02specularalp.jpg
 
the value for any individual pixel in this image could be described as a number from 0 - 255 (not 244 Dermmy!)

LOL - I got it right the line above! It's an 8-bit channel, ergo each pixel is limited to one of 256 possible 'outcomes'. Since the 'outcomes' are greyscale varying from very very dark to very very light, most of us would call it from black to white. Can't really see what the fuss is about...

Andy :)
 
Just occurs to me part of what might be causing the confusion is that in some ground textures (mine included) a normal is also referenced as the alpha. A normal is purplish but afaik when it is also used as the alpha for that purpose it is viewed (maybe treated would be better?) as an 8 bit greyscale. I might be wrong on that, but that has always been my assumption. Anyway for ground textures defining the normal as the alpha works and saves creating yet another image...

Andy
 
Last edited:
I've never done one of the normal-map ground textures, but when you say the 'normal is referenced as the alpha' I presume you mean these lines in the accompanying .txt file

Primary=groundtexture_normal.tga
Alpha=groundtexture_normal.tga

That surely doesn't mean you are literally using the purple (RGB) part of the normal image for the alpha channel. It's saying there's an alpha channel in the image file groundtexture_normal.tga. If there isn't one explicitly, then (I think I read this somewhere) Trainz assumes by default that it's a pure white alpha. Whatever the case, I doubt that you are using the purple/pink RGB image as an alpha. Do correct me if I'm wrong on that.
 
Back
Top