L3DT documentation
Large 3D terrain generator

Alpha map operations

If you are interested in generating alpha maps for texture splatting, you may find it beneficial to read the discussion on the algorithms page, which amongst other things explains what the alpha maps are, why you might want to combine alpha layers, and also some of the alpha map file output options available in L3DT.

Generating alpha maps

To generate alpha maps, select the 'Operations→Alpha maps→Generate alpha maps' menu option. This will open the Combine alpha layers wizard, shown below:

Viewing the alpha coverage of a texture.

On the left of this wizard you can see the list the textures that L3DT would use to generate the 'conventional' texture map. These textures are those that are associated with each land type in the attributes map, and are specified in the appropriate land type definitions. You can view the alpha map coverage for each texture in the panel to the left (as shown above), or the texture image itself (shown below).

Viewing a texture image.

Combining alpha layers

To combine textures into the same alpha layer, click on the 'Alpha ID' entry to open the 'in-place' drop-down list (shown below). If you want two textures in the same alpha layer, give them the same AlphaID value.

Selecting a different alpha layer for a texture.

As an example of this I have combined all grass textures into the same alpha layer (shown below). The coverage of this alpha layer is displayed in red in this case.

Combining several textures into one alpha layer.

Note that the coverage of the currently selected texture is shown brighter than the coverage of the other textures in the same alpha layer. Thus, below, the coverage of the 'grass1d' texture is highlighted, whereas in the above image the coverage of 'grass1a' is highlighted.

Once you are happy with the set of alpha layers, click on the Next » button to go to the alpha map options wizard.

File output

The alpha map file output wizard (below) is where you set the output filename and image file format used to save the alpha maps.

The controls are as follows:

  • The layers per image value sets how many alpha layers are packed into each image file. Allowed values include 1 (which is 8-bit greyscale), 3 (which is 24-bit RGB) and 4 (which is 32-bit RGBA).
  • The image file format may be bitmap, jpg, png, dds, tga or other supported formats, but for reasons of accuracy, the use of png is always recommended.
  • The number of images value is the calculated number required to save the all the alpha layers (set in the previous combine alpha layers wizard) using the specified value of layers per image (set in this wizard). For example, if you have 5 alpha layers and you are using 3 layers per image, then you will need 2 images to hold that number of layers.
  • The Anti-alias cutoff setting determines the radius (in pixels) of the anti-aliasing filter that is used to smoothly blend the interface between the textures of different land types. Anti-aliasing is slow, but it is required when using alpha maps that are larger in size than the attributes map.
  • The Make high-res alpha maps option allows you to make alpha maps with a higher resolution (and also size) than the attributes map. In the above example, the alpha maps will be 4x larger than the attributes map.
  • If you select the split alpha images into tiles option, the alpha image(s) will be split into a mosaic map of square image files, each of a side-length given by the mosaic tile size value. In the above example, a 2048×2048 image is to be split into an 4×4 mosaic of 512×512 pixel images.
  • The export alpha maps now option allows you to immediately export the alpha map images to the directory of your choosing, along with an XML file that describes the contents of the alpha map(s). The filenames of the alpha images will be listed in that file, and these will either be in the same directory as the XML file, or in subdirectories thereof (this is the case for mosaic images). If this option is disabled, the alpha maps will still be generated and stored in the project, but will not be immediately exported (you can of course export alpha map layers at any later time).

When you click 'OK' in this wizard, L3DT will go away and generate the alpha images. If you have enabled the export alpha maps now option, L3DT will also save the alpha map images and an XML file that describes the contents of the alpha image(s).

In the unregistered L3DT 'Standard Edition', you are restricted to 8-bit bitmap alpha maps only, and mosaics are disabled. To access RGB or RGBA images, or mosaic alpha maps, you will need the Professional Edition.

Alpha images

A typical alpha map output is shown below. These two mosaic images were taken from the example shown above, in which 10 textures were combined into 6 alpha layers, and saved as two RGB bitmap mosaic images.

If you would like to load a mosaic image such as those above, you may find the information on the mosaic algorithms page useful.

Why do my RGBA alpha-maps look black-and-white?

