-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparticlematerial.cpp
80 lines (57 loc) · 1.37 KB
/
particlematerial.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
62
63
64
65
66
67
68
69
70
71
72
#include "particlematerial.h"
#include "shader.h"
#include "shadercache.h"
#include "drawcontext.h"
#include "texture.h"
ParticleMaterial::ParticleMaterial()
{
shader_ = ShaderCache::getInstance()->acquire("particle");
}
void ParticleMaterial::apply(DrawContext &context)
{
assert(texture_);
Material::apply(context);
shader_->setUniformValue("lengthScale", lengthScale_);
shader_->setUniformValue("horizontal", horizontal_);
mat4 slopeMatrix;
slopeMatrix.rotate(slope_, {1, 0, 0});
shader_->setUniformValue("slope", slopeMatrix);
texture_->apply(context, "map", 0);
//glDisable(GL_DEPTH_TEST);
glDepthMask(GL_FALSE);
glDisable(GL_CULL_FACE);
}
void ParticleMaterial::endRender()
{
//glEnable(GL_DEPTH_TEST);
glDepthMask(GL_TRUE);
glEnable(GL_CULL_FACE);
}
void ParticleMaterial::setTexture(Texture *texture)
{
texture_ = texture;
}
float ParticleMaterial::lengthScale() const
{
return lengthScale_;
}
void ParticleMaterial::setLengthScale(float lengthScale)
{
lengthScale_ = lengthScale;
}
float ParticleMaterial::slope() const
{
return slope_;
}
void ParticleMaterial::setSlope(float slope)
{
slope_ = slope;
}
bool ParticleMaterial::horizontal() const
{
return horizontal_;
}
void ParticleMaterial::setHorizontal(bool horizontal)
{
horizontal_ = horizontal;
}