Click or drag to resize
DigitalRuneTerrainMaterialLayer Class
Represents a material with tiling textures that are rendered onto the terrain.
Inheritance Hierarchy

Namespace: DigitalRune.Graphics
Assembly: DigitalRune.Graphics (in DigitalRune.Graphics.dll) Version: 1.2.0.0 (1.2.1.14562)
Syntax
public class TerrainMaterialLayer : TerrainLayer

The TerrainMaterialLayer type exposes the following members.

Constructors
  NameDescription
Public methodTerrainMaterialLayer(IGraphicsService)
Initializes a new instance of the TerrainMaterialLayer class with the default material.
Public methodTerrainMaterialLayer(Material)
Initializes a new instance of the TerrainMaterialLayer class with a custom material.
Top
Methods
  NameDescription
Public methodDispose
Releases all resources used by an instance of the TerrainLayer class.
(Inherited from TerrainLayer.)
Protected methodDispose(Boolean)
Releases the unmanaged resources used by an instance of the TerrainLayer class and optionally releases the managed resources.
(Inherited from TerrainLayer.)
Public methodEquals
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetHashCode
Serves as a hash function for a particular type.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Properties
  NameDescription
Public propertyAabb
Gets (or sets) the axis-aligned bounding box of the area that is influenced by this terrain layer.
(Inherited from TerrainLayer.)
Public propertyAlpha
Gets or sets the opacity (alpha). (This is a material parameter - see remarks.)
Public propertyBlendHeightInfluence
Gets or sets the influence of the HeightTexture on the blend weight. (This is a material parameter - see remarks.)
Public propertyBlendNoiseInfluence
Gets or sets the influence of the noise on the blend weight. (This is a material parameter - see remarks.)
Public propertyBlendRange
Gets or sets the blend range. (This is a material parameter - see remarks.)
Public propertyBlendTexture
Gets or sets the texture which contains the blend weights. (This is a material parameter - see remarks.)
Public propertyBlendTextureChannel
Gets or sets the texture channel of the BlendTexture which contains the blend weight for this material. (This is a material parameter - see remarks.)
Public propertyBlendThreshold
Gets or sets the threshold for the blend weights. (This is a material parameter - see remarks.)
Public propertyDiffuseColor
Gets or sets the diffuse color. (This is a material parameter - see remarks.)
Public propertyDiffuseTexture
Gets or sets the diffuse texture. (This is a material parameter - see remarks.)
Public propertyFadeInEnd
Gets or sets the clipmap level where the fade-in ends and this terrain layer is fully visible. (This is a material parameter - see remarks.)
(Inherited from TerrainLayer.)
Public propertyFadeInStart
Gets or sets the clipmap level where this terrain layer starts to fade in. (This is a material parameter - see remarks.)
(Inherited from TerrainLayer.)
Public propertyFadeOutEnd
Gets or sets the clipmap level where the fade-out ends and this terrain layer is not rendered anymore. (This is a material parameter - see remarks.)
(Inherited from TerrainLayer.)
Public propertyFadeOutStart
Gets or sets the clipmap level where this terrain layer starts to fade out. (This is a material parameter - see remarks.)
(Inherited from TerrainLayer.)
Public propertyHeightTexture
Gets or sets the height texture, which stores relative height values. (This is a material parameter - see remarks.)
Public propertyHeightTextureBias
Gets or sets the bias that is added to samples of the height texture. (This is a material parameter - see remarks.)
Public propertyHeightTextureScale
Gets or sets the scale that is multiplied with samples of the height texture. (This is a material parameter - see remarks.)
Public propertyIsDisposed
Gets a value indicating whether this instance has been disposed of.
(Inherited from TerrainLayer.)
Public propertyMaterial
Gets (or sets) the material that is used to render this terrain layer.
(Inherited from TerrainLayer.)
Public propertyMaterialInstance
Gets the material instance.
(Inherited from TerrainLayer.)
Public propertyNoiseTileSize
Gets or sets the size of the tiling noise map in world space units. (This is a material parameter - see remarks.)
Public propertyNormalTexture
Gets or sets the normal texture. (This is a material parameter - see remarks.)
Public propertySpecularColor
Gets or sets the specular color. (This is a material parameter - see remarks.)
Public propertySpecularPower
Gets or sets the specular color exponent. (This is a material parameter - see remarks.)
Public propertySpecularTexture
Gets or sets the specular texture. (This is a material parameter - see remarks.)
Public propertyTerrainHeightBlendRange
Gets or sets the range for terrain height-based blending in world space units. (This is a material parameter - see remarks.)
Public propertyTerrainHeightMax
Gets or sets the max terrain height in world space. The material is not rendered above this height. (This is a material parameter - see remarks.)
Public propertyTerrainHeightMin
Gets or sets the min terrain height in world space. The material is not rendered below this height. (This is a material parameter - see remarks.)
Public propertyTerrainSlopeBlendRange
Gets or sets the range for terrain slope-based blending in radians. (This is a material parameter - see remarks.)
Public propertyTerrainSlopeMax
Gets or sets the max terrain slope in radians. The material is not rendered if the terrain is steeper than this slope. (This is a material parameter - see remarks.)
Public propertyTerrainSlopeMin
Gets or sets the min terrain slope in radians. The material is not rendered if the terrain is flatter than this slope. (This is a material parameter - see remarks.)
Public propertyTileSize
Gets or sets the tile size of the textures in world space. (This is a material parameter - see remarks.)
Public propertyTintStrength
Gets or sets the influence of the TintTexture. (This is a material parameter - see remarks.)
Public propertyTintTexture
Gets or sets the tint texture. (This is a material parameter - see remarks.)
Public propertyTriplanarTightening
Gets or sets the tightening factor for triplanar texture mapping. (Use -1 to disable triplanar texture mapping. This is a material parameter - see remarks.)
Top
Remarks

