This repository was archived by the owner on Sep 11, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtexture.vert
More file actions
executable file
·61 lines (46 loc) · 1.44 KB
/
Copy pathtexture.vert
File metadata and controls
executable file
·61 lines (46 loc) · 1.44 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
#version 330 compatibility
uniform float ambient, diffuse, spectral, shininess, light_x, light_y, light_z;
uniform vec4 surface_color, specular_color;
flat out vec3 vNf;
out vec3 vNs;
flat out vec3 vLf;
out vec3 vLs;
flat out vec3 vEf;
out vec3 vEs;
flat out vec3 vPVf;
out vec3 vPVs;
out vec3 MCposition;
out vec2 vST;
void main() {
vec3 Normal;
vec3 Light;
vec3 Eye;
vST = gl_MultiTexCoord0.st;
MCposition = gl_Vertex.xyz;
vec4 ECposition = uModelViewMatrix * vec4(MCposition, 1.);
vec3 eyeLightPosition = vec3(light_x, light_y, light_z);
// Normal Calc
vec3 normal = aNormal;
// End Normal
vNs = normalize(uNormalMatrix * normal); // surface normal vector
vNf = vNs;
vLs = eyeLightPosition - ECposition.xyz; // vector from the point
vLf = vLs;
vEs = vec3(0., 0., 0.) - ECposition.xyz; // vector from the point
vEf = vEs;
Normal = normalize(vNs);
Light = normalize(vLs);
Eye = normalize(vEs);
vec4 ambient = ambient * surface_color;
float d = max(dot(Normal, Light), 0.);
vec4 diffuse = diffuse * d * surface_color;
float s = 0.;
if (dot(Normal, Light) > 0.) { // only do specular if the light can see the point
vec3 ref = normalize(2. * Normal * dot(Normal, Light) - Light);
s = pow(max(dot(Eye, ref), 0.), shininess);
}
vec4 specular = spectral * s * specular_color;
vPVs = ambient.rgb + diffuse.rgb + specular.rgb;
vPVf = vPVs;
gl_Position = uModelViewProjectionMatrix * vec4(MCposition, 1.);
}