With the recent additions to the (imho) wonderful q3map2 by Ydnar it is now possible to do texture blending that was previously very difficult or just damn impossible in Quake 3. Ydnar really must be congratulated on extending the Quake 3 engines capabilities. The methods explained in this tutorials assume you have the latest version of Q3map2. If you don't the technique will not work, so head over to ShaderLab to download the latest build.
So what exactly is the fuss all about? Perhaps this is best illustrated by a couple of screenshots (as with all screenshots in the tutorials click on the image for a larger version).
The first image shows a 'rough' edge blend between grass and dirt textures. The second shows a smooth blend. The reason this is so exciting is that you can control the blending, literally specifying exactly where you wish it to be; if you have worked with the old method of terrain texture blending then the benefits of the new system should be obvious. Note: These blending techniques need not be limited to terrain, there are plenty of other possible uses.
Now we get to the clever bit, again best illustrated by an example. Here is a GTK editor shot that shows how the above was achieved. You can make out the grass and dirt textures in the picture but what about the red and yellow textures?
These are the key in getting this technique to work, wether you choose the smooth or rough edge blend the method is identical. It is all down to the shaders used. Yep I know, shaders can leave your head spinning but in this case it is really very simple.
There red and yellow textures are editor images I made for reference purposes when mapping in Radiant only. They do not show in game at all. The red texture is the alphmod volume shader used to instruct the compiler as to where blending is to occur, and the yellow texture is my blend shader that will be affected by the alphmod volume compiler instruction. If you were to have several different blend shaders in one map you would most likely make an editor image for each so that you can easily differentiate between them.
To get this to work texture a brush face with your blend shader then enclose some of the vertexes (the corner points of the face) with the alphmod volume shader. The blend shader has two image stages, in this case dirt and grass. My shader blends the grass texture over the top of the dirt texture, starting at the vertexes enclosed by the alphmod volume shader and, in the case of the smooth blend, gradually fading out towards the opposite side of the face, allowing the dirt to show through. I hope that's clearer than mud ;) Now lets look at the shaders themselves.
Note: The q3map_alphamod (marked in red) functions are what makes this shader work, q3map_alphamod scale {number} represents the amount of blending to perform - see the shader manual for more information. The actual editor image can be anything you wish.
Below is the shader used to achieve the smooth blend. Note the second stage marked in red. This is the stage that will be blended. The textures used do not require an alpha channel.
This is the shader used for the 'rough;' edged blend. Note the difference in the second stage (in red) to the smooth blend shader. The grass texture must have an alpha channel for the shader to work properly, some experimentation with the textures alpha channel may be required to get the effect you want. Usually a high contrast alpha channel is best.
The really great thing about this blending method is that your tri-soup can be of any size. Previously all the triangle brushes that made up our terrain mesh had to all be the same, that limitation is no longer with us as you can see from the images below. Here we have made the path look slightly more natural, the edge of the grass is no longer a dead straight line. The image on the right shows the outlines of the brushes (r_showtris 1). As you can see the brushes are of varying sizes, using this technique it is now easier to create things like river banks, vertical cliffs - the list goes on.
This has been a basic introduction to this technique and should be enough to get you going. There is much more to discuss, such as using the technique for cliff walls which will be the subject of the next tutorial. In case you can't wait here is a tip: Using these textures for vertical cliffs will produce a bar code type effect, this is due to the texture projection set in the shaders by the following:
q3map_tcGen ivector ( 256 0 0 ) ( 0 256 0 )
Just in case none of the above makes any sense (and I am not entirely sure it does) here is the sample map used in the tutorial.