L3DT documentation
Large 3D terrain generator

Differences

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

l3dt:algorithms:splatting [2017/08/31 06:33] (current)
Line 1: Line 1:
 +====== Texture splatting ====== 
 +
 +//Texture splatting// is a technique by which the texture of an object is calculated at run-time from a set of base textures and a set of [[l3dt:reference:maps:alpha|alpha maps]] or a suitable mathematical function. For a good discussion of how texture splatting works, please refer to [[http://www.gamedev.net/columns/hardcore/splatting/|this GameDev article]] by Nate Glasser.
 +
 +Splatting has several advantages over using pre-calculated textures:
 +
 +  * You can, in principle, achieve unlimited texture resolution.
 +  * By calculating textures on-the-fly, you obviate the need to store and manage 10s - 1,000s of Mb of high-res pre-calculated textures.
 +  * You can easily modify textures at run-time (eg. adding burn-marks on ground, etc).
 +
 +Splatting is standard for most commercial computer games these days. Some nice examples include [[http://www.farcry.ubi.com/|Far Cry]] by UbiSoft, and [[http://www.worldofwarcraft.com/|World of Warcraft]] by Blizzard Entertainment.
 +
 +<note>
 +John Carmack's [[http://www.id.com|id Software]] has moved away from texture splatting in their most recent games, in favour of extremely large pre-calculated textures (so-called 'MegaTextures'). Of course, L3DT supports this too (see [[l3dt:algorithms:tx#high resolution textures]]).
 +</note>
 +
 +
 +
 +
 +===== Generating alpha maps =====
 +
 +L3DT can export the alpha maps used to generate the terrain textures ([[l3dt:userguide:ops:alpha|see the user-guide]] for the //"how?"// part). To illustrate the meaning of these maps, consider the image below:
 +
 +<html><div align = "center"></html>
 +|  {{l3dt:algorithms:splatting:splattx.jpg}}  |
 +^  A blended texture.  ^
 +<html></div></html>
 +
 +This texture was blended from 9 different textures, including 4 for grass, 3 for rock, 1 for dirt, and 1 for sand. The individual alpha maps are shown below:
 +
 +<html><div align = "center"></html>
 +| {{l3dt:algorithms:splatting:layer1.gif}} | {{l3dt:algorithms:splatting:layer2.gif}} | {{l3dt:algorithms:splatting:layer3.gif}} |
 +^  steep grass  ^  coastal grass  ^  pebbles  ^
 +| {{l3dt:algorithms:splatting:layer4.gif}} | {{l3dt:algorithms:splatting:layer5.gif}} | {{l3dt:algorithms:splatting:layer6.gif}} |
 +^  beach sand  ^  rock slope  ^  grass (normal)  ^
 +| {{l3dt:algorithms:splatting:layer7.gif}} | {{l3dt:algorithms:splatting:layer8.gif}} | {{l3dt:algorithms:splatting:layer9.gif}} |
 +^  cliff face,<html><br/></html>u/w rock  ^  lush grass  ^  lake mud  ^
 +<html></div></html>
 +
 +L3DT can export the alpha layers as individual greyscale images, as shown above, but it can also combine the layers into the colour channels of RGB and RGBA images, thereby packing up to 4 alpha layers into each image (see below).
 +
 +<html><div align="center"></html>
 +| {{l3dt:algorithms:splatting:splat1.gif}} | {{l3dt:algorithms:splatting:splat2.gif}} | {{l3dt:algorithms:splatting:splat3.gif}} |
 +<html></div></html>
 +
 +However, using the above 3 alpha map images (and the 9 corresponding ground textures) will strain contemporary GFx cards, particularly if they're rendering other things as well (detail maps / light maps/ bump maps / etc). You can reduce the number of images required by combining the alpha layers of similar land types (see '[[l3dt:userguide:ops:alpha#combining_alpha_layers|Combine alpha layers]]' wizard). The image below is the combined alpha map in which all grass texture alphas were packed into the green channel, rock is in blue, and sand/mud is in the red channel. Using this alpha map you then only need 4 textures in GFx memory when rendering; one for grass, one for rock, one for sand/mud, and the alpha map itself. The result won't look as good at run-time (since all the grass will look the same), but it will render a whole lot quicker.
 +
 +<html><div align = "center"></html>
 +|  {{l3dt:algorithms:splatting:splatcombined.gif}}  |
 +^  A combined alpha map.  ^
 +<html></div></html>
 +
 +L3DT can also split the alpha maps into tiles (using [[l3dt:algorithms:mosaics|mosaic maps]]) so that, for example, that the alpha maps for a 4096x4096 pixel map can be split into an 8x8 set of 512x512 image files. This may be particularly useful when rendering very large maps, where you would not want to hold all textures in memory at once.
 +
 +
  
 
l3dt/algorithms/splatting.txt · Last modified: 2017/08/31 06:33 (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