-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
base.vert
79 lines (55 loc) · 1.51 KB
/
base.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
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
/*
(C) 2019 David Lettier
lettier.com
*/
#version 150
#define NUMBER_OF_LIGHTS 4
uniform mat4 p3d_ModelViewMatrix;
uniform mat4 p3d_ProjectionMatrix;
uniform mat3 p3d_NormalMatrix;
uniform struct p3d_LightSourceParameters
{ vec4 color
; vec4 ambient
; vec4 diffuse
; vec4 specular
; vec4 position
; vec3 spotDirection
; float spotExponent
; float spotCutoff
; float spotCosCutoff
; float constantAttenuation
; float linearAttenuation
; float quadraticAttenuation
; vec3 attenuation
; sampler2DShadow shadowMap
; mat4 shadowViewMatrix
;
} p3d_LightSource[NUMBER_OF_LIGHTS];
in vec4 p3d_Vertex;
in vec3 p3d_Normal;
in vec4 p3d_Color;
in vec2 p3d_MultiTexCoord0;
in vec2 p3d_MultiTexCoord1;
in vec3 p3d_Binormal;
in vec3 p3d_Tangent;
out vec4 vertexPosition;
out vec4 vertexColor;
out vec3 vertexNormal;
out vec3 binormal;
out vec3 tangent;
out vec2 normalCoord;
out vec2 diffuseCoord;
out vec4 vertexInShadowSpaces[NUMBER_OF_LIGHTS];
void main() {
vertexColor = p3d_Color;
vertexPosition = p3d_ModelViewMatrix * p3d_Vertex;
vertexNormal = normalize(p3d_NormalMatrix * p3d_Normal);
binormal = normalize(p3d_NormalMatrix * p3d_Binormal);
tangent = normalize(p3d_NormalMatrix * p3d_Tangent);
normalCoord = p3d_MultiTexCoord0;
diffuseCoord = p3d_MultiTexCoord1;
for (int i = 0; i < p3d_LightSource.length(); ++i) {
vertexInShadowSpaces[i] = p3d_LightSource[i].shadowViewMatrix * vertexPosition;
}
gl_Position = p3d_ProjectionMatrix * vertexPosition;
}