11 #include "DepthShader.h" 30 m_waterLevel(waterLevel), m_murkyDepth(murkyDepth)
38 auto Iend = params.end();
40 m_waterLevel = I->second;
44 m_murkyDepth = I->second;
48 DepthShader::~DepthShader() =
default;
52 if (s.
getMin() < m_waterLevel) {
63 unsigned int colors = channels - 1;
66 if (height_data == 0) {
67 std::cerr <<
"WARNING: Mercator: Attempting to shade empty segment." 68 << std::endl << std::flush;
73 unsigned int count = size * size;
75 for (
unsigned int i = 0; i < count; ++i) {
76 for (
unsigned int k = 0; k < colors; ++k) {
79 float depth = height_data[i];
80 if (depth > m_waterLevel) {
82 }
else if (depth < m_murkyDepth) {
85 data[++j] = colorMax - I_ROUND(colorMax * ((depth - m_murkyDepth)
86 / (m_waterLevel - m_murkyDepth)));
static const float default_murkyDepth
Default depth at which the bottom becomes completely obscured.
DataType * getData()
Accessor for a pointer to buffer containing data values.
Data store for terrain surface data.
static const std::string key_murkyDepth
Key string used when specifying the murky depth parameter.
int getSize() const
Accessor for array size of this segment.
std::map< std::string, float > Parameters
STL map of parameter values for a shader constructor.
DepthShader(float waterLevel=default_waterLevel, float murkyDepth=default_murkyDepth)
Constructor.
Class storing heightfield and other data for a single fixed size square area of terrain defined by fo...
void shade(Surface &) const override
Populate a Surface with data.
float getMin() const
Accessor for the minimum height value in this Segment.
static const float default_waterLevel
Default level of the surface of the water.
const float * getPoints() const
Accessor for buffer containing height points.
static const std::string key_waterLevel
Key string used when specifying the water level parameter.
unsigned int getChannels() const
Accessor for the number of data values per height point.
bool checkIntersect(const Segment &) const override
Check whether this Shader has any effect on the given Segment.
const Segment & getSegment() const
Accessor for the terrain height segment this surface is associated with.