IHeightmapOps
Description
- Extended by
Defines common operations of IHeightmap objects.
The IHeightmap object that is returned by the heightmap operation methods must be used by the caller instead of the IHeightmap on which the method has been called.
Public / Methods
Border
Pads this heightmap to the smallest fitting size of 2^n+1
.
This method will add a border region at the right and bottom edges of a rectangular heightmap (see MapType.Rect). A smooth falloff is computed at the heightmap edges in order to avoid unnecessary triangles being created by CLOD mesh refinement for overly sharp corners.
Clip
Clips away portions of this heightmap, according to the HeightmapLayer.Coverage layer of the given heightmap.
The coverage values of the returned heightmap are computed like this:
inverse == false : c_out = c_in * c_mask inverse == true : c_out = in * (1 - c_mask)
where c_out
is the normalized coverage value (i.e. in the range [0..1]) of the returned heightmap, c_in
is the normalized coverage value of this heightmap and c_arg
is the normalized coverage value of mask in.
Combine
Adds detail to this heightmap by combining it with the given heightmap.
The heightmap samples of this heightmap (source
) are modified using the samples of the given detail heightmap (detail
) according to these rules:
-
HeightmapLayer.Coverage:
The coverage of this heightmap will remain unchanged. The coverage of the given detail heightmap will be ignored. -
HeightmapLayer.Elevation:
The terrain-space elevation values (see VerticalRange) of this heightmap and the given detail heightmap are combined using the given scalar operation (see scalarOp opt); then the resulting scalar value is converted back to elevation values using the combined vertical range. -
HeightmapLayer.Texture:
The given color operation (see textureOp opt) is applied to the texture color of this heightmap (first
) and the color of the given detail heightmap (second
). -
HeightmapLayer.Material:
The material tokens of this heightmap are mixed with the tokens of the detail heightmap: If the weight sum (MaterialToken.WeightSum) of the detail token is greater than or equal to255
, the source token will be replaced with the detail token. Otherwise, the source token will be gradually blend into the detail token (see MaterialToken.Mix1). -
HeightmapLayer.Displacement:
The terrain-space displacement values (see VerticalRange) of this heightmap and the given detail heightmap are combined using the given scalar operation (see scalarOp opt); then the resulting scalar value is converted back to displacement values using the combined vertical range.
Merge
Merges the given heightmap with this one. The coverage of both heightmaps will be taken into account during merging.
Merged heightmaps fill data into heightmap samples in order, with heightmaps at a later stage overwriting sample data written by heightmaps of an earlier stage.
Both heightmaps (this one and second in) will be scaled to the maximum possible size.
Scale
Returns a scaled version of this heightmap.
The maximum up-scaling factor for heightmaps is 65536
, so the given condition should be met when up-scaling a heightmap (otherwise only the 16 most significant bits of the interpolation factor will be used):
(newSize - 1) / (Size - 1) <= 65536
where newSize in is the new heightmap size and IHeightmap.Type is the current size of this heightmap.
Swizzle
Swizzles materials.
When the coverage layer is involved in the substitution, material weights are mapped to inverse coverage values.
Material substitution always has a fixed cost at runtime, no matter how many times this method has been used.
ToPyramid
Wraps this heightmap in a pixel pyramid.
The returned pixel pyramid will have uniform level of detail, so it is not necessary to user the PyramidFlags.Opaque flag.
UseColorRamp
Return a heightmap that computes texture colors using an elevation-based color ramp.
The terrain-space values of the HeightmapLayer.Elevation layer (according to the vertical range and unit of the heightmap) are fed into the color ramp. The resulting diffuse color is used as the HeightmapLayer.Texture layer.