-
Notifications
You must be signed in to change notification settings - Fork 0
/
vshader.glsl~
57 lines (41 loc) · 1.39 KB
/
vshader.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
52
53
54
55
56
57
attribute vec4 vPosition;
//set up to pass color to fshader.
attribute vec4 vColor;
varying vec4 fColor;
attribute vec4 vNormal;
uniform vec4 LightPosition;
uniform float Shininess;
uniform vec4 AmbientProduct, DiffuseProduct, SpecularProduct;
uniform mat4 p; //projection view matrix
uniform mat4 mv; //model view matrix
uniform mat4 RD;
uniform float scale; //the scale
uniform vec2 pos; //the location of circle
void main()
{
vec4 ambient, diffuse, specular;
vec3 L,E;
//these have to be in column major order.
mat4 S = mat4(scale, 0.0, 0.0, 0.0,
0.0, scale, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0,
0.0, 0.0, 0.0, 1.0);
mat4 T = mat4(1.0, 0.0, 0.0, 0.0,
0.0, 1.0, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0,
pos.x, pos.y, 0.0, 1.0);
gl_Position = p * mv * RD*vPosition;
vec3 N = normalize(vNormal.xyz);
L = normalize(LightPosition.xyz - (mv*vPosition).xyz);
E = -normalize((mv*vPosition).xyz);
vec3 H = normalize(L+E);
float Kd = max(dot(L, N), 0.0);
float Ks = pow(max(dot(N, H), 0.0), Shininess);
ambient = vColor;
diffuse = Kd*DiffuseProduct;
specular = max(pow(max(dot(N, H), 0.0), Shininess)*SpecularProduct, 0.0);
//if(LightPosition.z >=-7)
fColor = vec4((ambient + diffuse + specular).xyz, 1.0);
// else
//fColor = vColor;
}