-
Notifications
You must be signed in to change notification settings - Fork 0
/
vertex.glsl
52 lines (38 loc) · 1.07 KB
/
vertex.glsl
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
#version 330 core
layout (location = 0) in vec3 position;
layout (location = 1) in vec3 normal;
layout (location = 2) in vec2 texCoord;
layout (location = 3) in vec3 partCoord;
layout (location = 4) in vec4 partPosition;
layout (location = 5) in vec4 partColor;
uniform mat4 model;
uniform mat4 view;
uniform mat4 projection;
uniform mat4 normalModel;
uniform int objectType;
out vec3 Normal;
out vec3 FragPos;
out vec2 TexCoord;
out vec4 PartColor;
const int PARTICLE = 3;
const int BOUNDINGBOX = 4;
void main()
{
switch (objectType) {
case PARTICLE:
vec4 ppos = vec4(partCoord, 1.0) + partPosition;
gl_Position = projection * view * ppos;
PartColor = partColor;
TexCoord = texCoord;
break;
case BOUNDINGBOX:
gl_Position = projection * view * vec4(position, 1.0);
break;
default:
gl_Position = projection * view * model * vec4(position, 1.0);
Normal = mat3(normalModel)*normal;
FragPos = vec3(model * vec4(position, 1.0));
TexCoord = texCoord;
break;
}
}