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 * ATTRIB_position; 10 gl_Position = UNI_proj * worldPos; 11 12 mat3 model3 = mat3(UNI_model[0].xyz, UNI_model[1].xyz, UNI_model[2].xyz); 13 vec3 worldNorm = model3 * ATTRIB_normal; 14 vec3 V = normalize(-worldPos.xyz); 15 16 vec3 light0Vec = normalize(UNI_light0_Posision.xyz - worldPos.xyz); 17 vec3 light0R = -reflect(light0Vec, worldNorm); 18 light0_Diffuse = clamp(dot(worldNorm, light0Vec), 0.0, 1.0) * UNI_light0_Diffuse; 19 float light0Spec = clamp(dot(light0R, V), 0.001, 1.0); 20 light0_Specular = pow(light0Spec, UNI_light0_CosinePower) * UNI_light0_Specular; 21 22 vec3 light1Vec = normalize(UNI_light1_Posision.xyz - worldPos.xyz); 23 vec3 light1R = reflect(light1Vec, worldNorm); 24 light1_Diffuse = clamp(dot(worldNorm, light1Vec), 0.0, 1.0) * UNI_light1_Diffuse; 25 float light1Spec = clamp(dot(light1R, V), 0.001, 1.0); 26 light1_Specular = pow(light1Spec, UNI_light1_CosinePower) * UNI_light1_Specular; 27 28 gl_PointSize = 1.0; 29 varTex0 = ATTRIB_texture0; 30} 31