1varying vec3 varWorldPos; 2varying vec3 varWorldNormal; 3varying vec2 varTex0; 4 5void main() { 6 7 vec3 V = normalize(-varWorldPos.xyz); 8 vec3 worldNorm = normalize(varWorldNormal); 9 10 vec3 light0Vec = normalize(UNI_light0_Posision.xyz - varWorldPos); 11 vec3 light0R = -reflect(light0Vec, worldNorm); 12 float light0_Diffuse = clamp(dot(worldNorm, light0Vec), 0.0, 1.0) * UNI_light0_Diffuse; 13 float light0Spec = clamp(dot(light0R, V), 0.001, 1.0); 14 float light0_Specular = pow(light0Spec, UNI_light0_CosinePower) * UNI_light0_Specular; 15 16 vec3 light1Vec = normalize(UNI_light1_Posision.xyz - varWorldPos); 17 vec3 light1R = reflect(light1Vec, worldNorm); 18 float light1_Diffuse = clamp(dot(worldNorm, light1Vec), 0.0, 1.0) * UNI_light1_Diffuse; 19 float light1Spec = clamp(dot(light1R, V), 0.001, 1.0); 20 float light1_Specular = pow(light1Spec, UNI_light1_CosinePower) * UNI_light1_Specular; 21 22 vec2 t0 = varTex0.xy; 23 lowp vec4 col = texture2D(UNI_Tex0, t0).rgba; 24 col.xyz = col.xyz * (light0_Diffuse * UNI_light0_DiffuseColor.xyz + light1_Diffuse * UNI_light1_DiffuseColor.xyz); 25 col.xyz += light0_Specular * UNI_light0_SpecularColor.xyz; 26 col.xyz += light1_Specular * UNI_light1_SpecularColor.xyz; 27 gl_FragColor = col; 28} 29 30