Mercator::GrassShader Class Reference

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

#include <GrassShader.h>

Inheritance diagram for Mercator::GrassShader:

Mercator::Shader

List of all members.

Public Member Functions

 GrassShader (float lowThreshold=default_lowThreshold, float highThreshold=default_highThreshold, float cutoff=default_cutoff, float intercept=default_intercept)
 Constructor.
 GrassShader (const Parameters &params)
 Constructor.
const float lowThreshold () const
 Accessor for level above which the shader renders.
const float highThreshold () const
 Accessor for level below which the shader renders.
const float cutoff () const
 Accessor for slope below which grass is opaque.
const float intercept () const
 Accessor for slope steeper than which no grass grows.
virtual bool checkIntersect (const Segment &) const
 Check whether this Shader has any effect on the given Segment.
virtual void shade (Surface &) const
 Populate a Surface with data.

Static Public Attributes

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

Private Member Functions

ColorT slopeToAlpha (float height, float slope) const
 Determine the alpha value for grass for a given slope.

Private Attributes

float m_lowThreshold
 The level above which the shader renders.
float m_highThreshold
 The level below which the shader renders.
float m_cutoff
 The slope below which grass is opaque.
float m_intercept
 The slope steeper than which no grass grows.


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.


Constructor & Destructor Documentation

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

Constructor.

Parameters:
lowThreshold level above which the shader renders.
highThreshold level above which the shader renders.
cutoff slope below which grass is opaque.
intercept slope steeper than which no grass grows.

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

Constructor.

Parameters:
params a map of parameters for the shader.

References key_cutoff, key_highThreshold, key_intercept, key_lowThreshold, m_cutoff, m_highThreshold, m_intercept, and m_lowThreshold.


Member Function Documentation

ColorT Mercator::GrassShader::slopeToAlpha ( float  height,
float  slope 
) const [inline, private]

Determine the alpha value for grass for a given slope.

Determine the alpha value used when applying grass to the terrain at a point with given height and average slope.

Parameters:
height the altitude of the specified point.
slope the steepness of the terrain at the specified point.

References m_cutoff, m_highThreshold, m_intercept, and m_lowThreshold.

Referenced by shade().

bool Mercator::GrassShader::checkIntersect ( const Segment  )  const [virtual]

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.

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


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

Generated for Mercator by  doxygen 1.5.6