-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathterrainmaterial.cpp
65 lines (50 loc) · 1.17 KB
/
terrainmaterial.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include "terrainmaterial.h"
#include "texture.h"
#include "drawcontext.h"
#include "shadercache.h"
TerrainMaterial::TerrainMaterial()
{
shader_ = ShaderCache::getInstance()->acquire("terrain");
}
void TerrainMaterial::apply(DrawContext &context)
{
assert(heightMap_);
assert(diffuseMap_);
Material::apply(context);
shader_->setUniformValue("ambient", ambient_);
shader_->setUniformValue("heightScale", heightScale_);
heightMap_->apply(context, "heightMap", 0);
diffuseMap_->apply(context, "diffuseMap", 1);
}
Texture *TerrainMaterial::diffuseMap() const
{
return diffuseMap_;
}
void TerrainMaterial::setDiffuseMap(Texture *diffuseMap)
{
diffuseMap_ = diffuseMap;
}
Texture *TerrainMaterial::heightMap() const
{
return heightMap_;
}
void TerrainMaterial::setHeightMap(Texture *heightMap)
{
heightMap_ = heightMap;
}
const Color &TerrainMaterial::ambient() const
{
return ambient_;
}
void TerrainMaterial::setAmbient(const Color &ambient)
{
ambient_ = ambient;
}
float TerrainMaterial::heightScale() const
{
return heightScale_;
}
void TerrainMaterial::setHeightScale(float value)
{
heightScale_ = value;
}