/
CShader.h
147 lines (100 loc) · 2.92 KB
/
CShader.h
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#pragma once
#include "ShaderDefinition.h"
#include <memory>
namespace shaders {
/**
* \brief
* Implementation class for Material.
*/
class CShader
: public Material
{
private:
ShaderTemplatePtr _template;
// The shader file name (i.e. the file where this one is defined)
vfs::FileInfo _fileInfo;
// Name of shader
std::string _name;
// The 2D editor texture
TexturePtr _editorTexture;
TexturePtr _texLightFalloff;
bool m_bInUse;
bool _visible;
// Vector of shader layers
ShaderLayerVector _layers;
public:
static bool m_lightingEnabled;
/*
* Constructor. Sets the name and the ShaderDefinition to use.
*/
CShader(const std::string& name, const ShaderDefinition& definition);
~CShader();
/* Material implementation */
int getSortRequest() const;
float getPolygonOffset() const;
TexturePtr getEditorImage();
bool isEditorImageNoTex();
// Return the light falloff texture (Z dimension).
TexturePtr lightFalloffImage();
/**
* Return the name of the light falloff texture for use with this shader.
* Shaders which do not define their own falloff will take the default from
* the defaultPointLight shader.
*/
std::string getFalloffName() const;
/*
* Return name of shader.
*/
std::string getName() const;
bool IsInUse() const;
void SetInUse(bool bInUse);
// get the shader flags
int getMaterialFlags() const;
// test if it's a true shader, or a default shader created to wrap around a texture
bool IsDefault() const;
// get the cull type
CullType getCullType() const;
// Clamp type
ClampType getClampType() const;
int getSurfaceFlags() const;
SurfaceType getSurfaceType() const;
// Deform types
DeformType getDeformType() const;
// Get the spectrum, -1 is "not defined"
int getSpectrum() const;
const DecalInfo& getDecalInfo() const;
Coverage getCoverage() const;
// get shader file name (ie the file where this one is defined)
const char* getShaderFileName() const;
const vfs::FileInfo& getShaderFileInfo() const override;
// Returns the description string of this material
std::string getDescription() const;
// returns the raw definition block
std::string getDefinition();
// -----------------------------------------
void realise();
void unrealise();
// Parse and load image maps for this shader
void realiseLighting();
void unrealiseLighting();
/*
* Set name of shader.
*/
void setName(const std::string& name);
ShaderLayer* firstLayer() const;
/* Material implementation */
const ShaderLayerVector& getAllLayers() const;
bool isAmbientLight() const;
bool isBlendLight() const;
bool isFogLight() const;
bool isCubicLight() const;
bool lightCastsShadows() const;
bool surfaceCastsShadow() const;
bool isDrawn() const;
bool isDiscrete() const;
bool isVisible() const;
void setVisible(bool visible);
int getParseFlags() const override;
}; // class CShader
typedef std::shared_ptr<CShader> CShaderPtr;
} // namespace shaders