L3DT documentation
Large 3D terrain generator

Differences

This shows you the differences between two versions of the page.

l3dt:userguide:ops:alpha [2017/08/31 07:17] (current)
Line 1: Line 1:
 +====== Alpha map operations ======
  
 +If you are interested in generating [[l3dt:reference:maps:alpha|alpha maps]] for texture splatting, you may find it beneficial to read the discussion on the [[l3dt:algorithms:splatting|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:
 +
 +<html><div align="center"></html>
 +|  {{l3dt:userguide:wizards:tx_alpha.gif}}  |
 +^  Viewing the alpha coverage of a texture.  ^
 +<html></div></html>
 +
 +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 [[l3dt:reference:maps:am|attributes map]], and are specified in the appropriate [[l3dt:algorithms:cli:land_type#texture|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).
 +
 +<html><div align="center"></html>
 +|  {{l3dt:userguide:ops:alpha:tx_alpha_b.gif}}  |
 +^  Viewing a texture image.  ^
 +<html></div></html>
 +
 +
 +
 +===== 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.
 +
 +
 +<html><div align="center"></html>
 +|  {{l3dt:userguide:ops:alpha:tx_alpha_c.gif}}  |
 +^  Selecting a different alpha layer for a texture.  ^
 +<html></div></html>
 +
 +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.
 +
 +
 +<html><div align="center"></html>
 +|  {{l3dt:userguide:ops:alpha:tx_alpha_d.gif}}  |
 +^  Combining several textures into one alpha layer.  ^
 +<html></div></html>
 +
 +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.
 +
 +
 +<html><div align="center"></html>
 +|  {{l3dt:userguide:ops:alpha:tx_alpha_e.gif}}  |
 +<html></div></html>
 +
 +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.
 +
 +{{ l3dt:userguide:wizards:tx_alpha2.png }}
 +
 +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 [[l3dt:algorithms:mosaics|mosaic map]] of square image files, each of a side-length given by the //mosaic tile size// value. In the above example, a 2048x2048 image is to be split into an 4x4 mosaic of 512x512 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 output|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|alpha images]]. If you have enabled the //export alpha maps now// option, L3DT will also save the alpha map images and an [[#XML file|XML file]] that describes the contents of the alpha image(s).
 +
 +<note important>
 +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 //[[http://www.bundysoft.com/L3DT/downloads/professional.php|Professional Edition]]//.
 +</note>
 +
 +==== 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.
 +
 +
 +<html><div align="center"></html>
 +{{l3dt:userguide:ops:alpha:alpha1_mosaic.png}}
 +
 +{{l3dt:userguide:ops:alpha:alpha2_mosaic.png}}
 +<html></div></html>
 +
 +<note>
 +If you would like to load a mosaic image such as those above, you may find the information on the [[l3dt:algorithms:mosaics|mosaic algorithms]] page useful.
 +</note>
 +
 +
 +==== 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:
 +
 +<html><div align="center"></html>
 +|  {{l3dt:userguide:ops:alpha:rgba1.png}}  |
 +^  RGBA PNG images used for texture splatting, rendered in your browser.  ^
 +<html></div></html>
 +
 +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:
 +
 +<html><div align="center"></html>
 +|  {{l3dt:userguide:ops:alpha:rgba2.png}}  |
 +^  RGBA PNG images used for texture splatting, rendered in MS Paint.  ^
 +<html></div></html>
 +
 +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 [[http://www.w3.org/TR/1998/REC-xml-19980210|extensible markup language (XML)]] that describes the contents of the alpha maps. A typical file is shown below:
 +
 +<code xml>
 +<?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>
 +</code>
 +
 +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 [[mailto:aaron@bundysoft.com|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 [[bundywiki>plugins:calc:atFilterAM:alphaexpress|atFilterAM plugin]], which implements this feature.
 
l3dt/userguide/ops/alpha.txt · Last modified: 2017/08/31 07:17 (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