Guest User

Untitled

a guest
Jul 23rd, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. uniform vec3 cam_pos;
  2. /* uniform vec4 diff_color, spec_color, ambient_color; */
  3. uniform float spec_power;
  4.  
  5. varying vec4 light;
  6. varying vec4 ambient, diff, spec;
  7.  
  8. void main (void)
  9. {
  10.   vec3 p = vec3(gl_ModelViewMatrix * gl_Vertex),
  11.     v = normalize(cam_pos - p),
  12.     n = normalize(gl_NormalMatrix * gl_Normal),
  13.     r = reflect(-v, n),
  14.     l = normalize(gl_LightSource[0].position.xyz - p);
  15.  
  16.   /* vec4 ambient, diff, spec; */
  17.   /* gl_FrontMaterial.shininess */
  18.  
  19.   ambient = gl_FrontLightProduct[0].ambient;
  20.   diff    = gl_FrontLightProduct[0].diffuse * max(dot(n, l), 0.0);
  21.   diff    = clamp(diff, 0.0, 1.0);
  22.   spec    = /* vec4(vec3(gl_FrontLightProduct[0].specular) */
  23.     /*      *  */vec4(pow(max(dot(l, r), 0.0), 0.3 * spec_power))/* , 1) */;
  24.   spec    = clamp(spec, 0.0, 1.0);
  25.  
  26.   light   = ambient + diff + spec;
  27.  
  28.   gl_TexCoord[0] = gl_MultiTexCoord0;
  29.   gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
  30. }
Add Comment
Please, Sign In to add comment