CC3DProgramInfo.h
10.4 KB
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
#pragma once
#include "base/ccMacros.h"
#include "math/CCMath.h"
#include <unordered_map>
#include <vector>
NS_CC_BEGIN
namespace shaderinfos
{
enum class VertexKey :int {
/**Index 0 will be used as Position.*/
VERTEX_ATTRIB_POSITION = 0,
/**Index 1 will be used as Color.*/
VERTEX_ATTRIB_COLOR = 1,
/**Index 2 will be used as Tex coord unit 0.*/
VERTEX_ATTRIB_TEX_COORD = 2,
/**Index 3 will be used as Tex coord unit 1.*/
VERTEX_ATTRIB_TEX_COORD1 = 3,
/**Index 4 will be used as Tex coord unit 2.*/
VERTEX_ATTRIB_TEX_COORD2 = 4,
/**Index 5 will be used as Tex coord unit 3.*/
VERTEX_ATTRIB_TEX_COORD3 = 5,
/**Index 6 will be used as Normal.*/
VERTEX_ATTRIB_NORMAL = 6,
/**Index 7 will be used as Blend weight for hardware skin.*/
VERTEX_ATTRIB_BLEND_WEIGHT = 7,
/**Index 8 will be used as Blend index.*/
VERTEX_ATTRIB_BLEND_INDEX = 8,
/**Index 9 will be used as tangent.*/
VERTEX_ATTRIB_TANGENT = 9,
/**Index 10 will be used as Binormal.*/
VERTEX_ATTRIB_BINORMAL = 10,
VERTEX_ATTRIB_MAX = 11,
// backward compatibility
VERTEX_ATTRIB_TEX_COORDS = VERTEX_ATTRIB_TEX_COORD,
VERTEX_ATTRIB_ERROR = -1
};
/**Preallocated uniform handle.*/
enum class Uniformkey
{
/**Ambient color.*/
UNIFORM_AMBIENT_COLOR,
/**Projection matrix.*/
UNIFORM_P_MATRIX,
/**MultiView Projection matrix.*/
UNIFORM_MULTIVIEW_P_MATRIX,
/**Model view matrix.*/
UNIFORM_MV_MATRIX,
/**Model view projection matrix.*/
UNIFORM_MVP_MATRIX,
/**MultiView Model view projection matrix.*/
UNIFORM_MULTIVIEW_MVP_MATRIX,
/**Normal matrix.*/
UNIFORM_NORMAL_MATRIX,
/**Time.*/
UNIFORM_TIME,
/**sin(Time).*/
UNIFORM_SIN_TIME,
/**cos(Time).*/
UNIFORM_COS_TIME,
/**Random number.*/
UNIFORM_RANDOM01,
/** @{
* Sampler 0-3, used for texture.
*/
UNIFORM_SAMPLER0,
UNIFORM_SAMPLER1,
UNIFORM_SAMPLER2,
UNIFORM_SAMPLER3,
/**@}*/
UNIFORM_MAX,
};
namespace shader {
extern const char* SHADER_NAME_ETC1AS_POSITION_TEXTURE_COLOR;
extern const char* SHADER_NAME_ETC1AS_POSITION_TEXTURE_COLOR_NO_MVP;
extern const char* SHADER_NAME_ETC1AS_POSITION_TEXTURE_GRAY;
extern const char* SHADER_NAME_ETC1AS_POSITION_TEXTURE_GRAY_NO_MVP;
/**Built in shader for 2d. Support Position, Texture and Color vertex attribute.*/
extern const char* SHADER_NAME_POSITION_TEXTURE_COLOR;
/**Built in shader for 2d. Support Position, Texture and Color vertex attribute, but without multiply vertex by MVP matrix.*/
extern const char* SHADER_NAME_POSITION_TEXTURE_COLOR_NO_MVP;
/**Built in shader for 2d. Support Position, Texture vertex attribute, but include alpha test.*/
extern const char* SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST;
/**Built in shader for 2d. Support Position, Texture and Color vertex attribute, include alpha test and without multiply vertex by MVP matrix.*/
extern const char* SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST_NO_MV;
/**Built in shader for 2d. Support Position, Color vertex attribute.*/
extern const char* SHADER_NAME_POSITION_COLOR;
/**Built in shader for 2d. Support Position, Color, Texture vertex attribute. texture coordinate will used as point size.*/
extern const char* SHADER_NAME_POSITION_COLOR_TEXASPOINTSIZE;
/**Built in shader for 2d. Support Position, Color vertex attribute, without multiply vertex by MVP matrix.*/
extern const char* SHADER_NAME_POSITION_COLOR_NO_MVP;
/**Built in shader for 2d. Support Position, Texture vertex attribute.*/
extern const char* SHADER_NAME_POSITION_TEXTURE;
/**Built in shader for 2d. Support Position, Texture vertex attribute. with a specified uniform as color*/
extern const char* SHADER_NAME_POSITION_TEXTURE_U_COLOR;
/**Built in shader for 2d. Support Position, Texture and Color vertex attribute. but alpha will be the multiplication of color attribute and texture.*/
extern const char* SHADER_NAME_POSITION_TEXTURE_A8_COLOR;
/**Built in shader for 2d. Support Position, with color specified by a uniform.*/
extern const char* SHADER_NAME_POSITION_U_COLOR;
/**Built in shader for draw a sector with 90 degrees with center at bottom left point.*/
extern const char* SHADER_NAME_POSITION_LENGTH_TEXTURE_COLOR;
/**Built in shader for ui effects */
extern const char* SHADER_NAME_POSITION_GRAYSCALE;
/** @{
Built in shader for label and label with effects.
*/
extern const char* SHADER_NAME_LABEL_NORMAL;
extern const char* SHADER_NAME_LABEL_OUTLINE;
extern const char* SHADER_NAME_LABEL_DISTANCEFIELD_NORMAL;
extern const char* SHADER_NAME_LABEL_DISTANCEFIELD_GLOW;
/**Built in shader used for 3D, support Position vertex attribute, with color specified by a uniform.*/
extern const char* SHADER_3D_POSITION;
/**Built in shader used for 3D, support Position and Texture vertex attribute, with color specified by a uniform.*/
extern const char* SHADER_3D_POSITION_TEXTURE;
/**
Built in shader used for 3D, support Position (Skeletal animation by hardware skin) and Texture vertex attribute,
with color specified by a uniform.
*/
extern const char* SHADER_3D_SKINPOSITION_TEXTURE;
/**
Built in shader used for 3D, support Position and Normal vertex attribute, used in lighting. with color specified by a uniform.
*/
extern const char* SHADER_3D_POSITION_NORMAL;
/**
Built in shader used for 3D, support Position, Normal, Texture vertex attribute, used in lighting. with color specified by a uniform.
*/
extern const char* SHADER_3D_POSITION_NORMAL_TEXTURE;
/**
Built in shader used for 3D, support Position(skeletal animation by hardware skin), Normal, Texture vertex attribute,
used in lighting. with color specified by a uniform.
*/
extern const char* SHADER_3D_SKINPOSITION_NORMAL_TEXTURE;
/**
Built in shader used for 3D, support Position, Bumped Normal, Texture vertex attribute, used in lighting. with color specified by a uniform.
*/
extern const char* SHADER_3D_POSITION_BUMPEDNORMAL_TEXTURE;
/**
Built in shader used for 3D, support Position(skeletal animation by hardware skin), Bumped Normal, Texture vertex attribute,
used in lighting. with color specified by a uniform.
*/
extern const char* SHADER_3D_SKINPOSITION_BUMPEDNORMAL_TEXTURE;
/**
Built in shader for particles, support Position and Texture, with a color specified by a uniform.
*/
extern const char* SHADER_3D_PARTICLE_TEXTURE;
/**
Built in shader for particles, support Position, with a color specified by a uniform.
*/
extern const char* SHADER_3D_PARTICLE_COLOR;
/**
Built in shader for skybox
*/
extern const char* SHADER_3D_SKYBOX;
/**
Built in shader for terrain
*/
extern const char* SHADER_3D_TERRAIN;
/**
Built in shader for LayerRadialGradient
*/
extern const char* SHADER_LAYER_RADIAL_GRADIENT;
/**
Built in shader for camera clear
*/
extern const char* SHADER_CAMERA_CLEAR;
/**
end of built shader types.
@}
*/
}
namespace uniform {
/**
@name Built uniform names
@{
*/
/**Ambient Color uniform.*/
extern const char* UNIFORM_NAME_AMBIENT_COLOR;
/**Projection Matrix uniform.*/
extern const char* UNIFORM_NAME_P_MATRIX;
/**MultiView Projection Matrix uniform.*/
extern const char* UNIFORM_NAME_MULTIVIEW_P_MATRIX;
/**Model view matrix uniform.*/
extern const char* UNIFORM_NAME_MV_MATRIX;
/**Model view projection uniform.*/
extern const char* UNIFORM_NAME_MVP_MATRIX;
/**MultiView Model view projection uniform.*/
extern const char* UNIFORM_NAME_MULTIVIEW_MVP_MATRIX;
/**Normal matrix uniform.*/
extern const char* UNIFORM_NAME_NORMAL_MATRIX;
/**Time uniform.*/
extern const char* UNIFORM_NAME_TIME;
/**Sin time uniform.*/
extern const char* UNIFORM_NAME_SIN_TIME;
/**Cos time uniform.*/
extern const char* UNIFORM_NAME_COS_TIME;
/**Random number uniform.*/
extern const char* UNIFORM_NAME_RANDOM01;
/**
@{ Sampler uniform 0-3, used for textures.
*/
extern const char* UNIFORM_NAME_SAMPLER0;
extern const char* UNIFORM_NAME_SAMPLER1;
extern const char* UNIFORM_NAME_SAMPLER2;
extern const char* UNIFORM_NAME_SAMPLER3;
/**
@}
*/
/**Alpha test value uniform.*/
extern const char* UNIFORM_NAME_ALPHA_TEST_VALUE;
/**
end of Built uniform names
@}
*/
}
namespace attribute {
/**
@name Built Attribute names
@{
*/
/**Attribute color.*/
extern const char* ATTRIBUTE_NAME_COLOR;
/**Attribute position.*/
extern const char* ATTRIBUTE_NAME_POSITION;
/**@{ Attribute Texcoord 0-3.*/
extern const char* ATTRIBUTE_NAME_TEX_COORD;
extern const char* ATTRIBUTE_NAME_TEX_COORD1;
extern const char* ATTRIBUTE_NAME_TEX_COORD2;
extern const char* ATTRIBUTE_NAME_TEX_COORD3;
/**@}*/
/**Attribute normal.*/
extern const char* ATTRIBUTE_NAME_NORMAL;
/**Attribute blend weight.*/
extern const char* ATTRIBUTE_NAME_BLEND_WEIGHT;
/**Attribute blend index.*/
extern const char* ATTRIBUTE_NAME_BLEND_INDEX;
/**Attribute blend tangent.*/
extern const char* ATTRIBUTE_NAME_TANGENT;
/**Attribute blend binormal.*/
extern const char* ATTRIBUTE_NAME_BINORMAL;
/**
end of Built Attribute names
@}
*/
}
const std::vector<std::pair<const char *, VertexKey>>& getPredefinedAttributes();
const std::string getAttributeName(const VertexKey &key);
};
NS_CC_END