Terrain Texture Blending System Overview

Here is the system for creating, categorizing, and naming the terrain blend preset images. It's designed to give a useful and uniform core set of presets, allow for expandability without creating disorganized chaos.

Terrain Shaders

The terrain system is expanded to include alpha blending between two textures. The includes the ability to control the alpha blend in real time in Radiant. First you need to build special two stage alpha blend shaders like the one displayed below.

The surfaceparam nolightmap statement tells q3map not to calculate a light map for the terrain brush. The qer_editorimage statement with two texture names tells Radiant to display the both textures as a single shader in the texture window. This second texture name is an optional parameter.

The first texture in the qer_editorimage statement appears on the left in the Radiant texture window and the second texture appears on the right in the Radiant texture window. In addition, the first texture in the qer_editorimage statment must be the first stage texture and the second texture in the qer_editorimage statment must be the second stage texture.

The first stage of the shader renders the first texture with verterx lighting and the second stage renders the second texture on top of the first using the alpha blend data created in Radiant. The second stage also applies vertex lighting to the second texture.

Radiant Usage

Once a two stage alpha blend shader has been created, the alpha blend on a terrain brush is editable in real time.

  1. Select a terrain brush in either the XY-window or the 3D-window with Shift-LeftMouseButton.
  2. Select a two pass blend shader in the texture window. Only the texture displayed on the left in the texture window will be visible on the terrain brush.
  3. Press the F key and Radiant will switch to terrain alpha blend mode.
  4. Select a vertex with the left mouse button and drag the vertex upwards. The vertex will not move but the texture will start to blend to the one displayed on the right in the texture window.
  5. Drag downwards to blend back to the texture displayed on the left in the texture window.

Preset blends may also be applied to terrain brushes.

  1. Load the textures in the blends directory.
  2. Select a terrain brush in either the XY-window or the 3D-window. (The terrain brush must have a two stage alpha blend shader on it.)
  3. Select a blend texture in the texture window. The blend will now be applied accross the terrain brush.
  4. The blend can be selectively modified using the first alpha blend mode described above.

Blend Preset Image Specifications

  • Blends
    • Type_Method-Modifier
      • Lin = Linear Ramp between A and B
      • Nos = Noisy transition between A and B
      • Wgt = Weighted transition between A and B
        • Weighted means the blend falloff is weighted towards the white or black end of the luminosity ramp.
          • i.e.: Circ_Wgt-25 .tga= Circular Blend, Weighted at 25% more White than Black versus a linear ramp.
      • Wvy = Wavy transition between A and B

The shader name for blend presets must be blends/presetimagefilename (the shader name following "blends/" must be identical to the Targa image's filename so Radiant can find the image from the shader's name.

  • The shader name for the above example image should be blends/Circ_Wgt-25

Here are the basic blend types and methods:

  • Horizontal Gradient
    • Horiz_Lin
    • Horiz_Nos
    • Horiz_Wgt
    • Horiz_Wvy
  • Vertical
    • Vert_Lin
    • Vert_Nos
    • Vert_Wgt
    • Vert_Wvy
  • Diagonal Upper Left to Lower Right
    • DiagLR_Lin
    • DiagLR_Nos
    • DiagLR_Wgt
  • Diagonal Upper Right to Lower Left
    • DiagRL_Lin
    • DiagRL_Nos
    • DiagRL_Wgt
  • Circular
    • Circ_Lin
    • Circ_Nos
    • Circ_Wgt
  • Corners
    • Crns_Lin
    • Crns_Nos
    • Crns_Wgt
  • Diamond
    • Dmd_Lin
    • Dmd_Nos
    • Dmd_Wgt
  • Bulge Upwards
    • BlgUp_Lin
    • BlgUp_Nos
    • BlgUp_Wgt
  • Bulge Downwards
    • BlgDn_Lin
    • BlgDn_Nos
    • BlgDn_Wgt
  • Bulge Left
    • BlgLt_Lin
    • BlgLt_Nos
    • BlgLt_Wgt
  • Bulge Right
    • BlgRt_Lin
    • BlgRt_Nos
    • BlgRt_Wgt
  • Irregular
    • Irreg_Nos
    • Irreg_Spots
    • Irreg_?other?

Blend Preset shaders are completely separate from the Terrain shaders. Every blend preset is a shader that blends between with 2 base images referenced in a separate terrain shader entry. The first is the "A" texture and the second is the "B" texture. The blend is from "A" to "B" when in normal mode, and from "B" to "A" when Inverse Blend is activated.

The actual blend texture must be a 9x9 24-bit targa file. Even though depicted as a hue neutral (grayscale) image, the blend must be in the red, green, and blue channels. Each blend preset shader must also have a QEReditorimage that represents the blend. While terrain blend preset images are 9x9 pixels, corresponding with the verts of a terrain tile, this is too small to see in the editor and so QEReditorimages for blend preset shaders need to be 64x64 so it is viewable in Radiant without changing any settings.

The procedure to make a QEReditorimage for blend presets in PhotoShop is:

  1. Create a new image of 64x64.

  2. Make a pure red layer and a pure blue layer. Red represents image "A" and blue represents "B", so the red layer should be above the blue layer in order.

  3. Resize your grayscale blend image image to 64x64 using the nearest neighbor interpolation method.

  4. Copy the blend image to the clipboard.

  5. Add a Layer Mask to the red layer (Reveal All mode if using PS6).

  6. Select the Layer Mask thumbnail on the Layers palette, and then select the Channels tab.

  7. Activate the visibility icon for the Mask channel and select the Mask Channel.

  8. Paste the blend image into the Mask Channel.

  9. Save the file as a Targa in the QER folder using the naming convention qer_blendimagename.tga.

  10. Set up the blend preset shader, pointing to this QEREditorImage.