-
Notifications
You must be signed in to change notification settings - Fork 139
/
Copy pathExample.450core.vert
49 lines (39 loc) · 938 Bytes
/
Example.450core.vert
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
// GLSL vertex shader
#version 450 core
layout(std140, binding = 2) uniform Settings
{
mat4 vpMatrix;
vec4 viewPos;
vec4 fogColorAndDensity;
vec2 animVec;
};
// Per-vertex attributes
layout(location = 0) in vec3 position;
layout(location = 1) in vec2 texCoord;
// Per-instance attributes
layout(location = 2) in vec3 color;
layout(location = 3) in float arrayLayer;
layout(location = 4) in mat4 wMatrix;
// Vertex output to the fragment shader
layout(location = 0) out vec4 vWorldPos;
layout(location = 1) out vec3 vTexCoord;
layout(location = 2) out vec3 vColor;
out gl_PerVertex
{
vec4 gl_Position;
};
// Vertex shader main function
void main()
{
vec2 offset = animVec * position.y;
vec4 coord = vec4(
position.x + offset.x,
position.y,
position.z + offset.y,
1.0
);
vWorldPos = wMatrix * coord;
gl_Position = vpMatrix * vWorldPos;
vTexCoord = vec3(texCoord, arrayLayer);
vColor = color;
}