VoltAir
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Groups Pages
Public Types | Public Member Functions | Static Public Member Functions | List of all members
TerrainMaterialDef Class Reference

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 QStringgetName () 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 QStringgetBaseTexture () 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 QStringgetBevelTexture () 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 QStringgetEdgeTexture () 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...
 

Detailed Description

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.

Member Enumeration Documentation

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 2.0f, and then with the destination. This results in source values over 0.5f brightening the destination, and source values under 0.5f darkening it. Values of exactly 0.5f leave the destination unchanged. This effect is performed per color channel allowing color tinting similar to BlendMode::Multiply. The alpha channel determines how much to mix this computed color with the destination.

Blend 

Source over blending.

Source colors are linearly mixed with the destination based on source alpha.

Count 

Total number of blending modes.

Note
This value is not a valid blend mode, and should not be used in setBlendMode().

Constructor & Destructor Documentation

TerrainMaterialDef::TerrainMaterialDef ( )

Construct a default TerrainMaterialDef.

Member Function Documentation

const QString& TerrainMaterialDef::getBaseTexture ( ) const
inline

Returns the graphics root relative path to the base texture.

float TerrainMaterialDef::getBevelScale ( ) const
inline

Returns the horizontal scaling factor on bevel texture coordinates.

const QString& TerrainMaterialDef::getBevelTexture ( ) const
inline

Returns the graphics root relative path to the bevel texture.

BlendMode TerrainMaterialDef::getBlendMode ( ) const
inline

Returns the blend mode used to composite the bevel texture over the base texture.

float TerrainMaterialDef::getEdgeOffset ( ) const
inline

Returns the offset to apply to the start of the edge polygon's texture coordinates.

See also
setEdgeOffset()
float TerrainMaterialDef::getEdgeScale ( ) const
inline

Returns the scaling factor on edge texture coordinates.

const QString& TerrainMaterialDef::getEdgeTexture ( ) const
inline

Returns the graphics root relative path to the edge texture.

float TerrainMaterialDef::getEdgeWidth ( ) const
inline

Returns the width of the edge, in world coordinates.

See also
setEdgeWidth()
const QString& TerrainMaterialDef::getName ( ) const
inline

Returns the name of this material.

bool TerrainMaterialDef::isOpaque ( ) const
inline

Whether or not the alpha channel on the base texture should be used for alpha blending.

bool TerrainMaterialDef::isTiled ( ) const
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.

Parameters
jsonValueJSON-based property map to initialize from
static BlendMode TerrainMaterialDef::parseBlendMode ( const QString str,
BlendMode  defaultValue 
)
static

Returns a string converted into the corresponding BlendMode.

Parameters
strString to parse
defaultValueDefault 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.

Parameters
valuePath 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.

Note
This is used exclusively by the editor to generate the render mesh.
Default Value:
1.0f
Parameters
valueScaling factor to set
void TerrainMaterialDef::setBevelTexture ( const QString value)

Sets the graphics root relative path to the bevel texture.

Parameters
valuePath to texture to set
void TerrainMaterialDef::setBlendMode ( BlendMode  value)

Returns the blend mode used to composite the bevel texture over the base texture.

See also
BlendMode
Parameters
valueBlendMode to use
Default Value:
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.

Note
This is used exclusively by the editor to generate the render mesh.
Parameters
valueOffset to set
Default Value:
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.

Note
This is used exclusively by the editor to generate the render mesh.
Default Value:
1.0f
Parameters
valueScaling factor to set
void TerrainMaterialDef::setEdgeTexture ( const QString value)

Sets the graphics root relative path to the edge texture.

Parameters
valuePath 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).

Note
This is used exclusively by the editor to generate the render mesh.
Parameters
valueWidth to set
Default Value:
0.0f
void TerrainMaterialDef::setName ( const QString value)

Sets the name of this material, used to identify it and look it up.

Parameters
valueName 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.

Parameters
valuetrue to treat the base texture as opaque
Default Value:
true
void TerrainMaterialDef::setTiled ( bool  value)

Sets whether or not the base texture should be tiled past the first instance.

Parameters
valuetrue to tile
Default Value:
true