TerrainDecal
Description
- Derived from
-
Versioned abstract
IMeshBound
IDecal
IVisibleMask
A terrain surface decal, to be used with TerrainMesh.DecalAdd
The Transform property returns a IMapTransform object, where dataset space corresponds to the heightmap raster of the underlying terrain and map space is a user-defined coordinate system in which the terrain decal vertices are specified via Vertex2.
- See also
Public / Methods
AsStreamingTarget
Creates a IStreamingTarget object that wraps the given stack of TerrainDecal objects.
The Texture of the given decals in will be reset to a dynamic model texture by the returned streaming target.
InterpolationWithAlpha
Computes alpha blending factors for the given stack of terrain decals in order to perform smooth interpolation between them.
This method will replace the alpha channel of Color and Priority in each TerrainDecal of decals in, which must have the same SortIndex value and opaque Texture resources.
- See also
InterpolationWithSlices
Computes values for TextureSlices and TextureWeights in order to perform smooth interpolation between the slices of Texture.
First, the model texture slices of Texture are mapped to the texture slice sequence, according to slices in and first in. Then, the given index in and range in are used to locate the interpolation window. Finally, the interpolation weights are computed from mode opt and the fractional part of index in. For example:
slices = [1..6] index = 100.5 range = [99..104] first = 1 +---+---+---+---+---+---+---+---+ | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | model texture slices +---+---+---+---+---+---+---+---+ | 5 | 0 | 1 | 2 | 3 | 4 | texture slice sequence +---+---+---+---+---+---+ | A | B | C | D | interpolation window +---+---+---+---+ | index
This scheme allows to use separate texture slice sequences that are packed into a single IModelTexture (see ModelTexture.Slices), which is useful for rendering static content. Streaming dynamic content for rendering (for example, time-series data or video clips) can be accomplished by performing the following steps:
-
Use ModelTexture.Dynamic to create a IModelTexture that can be updated dynamically at runtime. The slices of the dynamic model texture represent a sliding window into the whole content.
-
Load the contents of the sliding window: a background thread or task loads the content and fills in the texture data (see IModelTextureDynamic.Content). This should be done incrementally, if possible.
-
Once loading is complete, the render thread calls IModelTextureDynamic.Update, which makes the loaded texture data available for rendering.
-
The render thread calls InterpolationWithSlices to set up interpolation.
If texture arrays are not available (see ITextureFactory.MaximumCount), the InterpolationWithAlpha method may be used to achieve similar results.
Public / Attributes
Coordinates
The coordinate system to use for interpreting the transformed vertex coordinates.
If the coordinate system is null
, the decal texture will be skipped silently during processing.
- See also
Matrix
A transformation matrix that is applied to the decal vertex coordinates before rendering.
Defaults to Mat3D.Identity.
SortIndex
Specifies the terrain layer after which this terrain decal shall be rendered.
The decal will be rendered after the terrain layer that has the greatest sort index value which is less than or equal this value and before the subsequent terrain layer ( if existent).
The default value is TerrainLayer.SortIndexMaximum, i.e. the terrain decal is rendered on top of the topmost terrain layer.
- See also
TextureClip
The texture clip rectangle.
The decal vertices A, B, C and D (see remarks) are mapped to normalized texture coordinates in the range [0..1]. The texture clip rectangle spans the texture coordinate range from (X,Y)
to (1-Z,1-W)
. Pixels that lie outside of the clip rectangle are discarded during rendering. Using Vec4F.Zero will make the clip rectangle encompass the whole texture.
TextureSlices
Chooses the slices of Texture that will be used for rendering.
Each component gets clamped to [0..ITextureFactory.MaximumCount-1] and each clamped component then chooses a texture slice. The final decal texture is the sum of the chosen texture slices, weighted by their respective weight:
decal = Texture[TextureSlices.X] * TextureWeights.X + Texture[TextureSlices.Y] * TextureWeights.Y + Texture[TextureSlices.Z] * TextureWeights.Z + Texture[TextureSlices.W] * TextureWeights.W
If ITextureFactory.MaximumCount is 1
, separate TerrainDecal objects can be combined with InterpolationWithAlpha in order to get similar results.
Default to Vec4I.Zero.
- See also
Transform
Returns the IMapTransform object that represents the transformation between dataset space (the scene terrain) and map space (the terrain decal), computing it if necessary.