Alex Sakhartchouk | af83e79 | 2010-08-27 16:10:55 -0700 | [diff] [blame] | 1 | varying float light0_Diffuse; |
| 2 | varying float light0_Specular; |
| 3 | varying float light1_Diffuse; |
| 4 | varying float light1_Specular; |
Alex Sakhartchouk | e7ae69f | 2010-09-14 09:50:43 -0700 | [diff] [blame] | 5 | varying vec2 varTex0; |
Alex Sakhartchouk | af83e79 | 2010-08-27 16:10:55 -0700 | [diff] [blame] | 6 | |
| 7 | // This is where actual shader code begins |
| 8 | void main() { |
| 9 | vec4 worldPos = UNI_model * ATTRIB_position; |
Alex Sakhartchouk | e7ae69f | 2010-09-14 09:50:43 -0700 | [diff] [blame] | 10 | gl_Position = UNI_proj * worldPos; |
Alex Sakhartchouk | af83e79 | 2010-08-27 16:10:55 -0700 | [diff] [blame] | 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 | |
Alex Sakhartchouk | 54929cc | 2010-11-08 15:10:52 -0800 | [diff] [blame^] | 16 | vec3 light0Vec = normalize(UNI_light0_Posision.xyz - worldPos.xyz); |
| 17 | vec3 light0R = -reflect(light0Vec, worldNorm); |
Alex Sakhartchouk | af83e79 | 2010-08-27 16:10:55 -0700 | [diff] [blame] | 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 | |
Alex Sakhartchouk | 54929cc | 2010-11-08 15:10:52 -0800 | [diff] [blame^] | 22 | vec3 light1Vec = normalize(UNI_light1_Posision.xyz - worldPos.xyz); |
Alex Sakhartchouk | af83e79 | 2010-08-27 16:10:55 -0700 | [diff] [blame] | 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 | } |