11#include "DepthShader.h"
30 m_waterLevel(waterLevel), m_murkyDepth(murkyDepth)
35 m_waterLevel(default_waterLevel), m_murkyDepth(default_murkyDepth)
38 auto Iend = params.end();
40 m_waterLevel = I->second;
44 m_murkyDepth = I->second;
48DepthShader::~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)));
DataType * getData()
Accessor for a pointer to buffer containing data values.
unsigned int getChannels() const
Accessor for the number of data values per height point.
static const float default_murkyDepth
Default depth at which the bottom becomes completely obscured.
static const std::string key_murkyDepth
Key string used when specifying the murky depth parameter.
void shade(Surface &) const override
Populate a Surface with data.
bool checkIntersect(const Segment &) const override
Check whether this Shader has any effect on the given Segment.
DepthShader(float waterLevel=default_waterLevel, float murkyDepth=default_murkyDepth)
Constructor.
static const std::string key_waterLevel
Key string used when specifying the water level parameter.
static const float default_waterLevel
Default level of the surface of the water.
Class storing heightfield and other data for a single fixed size square area of terrain defined by fo...
int getSize() const
Accessor for array size of this segment.
float getMin() const
Accessor for the minimum height value in this Segment.
const float * getPoints() const
Accessor for buffer containing height points.
std::map< std::string, float > Parameters
STL map of parameter values for a shader constructor.
Data store for terrain surface data.
const Segment & getSegment() const
Accessor for the terrain height segment this surface is associated with.