The SC2 Engine uses Deferred Rendering, that means instead of rendering an object one time for each light in your map, an object is rendered only once. To get the correct light result for more than 1 light, light information for each pixel are stored in the RGB channels of its texture, thats the base-map - the texture file (how much of a red/green/blue light would this pixel reflect).
With the base-map, we can make out terrain look colorful, but it still would look a bit flat. Bricks have cracks and other details...they are not even. To get more details into a simple texture, the Starcraft 2 Engine uses some kind of Bump Mapping. That means, on top of our base-map we project another texture, that contains information of the height of each pixel. Thats handy, but if we would rotate our map (or adjust time of day values to change the light) the lightning on a bump mapped surface would always bounce in the same direction. To get a nice lightning effect for each aspect, we need information for each axis we move (x,y,z). Thats what Normal Maps are for. Each RGB channel is a height map of our texture, where R=x-axis, G=y-axis, B=z-axis. If we would move in our scenery along the x-axis, the R channel of the normal map tells the engine how to adjust light reflection. Edges will have brighter values and reflect more light whereas cracks would be dark and start reflecting only at an extreme angle or not at all. SC2 Normal maps also have an alpha channel, that works as some kind of default bump map.
Getting started
Prepare your texture file (tiling it, contrast etc.)
Create a standard normal map of your texture (use Crazybump, Gimp-Normalmap or even the Photoshop plugin, whatever you are comfortable with)
Prepare your Gimp if you want to follow this tutorial (install gimp-dds) or have a snickers if you just want to know basics
I'll use these:
Creating the Base Map
Take a tiled texture of your choice (I am not going deeper into tiling textures; some say you don't even need a seemingless one). Almost all Terrain Tiles are 512x512, changing the size of a terrain texture will result in a scaled texture ingame, so stick at this size or go higher.
Open it with Gimp.
Remove the alpha channel, if it exists. (Right Click on the Layer->Remove Alpha Channel)
The RGB channels should be fine; you may adjust brightness values, but if you can clearly see it, they are ok
Now we apply a new Alpha Channel to our texture.
Setting it to 255 (white) will result in nothing but white glimmering space. :) The texture will be drawn but is completely overloaded with light, since it will not let light through and reflect everything. A value of 0 (black) will do a plain texture as your RGB channel reflects nothing and doesn't change at all.
Basics: Red Channel describes where red light will be reflected, so that our texture appears to be red. Same for the other channels.
The Alpha channel determines, how much of light is reflected in general, see it as a sun glass for your texture. The darker a channel (or a pixel/area in this channel) the less light will be reflected there.
If you have a generally very dark texture (reeaaaallly dark) your alpha channel could almost be gray...If you want a texture, that reflects light extremely (slime, organic bleeding stuff), your alpha channel can be gray. However, for most textures you want an alpha channel that is between 1 and 25, that means almost fully transparent.
Alpha Channel Gimp:
Select "Colors"->"Levels", change the channel dropdown box to Alpha. What you see there is a histogram, describing how much pixels are of each color in the grayscale. We want every pixel there in a range from 1 to 40 (try it out what suits you best).
Leave the first slider as it is (Did you touch it? select the whole spectrum from 0 to 255 with 1,00 as the gamma value). You want to adjust the "Output Levels" slider: Drag the right pointer to about 40 or just enter it in the textbox on the right, then hit OK.
This is what the final histogram could look like:
Now the image is gone...in the world of wysiwyg. It's still there, but almost transparent.
Save your file as a *.dds; use BC3 / DXT5 compression and check "Generate mipmaps" (Use these settings for all SC2 DDS files).
Creating the Normal Map
Load your standard normal map into Gimp.
Remove the alpha channel, if it exists. (Right Click on the Layer->Remove Alpha Channel)
This is where the fun starts: We have to set up all channels to fit into the Blizzard Normal map scheme. Remember what we said about how the RGB channels are assigned to the axis? R=x, G=y, B=z. Selecting only the red layer you should see all dimples from top to down; all from left to right with only the green layer selected. And blue? Why does it display both? If we move along the Z axis, all the edges are relevant. But guess what: We dont need them. R and G combined does almost the same.
The Alpha Layer of the blizzard normal map acts as the bump map from above, so we have to combine R and G and copy it to the alpha channel:
Unselect any selection you have ("Select"->"None")
Right Click the Red Channel -> "Channel to Selection"
Right Click the Green Channel -> "Add Channel to Selection"
Right Click on the empty space below -> "Add Channel" -> Opacity 100%, Check "Initialize from Selection"
Unselect any selection you have ("Select"->"None"), depending on your image, these selections really slow down Gimp...
Now we have an additional channel, representing x and y movement reflections. Later more on that
Right now I'm unsure, some people say we need a red-scale normal map, for me a grayscale worked fine.
To convert the image into a grayscale we do the following:
Select the Layer
Right Click on it ->"Colors"->"Components"->"Channel Mixer", check "Monochrome", don't click OK
Now you have to choose from which channel you want to take the colors; Select the Green Value (100%).
You can also check Red and Green and do 50% for both. This setting does not change the color of our map itself, it just changes how the lightning on our texture changes when we move through the map. Since the SC2 point of origin is the bottom left of your map, we move in the x or y so both of them or a combined value is ok.
Now the Normal map is almost complete.
Setting up the old R channel (the one thats still hanging around) as Alpha:
Right Click on the layer -> Add Layer Mask, select "Channel" and choose this channel
Remove the R channel: Channels -> Right Click on it -> "Delete Channel"
Select the Layer -> Right Click on it -> "Apply Layer Mask"
That should be it; Save the file as *.dds just like the base-map
You can find sample screenshots and the generated *.dds files in the attachments.
Tips
Do not test your textures in the Terrain Editor, it has bugs and odd results due to re-uploading etc., test it directly in Starcraft.
Use different light settings to see, how your texture reacts
Don't just fill the ground only with your texture, use other and paint around to see the blending
You can set up a lightning that changes fast: In the Data editor create a new lightning or use an existing one and set "Time Per Game Loop to something like 00:10:00. Don't forget to give this lightning settings for more than 1 Time of Day. :)
Don't worry if you can't see the picture of your texture, the preview in the galaxy editor doesn't deal properly with the alpha channels, too.
Don't eat yellow snow
Q&A
My texture shines almost pure white at different angles: Lower the base-map alpha
My texture is still too dark/bright: Adjust the brightness/contrast of the alpha channel of the normal map
My texture does not show up in the Terrain editor although i put it in the data editor: Close the Terrain Editor. Open the Terrain Editor ;)
My texture does not blend at all/Terrain Editor Crashes when I try to paint it: Check the *.dds Format settings when you saved your file. Check if they all have an alpha channel. Don't forget to re-import them.
Feel free to comment, add additional infos or report my errors.
Right now I'm too tired, but I still want to figure out, how the minimap color works and there is still some formatting / additional screenshots to do.
You get really vauge at the end, using "this channel" right click "this" I couldn't follow the end and I really needed to learn how to do this.... bummer
In this tutorial, I am going to show you how to create a Starcraft 2 texture for a custom tileset.
Prerequisites
Theoretical stuff
The SC2 Engine uses Deferred Rendering, that means instead of rendering an object one time for each light in your map, an object is rendered only once. To get the correct light result for more than 1 light, light information for each pixel are stored in the RGB channels of its texture, thats the base-map - the texture file (how much of a red/green/blue light would this pixel reflect).
With the base-map, we can make out terrain look colorful, but it still would look a bit flat. Bricks have cracks and other details...they are not even. To get more details into a simple texture, the Starcraft 2 Engine uses some kind of Bump Mapping. That means, on top of our base-map we project another texture, that contains information of the height of each pixel. Thats handy, but if we would rotate our map (or adjust time of day values to change the light) the lightning on a bump mapped surface would always bounce in the same direction. To get a nice lightning effect for each aspect, we need information for each axis we move (x,y,z). Thats what Normal Maps are for. Each RGB channel is a height map of our texture, where R=x-axis, G=y-axis, B=z-axis. If we would move in our scenery along the x-axis, the R channel of the normal map tells the engine how to adjust light reflection. Edges will have brighter values and reflect more light whereas cracks would be dark and start reflecting only at an extreme angle or not at all. SC2 Normal maps also have an alpha channel, that works as some kind of default bump map.
Getting started
Creating the Base Map
Creating the Normal Map
Importing / Data
Tips
Q&A
Thank You
Comments
Feel free to comment, add additional infos or report my errors. Right now I'm too tired, but I still want to figure out, how the minimap color works and there is still some formatting / additional screenshots to do.
Finally some good tutorial for texturing Normals! Thanks!
You get really vauge at the end, using "this channel" right click "this" I couldn't follow the end and I really needed to learn how to do this.... bummer
If you had trouble following this then there's the galaxywiki tutorial http://www.galaxywiki.net/Custom_Terrain_Textures which has been around for a while. It should be fairly readable.
@JackRCDF: Go
Thank you so much!