shaderarrayv.glsl revision e5f2f66f8c802d64ecf869081036ae13d4e9e19c
1varying float light0_Diffuse;
2varying float light0_Specular;
3varying float light1_Diffuse;
4varying float light1_Specular;
5varying vec2 varTex0;
6
7// This is where actual shader code begins
8void main() {
9   vec4 worldPos = UNI_model[0] * ATTRIB_position;
10   worldPos = UNI_model[1] * worldPos;
11   gl_Position = UNI_proj * worldPos;
12
13   mat4 model0 = UNI_model[0];
14   mat3 model3 = mat3(model0[0].xyz, model0[1].xyz, model0[2].xyz);
15   vec3 worldNorm = model3 * ATTRIB_normal;
16   vec3 V = normalize(-worldPos.xyz);
17
18   vec3 light0Vec = normalize(UNI_light_Posision[0].xyz - worldPos.xyz);
19   vec3 light0R = -reflect(light0Vec, worldNorm);
20   light0_Diffuse = clamp(dot(worldNorm, light0Vec), 0.0, 1.0) * UNI_light_Diffuse[0];
21   float light0Spec = clamp(dot(light0R, V), 0.001, 1.0);
22   light0_Specular = pow(light0Spec, UNI_light_CosinePower[0]) * UNI_light_Specular[0];
23
24   vec3 light1Vec = normalize(UNI_light_Posision[1].xyz - worldPos.xyz);
25   vec3 light1R = reflect(light1Vec, worldNorm);
26   light1_Diffuse = clamp(dot(worldNorm, light1Vec), 0.0, 1.0) * UNI_light_Diffuse[1];
27   float light1Spec = clamp(dot(light1R, V), 0.001, 1.0);
28   light1_Specular = pow(light1Spec, UNI_light_CosinePower[1]) * UNI_light_Specular[1];
29
30   gl_PointSize = 1.0;
31   varTex0 = ATTRIB_texture0;
32}
33