UnigineScript
The Language
Core Library
Engine Library
Node-Related Classes
GUI-Related Classes
Plugins Library
High-Level Systems
Samples
C++ API
API Reference
Integration Samples
Usage Examples
C++ Plugins
Content Creation
Materials
Unigine Material Library
Tutorials

Texturing

There are several base textures that are used in Unigine to construct a material. Depending on material and object properties, not all of them are needed and, of course, their sizes don't have to be equal. Here is a list of base textures:

  • Diffuse texture. It uses an RGBA format where the alpha channel contains either transparency values or a detail mask.
  • Normal map. It uses an LA format which stores two components of a normal. The third component is calculated from the stored components.
  • Specular map. It uses the RGBA format where the alpha channel contains a reflection scale.
  • Emission map. It uses the RGBA format where the alpha channel contains a glow mask.
  • Height map. It uses an L format where white means a neutral value and darker shades specify different depths of depression.

Requirements

The following conditions are necessary:

  • Dimensions of all textures should be equal to some power of two, for example, 256×512 is a valid size, and 255×512 is an invalid size.
  • Textures larger than 2048×2048 are not supported by some older graphics cards. Moreover, objects with such textures will rarely be close enough to the screen to show all pixels at a natural scale. On the other hand, do not use textures less than 4×4; this is the smallest block for DXT compression. Also, sometimes 1×1 textures aren't rendered correctly due to driver bugs.
  • Preferred storage format for final textures is DDS. What compression to choose depends on texture properties. Sometimes, it is better not to use compression at all, for example, for a small texture of a window glass that will be stretched to the glass size. It is recommended to use ImageDDS to convert textures into the DDS format (note that it implies a certain naming convention). See also: Level Design.
  • Texture background should not make a contrast to colors at edges of images. It is especially important for normal maps and height maps; for them, use blue and white as a background color respectively.
  • If an object surface is not tiled and parallax mapping will be used for it, a certain amount of pixels outside a UV map (near image edges) should be "painted" to avoid visual artifacts. An actual amount of pixels depends on a parallax scale.
  • If you need to combine two normal maps, for example, when adding noise, use NormalCombiner to correctly merge two maps.
  • A 3D texture is simply a vertical strip of frames, and the number of frames should be equal to some power of two. Also, try to keep your 3D textures as small as possible.
  • Specular map should have non-zero alpha channel value to avoid artifacts.
    Notice
    DirectX 10 hardware cannot handle specular map if it has alpha channel value of 0. As it is used to modulate specular power, the function pow(any,0.0f) will result in "not a number" value.

Guidelines and Tips

Here are some useful tips:

  • Use tetxure atlases but with the following restrictions:
    • A DXT-compressed texture with an alpha channel is twice as large as the same DXT-compressed texture without the alpha channel due to the nature of the compression algorithm. So, it is recommended to use separate textures for elements that require the alpha channel and for elements that don't need it.
    • Prefer spatial organization of the atlases, so that parts belonging to neighboring objects in the scene were close to each other, and parts belonging to distant objects were away from each other.
  • It makes sense to use a 16-bit normal map for a surface with a large curve radius to avoid visible level switching.
  • If an object contains thin lines and fine details, it is better to edit its normal map in target texture dimensions from the start. This will ensure image clearness when applied to a model. Using larger dimensions than required and further downsizing may lead to a blur because of filtering.
  • Use mipmaps to achieve an even distribution of pixel density and to determine optimal texture dimensions. Turn on mipmap visualization, if needed.
    • Create mipmaps when compressing textures into the DDS format (-m flag of ImageDDS).
    • Manually edit or at least review mipmaps, if alpha testing will be used with a given texture. Otherwise, on some levels, transparent parts of objects may disappear. This is especially important for textures representing grates, grids, bars, etc.
    Notice
    Mipmaps are not generated automatically in run time. If no mipmaps are stored in the DDS file, they won't be used at all. (Despite the fact that possible mipmaps levels are visualized by the editor, they are still not used).
  • Average brightness level of a detail texture (diffuse) should be equal or almost equal to 127. Thus, if the detail texture is off after LODs switching, material brightness remains the same.
Last update: 2017-07-03