Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- uniform float texScale;
- varying vec4 color;
- varying vec2 texCoord; // The third coordinate is always 0.0 and is discarded
- varying vec4 position;
- uniform sampler2D texture;
- uniform mat4 ModelView;
- uniform vec4 light1Pos;
- uniform vec3 AmbientProduct, DiffuseProduct, SpecularProduct;
- uniform float Shininess;
- uniform vec4 light2Pos;
- uniform vec3 light1Brightness;
- uniform vec3 light2Brightness;
- uniform float spread;
- uniform vec4 lightVec;
- void main()
- {
- vec3 eyePos = (ModelView * position).xyz;
- vec3 Lvec = light1Pos.xyz - pos;
- vec3 L = normalize (Lvec);
- vec3 L2 = normalize(light2Pos.xyz);
- vec3 E = normalize (-eyePos);
- vec3 H = normalize( L + E );
- vec3 H2 = normalize( L2 + E);
- vec3 N = normalize((ModelView*vec4(normal, 0.0)).xyz);
- vec3 ambient = light1Brightness * AmbientProduct;
- vec3 ambient2 = light2Brightness * AmbientProduct;
- float Kd = max(dot(L,N), 0.0);
- vec3 diffuse = light1Brightness * Kd*DiffuseProduct;
- float Kd2 = max(dot(L2, N), 0.0);
- vec3 diffuse2 = light2Brightness * Kd2*DiffuseProduct;
- float Ks = pow(max(dot(N,H), 0.0), Shininess);
- vec3 specular = light1Brightness * Ks * SpecularProduct;
- float Ks2 = pow(max(dot(N,H2), 0.0), Shininess);
- vec3 specular2 = light2Brightness * Ks2 * SpecularProduct;
- if(dot(L,N) < 0.0) {
- specular = vec3(0.0, 0.0, 0.0);
- }
- if(dot(L2,N) < 0.0) {
- specular2 = vec3(0.0, 0.0, 0.0);
- }
- vec3 globalAmbient = vec3(0.1, 0.1, 0.1);
- float dropoff = sqrt(dot(Lvec, Lvec))/15 + 1;
- color = vec4(globalAmbient + ((ambient1 + diffuse1) / len) + ambient2 + diffuse2, 1.0);
- //gl_FragColor = color * texture2D( texture, texCoord * texScale );
- gl_FragColor = color * texture2D( texture, texCoord) + vec4((specular1 / len) + specular2, 1.0) ;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement