Extended explanation:
Write a shader like this:
textures/yourmap/terrain
{
// standard terrain shader stuffs:
qer_editorimage textures/yourmap/rock.tga
q3map_nonplanar
q3map_shadeAngle 179
q3map_tcGen ivector ( 512 0 0 ) ( 0 512 0 )
q3map_tcMod rotate 33
q3map_lightmapAxis z
q3map_lightmapSampleOffset 8
// this means dot product squared, for faster falloff between vertical and horizontal planes:
q3map_alphaMod dotproduct2 ( 0 0 .85 )
// mapping stages:
{
map textures/yourmap/dirt.tga
rgbGen identity
}
{
map textures/yourmap/rock.tga
blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
alphaFunc GE128
rgbGen identity
alphaGen oneMinusVertex
}
{
map textures/yourmap/grass.tga
blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
alphaFunc GE128
rgbGen identity
alphaGen vertex
}
{
map $lightmap
blendFunc GL_DST_COLOR GL_ZERO
}
}
And then put it all over the surface of your terrain entity instead of common/terrain. No alphamaps required!
In order for this to work, however, your grass.tga and rock.tga images need to have a bright alpha channel (~85-95% bright). The reason it needs to be bright for both images is that rock.tga gets mapped according to the alpha’s inverse.
Here’s an explanation of how this works: this shader draws dirt.tga all over your terrain. Then, according to the vertex alpha (which defaults to white, and is scaled toward black according to the vertex normal by the q3map_alphaMod line), it blends on either rocks or grass. It’s really a great effect, and with a little bit of toying around with the values in the shader it’s very tweakable. q3map_alphaMod dotproduct2 defines the “falloff” of shader blending; it takes values for ( x y z ), and falloff gets harder/sharper as values approach zero. For soft, soft falloff, use values greater than 1 (or just use the old q3map_alphaMod dotproduct instead of dotproduct2).
<img src=http://www4.ncsu.edu/~rlcordes/MAD_BONERS/shot0058.jpg width=400 height=300>
Just for the curious: what dotproduct2 is doing is multiplying the alpha of a given vertex by the square of the result of a dotproduct operation between the normal of said vertex and the ( x y z ) vector defined in the shader.