mercator  0.4.0
A terrain generation library for the Worldforge system.
Mercator::GrassShader Class Reference

Shader for adding grass to the terrain. More...

#include <GrassShader.h>

Inheritance diagram for Mercator::GrassShader:
Collaboration diagram for Mercator::GrassShader:

Public Types

typedef std::map< std::string, float > Parameters
 STL map of parameter values for a shader constructor. More...
 

Public Member Functions

 GrassShader (float lowThreshold=default_lowThreshold, float highThreshold=default_highThreshold, float cutoff=default_cutoff, float intercept=default_intercept)
 Constructor. More...
 
 GrassShader (const Parameters &params)
 Constructor. More...
 
float lowThreshold () const
 Accessor for level above which the shader renders. More...
 
float highThreshold () const
 Accessor for level below which the shader renders. More...
 
float cutoff () const
 Accessor for slope below which grass is opaque. More...
 
float intercept () const
 Accessor for slope steeper than which no grass grows. More...
 
bool checkIntersect (const Segment &) const override
 Check whether this Shader has any effect on the given Segment. More...
 
void shade (Surface &) const override
 Populate a Surface with data. More...
 
bool getColor () const
 Accessor for color flag. More...
 
bool getAlpha () const
 Accessor for alpha flag. More...
 
std::unique_ptr< SurfacenewSurface (const Segment &) const
 Create a new Surface which matches the requirements of this shader. More...
 

Static Public Attributes

static const std::string key_lowThreshold
 Key string used when specifying the low threshold parameter. More...
 
static const std::string key_highThreshold
 Key string used when specifying the high threshold parameter. More...
 
static const std::string key_cutoff
 Key string used when specifying the cutoff parameter. More...
 
static const std::string key_intercept
 Key string used when specifying the intercept parameter. More...
 
static const float default_lowThreshold = 1.f
 Default level above which the shader renders. More...
 
static const float default_highThreshold = 20.f
 Default level below which the shader renders. More...
 
static const float default_cutoff = 1.f
 Default slope below which grass is opaque. More...
 
static const float default_intercept = 2.f
 Default slope steeper than which no grass grows. More...
 

Detailed Description

Shader for adding grass to the terrain.

This shader is used to add grassy vegetation to some terrain. The mask generated by this shader depends on two factors. The altitude of the terrain, and its slope. Two parameter specify the low and high altitude values between which vegetation grows. The low value will typically be just above sea level, and the high value could be anything up to the height above which plants cannot grow.

Definition at line 50 of file GrassShader.h.

Member Typedef Documentation

◆ Parameters

typedef std::map<std::string, float> Mercator::Shader::Parameters
inherited

STL map of parameter values for a shader constructor.

Definition at line 59 of file Shader.h.

Constructor & Destructor Documentation

◆ GrassShader() [1/2]

Mercator::GrassShader::GrassShader ( float  lowThreshold = default_lowThreshold,
float  highThreshold = default_highThreshold,
float  cutoff = default_cutoff,
float  intercept = default_intercept 
)
explicit

Constructor.

Parameters
lowThresholdlevel above which the shader renders.
highThresholdlevel above which the shader renders.
cutoffslope below which grass is opaque.
interceptslope steeper than which no grass grows.

Definition at line 30 of file GrassShader.cpp.

◆ GrassShader() [2/2]

Mercator::GrassShader::GrassShader ( const Parameters params)
explicit

Constructor.

Parameters
paramsa map of parameters for the shader.

Definition at line 37 of file GrassShader.cpp.

References key_cutoff, key_highThreshold, key_intercept, and key_lowThreshold.

Member Function Documentation

◆ checkIntersect()

bool Mercator::GrassShader::checkIntersect ( const Segment ) const
overridevirtual

Check whether this Shader has any effect on the given Segment.

Returns
true if the given Segment height range is within the range that this Shader uses. e.g. A high altitude snow shader will have no effect on low level terrain.

Implements Mercator::Shader.

Definition at line 78 of file GrassShader.cpp.

References Mercator::Segment::getMax(), and Mercator::Segment::getMin().

◆ cutoff()

float Mercator::GrassShader::cutoff ( ) const
inline

Accessor for slope below which grass is opaque.

Definition at line 108 of file GrassShader.h.

◆ getAlpha()

bool Mercator::Shader::getAlpha ( ) const
inlineinherited

Accessor for alpha flag.

Definition at line 42 of file Shader.h.

◆ getColor()

bool Mercator::Shader::getColor ( ) const
inlineinherited

Accessor for color flag.

Definition at line 37 of file Shader.h.

◆ highThreshold()

float Mercator::GrassShader::highThreshold ( ) const
inline

Accessor for level below which the shader renders.

Definition at line 106 of file GrassShader.h.

◆ intercept()

float Mercator::GrassShader::intercept ( ) const
inline

Accessor for slope steeper than which no grass grows.

Definition at line 110 of file GrassShader.h.

◆ lowThreshold()

float Mercator::GrassShader::lowThreshold ( ) const
inline

Accessor for level above which the shader renders.

Definition at line 104 of file GrassShader.h.

◆ newSurface()

std::unique_ptr< Surface > Mercator::Shader::newSurface ( const Segment segment) const
inherited

Create a new Surface which matches the requirements of this shader.

Called by terrain when creating a new Segment to add the necessary Surface objects to that Segment.

Definition at line 27 of file Shader.cpp.

Referenced by Mercator::Terrain::addShader().

◆ shade()

Member Data Documentation

◆ default_cutoff

const float Mercator::GrassShader::default_cutoff = 1.f
static

Default slope below which grass is opaque.

Definition at line 83 of file GrassShader.h.

◆ default_highThreshold

const float Mercator::GrassShader::default_highThreshold = 20.f
static

Default level below which the shader renders.

Definition at line 81 of file GrassShader.h.

◆ default_intercept

const float Mercator::GrassShader::default_intercept = 2.f
static

Default slope steeper than which no grass grows.

Definition at line 85 of file GrassShader.h.

◆ default_lowThreshold

const float Mercator::GrassShader::default_lowThreshold = 1.f
static

Default level above which the shader renders.

Definition at line 79 of file GrassShader.h.

◆ key_cutoff

const std::string Mercator::GrassShader::key_cutoff
static

Key string used when specifying the cutoff parameter.

Definition at line 74 of file GrassShader.h.

Referenced by GrassShader().

◆ key_highThreshold

const std::string Mercator::GrassShader::key_highThreshold
static

Key string used when specifying the high threshold parameter.

Definition at line 72 of file GrassShader.h.

Referenced by GrassShader().

◆ key_intercept

const std::string Mercator::GrassShader::key_intercept
static

Key string used when specifying the intercept parameter.

Definition at line 76 of file GrassShader.h.

Referenced by GrassShader().

◆ key_lowThreshold

const std::string Mercator::GrassShader::key_lowThreshold
static

Key string used when specifying the low threshold parameter.

Definition at line 70 of file GrassShader.h.

Referenced by GrassShader().


The documentation for this class was generated from the following files: