Mercator
Main Page
Classes
Files
File List
Mercator
GrassShader.h
1
// This file may be redistributed and modified only under the terms of
2
// the GNU General Public License (See COPYING for details).
3
// Copyright (C) 2003 Alistair Riddoch
4
5
#ifndef MERCATOR_FILL_GRASS_SHADER_H
6
#define MERCATOR_FILL_GRASS_SHADER_H
7
8
#include <Mercator/Shader.h>
9
#include <Mercator/Surface.h>
10
11
/* alpha ^
12
* |
13
* 1 |_______________________ cutoff
14
* | \
15
* | \
16
* | \
17
* | \
18
* | \
19
* | \
20
* | \
21
* | \
22
* | \
23
* | \ intercept
24
* 0 |_________________________________\_________________________> slope
25
*
26
* This shader is used to add grassy vegetation to some terrain.
27
* The mask generated by this shader depends on two factors. The altitude
28
* of the terrain, and its slope. Two parameter specify the low and high
29
* altitude values between which vegetation grows. The low value will typically
30
* be just above sea level, and the high value could be anything up to the
31
* height above which plants cannot grow.
32
*
33
* The cutoff parameter specifies the slope below which the vegetation is
34
* completely opaque. The intercept parameter specifies the slope above which
35
* vegetetation will not grow on the terrain. Between these values the
36
* vegetation is blended onto the terrain to give an impression of a light
37
* covering.
38
*/
39
40
namespace
Mercator {
41
50
class
GrassShader
:
public
Shader
{
51
private
:
53
float
m_lowThreshold
;
55
float
m_highThreshold
;
57
float
m_cutoff
;
59
float
m_intercept
;
60
67
ColorT
slopeToAlpha
(
float
height,
float
slope)
const
;
68
public
:
70
static
const
std::string
key_lowThreshold
;
72
static
const
std::string
key_highThreshold
;
74
static
const
std::string
key_cutoff
;
76
static
const
std::string
key_intercept
;
77
79
static
const
float
default_lowThreshold
;
81
static
const
float
default_highThreshold
;
83
static
const
float
default_cutoff
;
85
static
const
float
default_intercept
;
86
93
explicit
GrassShader
(
float
lowThreshold
=
default_lowThreshold
,
94
float
highThreshold
=
default_highThreshold
,
95
float
cutoff
=
default_cutoff
,
96
float
intercept
=
default_intercept
);
100
explicit
GrassShader
(
const
Parameters
& params);
101
virtual
~
GrassShader
();
102
104
const
float
lowThreshold
()
const
{
return
m_lowThreshold
; }
106
const
float
highThreshold
()
const
{
return
m_highThreshold
; }
108
const
float
cutoff
()
const
{
return
m_cutoff
; }
110
const
float
intercept
()
const
{
return
m_intercept
; }
111
112
virtual
bool
checkIntersect
(
const
Segment
&)
const
;
113
virtual
void
shade
(
Surface
&)
const
;
114
};
115
116
}
// namespace Mercator
117
118
#endif // MERCATOR_FILL_GRASS_SHADER_H
Generated by
1.8.1.1