OLD | NEW |
| (Empty) |
1 // shared fragment shader should succeed. | |
2 precision mediump float; | |
3 uniform vec4 lightColor; | |
4 varying vec4 v_position; | |
5 varying vec2 v_texCoord; | |
6 varying vec3 v_surfaceToLight; | |
7 | |
8 uniform vec4 ambient; | |
9 uniform sampler2D diffuse; | |
10 uniform vec4 specular; | |
11 uniform float shininess; | |
12 uniform float specularFactor; | |
13 // #fogUniforms | |
14 | |
15 vec4 lit(float l ,float h, float m) { | |
16 return vec4(1.0, | |
17 max(l, 0.0), | |
18 (l > 0.0) ? pow(max(0.0, h), m) : 0.0, | |
19 1.0); | |
20 } | |
21 void main() { | |
22 vec4 diffuseColor = texture2D(diffuse, v_texCoord); | |
23 vec4 normalSpec = vec4(0,0,0,0); // #noNormalMap | |
24 vec3 surfaceToLight = normalize(v_surfaceToLight); | |
25 vec3 halfVector = normalize(surfaceToLight); | |
26 vec4 litR = lit(1.0, 1.0, shininess); | |
27 vec4 outColor = vec4( | |
28 (lightColor * (diffuseColor * litR.y + diffuseColor * ambient + | |
29 specular * litR.z * specularFactor * normalSpec.a)).rgb, | |
30 diffuseColor.a); | |
31 // #fogCode | |
32 gl_FragColor = outColor; | |
33 } | |
34 | |
OLD | NEW |