The TerrainMaterialLayer renders a material, such as grass, dirt, rocks, etc., onto the terrain.

Material textures:
The material is defined by several tiling textures:

These textures repeat within the bounds of terrain tile. The property TileSize defines the scale of the textures.

Blend texture:
The BlendTexture contains blend weights. It is a non-tiling texture which covers the terrain tile. (In other tools or engines this texture is called splat map, control map, alpha map, material map, weight map, or mask texture.) A blend texture can contain several blend weights (e.g. an RGBA texture can contain 4 blend weights - one weight per channel). The property BlendTextureChannel determines which channel is used by the material layer.

The material reads the blend weight from the blend texture and if the blend weight is greater than BlendThreshold, the material is drawn. There is a small transition zone around the threshold where the material fades out. This transition zone is defined by BlendRange.

The HeightTexture of the material can be used to modify the blending. This can be used to create more realistic transitions between two materials. For example: One material layer draws a dirt texture. The next material layer blends a stone texture over the dirt texture. The stone material includes a height texture. This is used to create a dirt-stone transition where more dirt is visible in the gaps between stones (low height values). BlendHeightInfluence controls how much the height texture influences the blending.

Noise can also be used to make transitions between two material layers visually more interesting. If BlendNoiseInfluence is greater than 0, a noise value is added to the blend weight to make transitions less uniform. NoiseTileSize controls the size of the tiling noise texture.

Tint texture:
The TintTexture contains a color that is multiplied with the material. Like the BlendTexture, the TintTexture is a non-tiling texture which covers the entire terrain tile. TintStrength defines the influence of the TintTexture.

Height-based and slope-based blending based:
The properties TerrainHeightMin, TerrainHeightMax, TerrainSlopeMin, and TerrainSlopeMax can be used to apply the material only on terrain geometry with a certain height or slope. Near these limits the material fades out. The fade-out range is determined by TerrainHeightBlendRange and TerrainSlopeBlendRange.

Triplanar texture mapping:
The material textures are usually projected top-down onto the material. This may lead to distorted textures on very steep slopes. Triplanar texture mapping can be used to reduce distortions. If the triplanar texturing is enabled, the terrain normals are checked and the texture is projected vertically (y direction) or horizontally (x or z direction) to minimize distortions.

Triplanar texture mapping is disabled by default (TriplanarTightening = -1). Set TriplanarTightening to a positive value, e.g. 0.5, to enable triplanar texturing. Larger TriplanarTightening values make the transitions between different projection directions shorter.

See Also