If you save the alpha images as 4-layer PNG images (i.e. 32-bit RGBA), you may be surprised to find that the images appear to be black and white:

RGBA PNG images used for texture splatting, rendered in your browser.

Fear not, the RGB channels are not wonky! If you load the same image in MS Paint you will see that the RGB channels are OK:

RGBA PNG images used for texture splatting, rendered in MS Paint.

In the alpha maps, pixels will be either pure red, pure green, pure blue or pure alpha. Hence every pixel with a non-black RGB colour has an alpha of zero. In computer graphics, the alpha channel is defined such that an alpha of zero means full transparency, which most image viewing programs will render either as transparent or as a white background. Conversely, any pixel with a non-zero alpha has an RGB colour of black, and so is rendered black. Thus the 4-layer PNG images will appear, in most programs, to be either black-and-transparent or black-and-white. MS Paint is an exception, as it discards the alpha layer and renders just the RGB colour.

So, in summary, the images are just fine, but you can't view them in most image viewing programs.

XML file output

Along with the alpha images (shown above), L3DT saves a text file in the extensible markup language (XML) that describes the contents of the alpha maps. A typical file is shown below:

<?xml version="1.0" encoding="utf-8"?>
<AlphaData>
  <nImages>2</nImages>
  <nLayers>6</nLayers>
  <LayersPerImage>3</LayersPerImage>
  <ImageFileExt>jpg</ImageFileExt>
  <MosaicImages>true</MosaicImages>
  <MosaicTileSize>512</MosaicTileSize>
  <ImageList>
    <Image>
      <FileName>"Splat_Alpha1\Alpha1.mmf"</FileName>
      <LayerList>
        <Layer>
          <LayerColour>red</LayerColour>
          <TexList>
            <TextureFile>"grass\grass1h.jpg"</TextureFile>
            <TextureFile>"grass\grass1d.jpg"</TextureFile>
            <TextureFile>"grass\grass1c.jpg"</TextureFile>
            <TextureFile>"grass\grass1a.jpg"</TextureFile>
          </TexList>
        </Layer>
        <Layer>
          <LayerColour>green</LayerColour>
          <TexList>
            <TextureFile>"rock\rock1.jpg"</TextureFile>
            <TextureFile>"rock\rock1b.jpg"</TextureFile>
          </TexList>
        </Layer>
        <Layer>
          <LayerColour>blue</LayerColour>
          <TexList>
            <TextureFile>"ground\dirt1.jpg"</TextureFile>
          </TexList>
        </Layer>
      </LayerList>
    </Image>
    <Image>
      <FileName>"Splat_Alpha2\Alpha2.mmf"</FileName>
      <LayerList>
        <Layer>
          <LayerColour>red</LayerColour>		
          <TexList>
            <TextureFile>"snow\snow.jpg"</TextureFile>
          </TexList>
        </Layer>
        <Layer>
          <LayerColour>green</LayerColour>		
          <TexList>
            <TextureFile>"ground\rocks1d.jpg"</TextureFile>
          </TexList>
        </Layer>
        <Layer>
          <LayerColour>blue</LayerColour>		
          <TexList>
            <TextureFile>"sand\yellowsand1.jpg"</TextureFile>
          </TexList>
        </Layer>
      </LayerList>
    </Image>
  </ImageList>
</AlphaData>

XML is human-readable, so I hope that users will not have difficulty in understanding names and meanings of entities contained in this file. If you would like me to write a proper discussion of the file contents, please e-mail me at aaron@bundysoft.com. Similarly, if you think there should be some additional data added to this file, you know where to contact me.

Alpha export express

L3DT includes a second method to generate alpha maps, which is available in the menu at 'Operations→Alpha maps→Alpha export express'. Rather than combining the alpha layers manually, as done above, this option uses a set of pre-defined (and user-editable) rules to calculate the alpha maps from the attributes map.

For more information on using Alpha export express, please consult the user-guide for the atFilterAM plugin, which implements this feature.

 
l3dt/userguide/ops/alpha.txt · Last modified: 2013/08/21 17:20 (external edit)
 
Except where otherwise noted, content on this wiki is licensed under the following license:CC Attribution-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki