1 varying vec3 varWorldPos; 2 varying vec3 varWorldNormal; 3 varying vec2 varTex0; 4 5 void main() { 6 7 vec3 V = normalize(UNI_cameraPos.xyz - varWorldPos.xyz); 8 vec3 worldNorm = normalize(varWorldNormal); 9 10 vec3 light0Vec = V; 11 vec3 light0R = reflect(light0Vec, worldNorm); 12 float light0_Diffuse = clamp(dot(worldNorm, light0Vec), 0.01, 0.99); 13 float light0Spec = clamp(dot(-light0R, V), 0.001, 1.0); 14 float light0_Specular = pow(light0Spec, 150.0) * 0.5; 15 16 vec2 t0 = varTex0.xy; 17 lowp vec4 col = texture2D(UNI_diffuse, t0).rgba; 18 col.xyz = col.xyz * light0_Diffuse * 1.1; 19 col.xyz += light0_Specular * vec3(0.8, 0.8, 1.0); 20 21 float fresnel = mix(pow(1.0 - light0_Diffuse, 15.0), 1.0, 0.1); 22 col.xyz = mix(col.xyz, textureCube(UNI_reflection, -light0R).rgb * 2.4, fresnel); 23 col.w = 0.8; 24 gl_FragColor = col; 25 } 26 27