-
Notifications
You must be signed in to change notification settings - Fork 0
/
Draw.vertex
47 lines (39 loc) · 1.18 KB
/
Draw.vertex
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
#version 330 core
const uint MAX_LIGHTS = 1u;
uniform uint numLights = 1u;
uniform mat4 camera = mat4(1.0f);
uniform mat4 projection = mat4(1.0f);
uniform mat4 vTrans = mat4(1.0f);
uniform mat4 nSkew = mat4(1.0f);
uniform mat4 shadowMatrix = mat4(1.0f);
//These uniform ints are used as boolean values that specify
//functionality in the shaders. In this way, shading models can
//be switched without having to change the entire shading program.
uniform uint isInside = 0u;
uniform uint isSun = 0u;
layout(location = 0) in vec4 vPosition;
layout(location = 1) in vec4 vColor;
layout(location = 2) in vec4 vNormal;
out Interface {
vec3 global; //coordinates
vec3 viewer; //coordinates
vec4 shadow; //coordinates
vec3 color;
vec3 normal;
} vertex;
void main() {
vec4 tempVec = vTrans * vPosition;
vertex.global = tempVec.xyz;
if ( ! bool(isSun) ) { //if not sun
vertex.shadow = shadowMatrix * tempVec;
vertex.color = vColor.rgb;
vertex.normal = normalize( (nSkew * vNormal).xyz );
} else { //if sun
vertex.shadow = vec4(0.0f);
vertex.color = vColor.rgb;
vertex.normal = vec3(0.0f);
}
tempVec = camera * tempVec;
vertex.viewer = tempVec.xyz;
gl_Position = projection * tempVec;
}