VoltAir
|
Definition of a terrain material. More...
Public Types | |
enum | BlendMode { BlendMode::Add, BlendMode::Multiply, BlendMode::Overlay, BlendMode::Blend, BlendMode::Count } |
Blend modes used to mix the bevel texture with the base texture. More... | |
Public Member Functions | |
TerrainMaterialDef () | |
Construct a default TerrainMaterialDef. More... | |
const QString & | getName () const |
Returns the name of this material. More... | |
void | setName (const QString &value) |
Sets the name of this material, used to identify it and look it up. More... | |
const QString & | getBaseTexture () const |
Returns the graphics root relative path to the base texture. More... | |
void | setBaseTexture (const QString &value) |
Sets the graphics root relative path to the base texture. More... | |
const QString & | getBevelTexture () const |
Returns the graphics root relative path to the bevel texture. More... | |
void | setBevelTexture (const QString &value) |
Sets the graphics root relative path to the bevel texture. More... | |
const QString & | getEdgeTexture () const |
Returns the graphics root relative path to the edge texture. More... | |
void | setEdgeTexture (const QString &value) |
Sets the graphics root relative path to the edge texture. More... | |
bool | isTiled () const |
Whether or not the base texture should be tiled past the first instance. More... | |
void | setTiled (bool value) |
Sets whether or not the base texture should be tiled past the first instance. More... | |
bool | isOpaque () const |
Whether or not the alpha channel on the base texture should be used for alpha blending. More... | |
void | setOpaque (bool value) |
Returns whether or not the alpha channel on the base texture should be used for alpha blending. More... | |
float | getEdgeWidth () const |
Returns the width of the edge, in world coordinates. More... | |
void | setEdgeWidth (float value) |
Sets the width of the edge, in world coordinates. More... | |
float | getEdgeOffset () const |
Returns the offset to apply to the start of the edge polygon's texture coordinates. More... | |
void | setEdgeOffset (float value) |
Sets the offset to apply to the start of the edge polygon's texture coordinates, to shift the start of the edge polygon where a texture seam occurs. More... | |
float | getEdgeScale () const |
Returns the scaling factor on edge texture coordinates. More... | |
void | setEdgeScale (float value) |
Sets the scaling factor on edge texture coordinates, controlling the tightness of tiling. More... | |
float | getBevelScale () const |
Returns the horizontal scaling factor on bevel texture coordinates. More... | |
void | setBevelScale (float value) |
Sets the horizontal scaling factor on bevel texture coordinates, controlling the tightness of tiling. More... | |
BlendMode | getBlendMode () const |
Returns the blend mode used to composite the bevel texture over the base texture. More... | |
void | setBlendMode (BlendMode value) |
Returns the blend mode used to composite the bevel texture over the base texture. More... | |
void | reset () |
Sets all properties in this TerrainMaterialDef to their default. More... | |
void | mergeFromJson (const QVariantMap &jsonValue) |
Initializes the terrain material properties from a JSON-based property map. More... | |
Static Public Member Functions | |
static BlendMode | parseBlendMode (const QString &str, BlendMode defaultValue) |
Returns a string converted into the corresponding BlendMode. More... | |
Definition of a terrain material.
A terrain material blends up to three textures:
The base texture is tiled across the entire terrain mesh. The edge texture is used to mask out the outer edges of the mesh. This adds antialiasing which also help create small variations that break up the edge visually. The bevel texture is overlayed on top of these. It is stretched from the outer edge inwards to some depth, and is blended using the selected mode (see setBlendMode()). This allows the bevel texture to be used to create a variety effects such as:
TerrainMaterialDefs are loaded from JSON by class TerrainMaterials and consumed by TerrainMeshRenderer. Terrain materials are referenced by name.
|
strong |
Blend modes used to mix the bevel texture with the base texture.
Enumerator | |
---|---|
Add |
Additive blending. Source color values are added on to the destination. |
Multiply |
Multiplicative blending. Source color values are multiplied with the destination. |
Overlay |
Overlay blending. Source color values are multiplied by |
Blend |
Source over blending. Source colors are linearly mixed with the destination based on source alpha. |
Count |
Total number of blending modes.
|
TerrainMaterialDef::TerrainMaterialDef | ( | ) |
Construct a default TerrainMaterialDef.
|
inline |
Returns the graphics root relative path to the base texture.
|
inline |
Returns the horizontal scaling factor on bevel texture coordinates.
|
inline |
Returns the graphics root relative path to the bevel texture.
|
inline |
Returns the blend mode used to composite the bevel texture over the base texture.
|
inline |
Returns the offset to apply to the start of the edge polygon's texture coordinates.
|
inline |
Returns the scaling factor on edge texture coordinates.
|
inline |
Returns the graphics root relative path to the edge texture.
|
inline |
Returns the width of the edge, in world coordinates.
|
inline |
Returns the name of this material.
|
inline |
Whether or not the alpha channel on the base texture should be used for alpha blending.
|
inline |
Whether or not the base texture should be tiled past the first instance.
void TerrainMaterialDef::mergeFromJson | ( | const QVariantMap & | jsonValue | ) |
Initializes the terrain material properties from a JSON-based property map.
jsonValue | JSON-based property map to initialize from |
|
static |
Returns a string converted into the corresponding BlendMode.
str | String to parse |
defaultValue | Default BlendMode to return if str is not recognized |
void TerrainMaterialDef::reset | ( | ) |
Sets all properties in this TerrainMaterialDef to their default.
void TerrainMaterialDef::setBaseTexture | ( | const QString & | value | ) |
Sets the graphics root relative path to the base texture.
value | Path to texture to set |
void TerrainMaterialDef::setBevelScale | ( | float | value | ) |
Sets the horizontal scaling factor on bevel texture coordinates, controlling the tightness of tiling.
Larger values increases the size of each tile segment, spacing them out. Smaller values decrease the size of each tile segment, tighting the tiling pattern.
1.0f
value | Scaling factor to set |
void TerrainMaterialDef::setBevelTexture | ( | const QString & | value | ) |
Sets the graphics root relative path to the bevel texture.
value | Path to texture to set |
void TerrainMaterialDef::setBlendMode | ( | BlendMode | value | ) |
Returns the blend mode used to composite the bevel texture over the base texture.
value | BlendMode to use |
BlendMode::Add
void TerrainMaterialDef::setEdgeOffset | ( | float | value | ) |
Sets the offset to apply to the start of the edge polygon's texture coordinates, to shift the start of the edge polygon where a texture seam occurs.
value | Offset to set |
0.0f
void TerrainMaterialDef::setEdgeScale | ( | float | value | ) |
Sets the scaling factor on edge texture coordinates, controlling the tightness of tiling.
Larger values increases the size of each tile segment, spacing them out. Smaller values decrease the size of each tile segment, tighting the tiling pattern.
1.0f
value | Scaling factor to set |
void TerrainMaterialDef::setEdgeTexture | ( | const QString & | value | ) |
Sets the graphics root relative path to the edge texture.
value | Path to texture to set |
void TerrainMaterialDef::setEdgeWidth | ( | float | value | ) |
Sets the width of the edge, in world coordinates.
This specifies the width of the triangle strip around the circumference of the terrain. This strip is where the edge texture gets combined with the base texture (and potentially bevel texture) to produce a soft edge. A value of 0.0f
disables the generation of the edge triangle strip (reducing the amount of geometry drawn, but introducing aliasing artifacts).
value | Width to set |
0.0f
void TerrainMaterialDef::setName | ( | const QString & | value | ) |
Sets the name of this material, used to identify it and look it up.
value | Name to set |
void TerrainMaterialDef::setOpaque | ( | bool | value | ) |
Returns whether or not the alpha channel on the base texture should be used for alpha blending.
When this is true
, the base texture is treated as an opaque texture and the only alpha rendered is where the edge texture has alpha. When this is false
, the base texture's alpha channel is used as a per-pixel alpha, and multiplied with the edge texture's alpha to produce an overall per-pixel transparency.
value | true to treat the base texture as opaque |
true
void TerrainMaterialDef::setTiled | ( | bool | value | ) |
Sets whether or not the base texture should be tiled past the first instance.
value | true to tile |
true