Advertisement
Guest User

Untitled

a guest
Jul 8th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. #version 130
  3.  
  4. precision highp float;
  5.  
  6. const vec3 ambient = vec3(0, 0.0, 0.0);
  7. const vec3 lightVecNormalized = normalize(vec3(0.0, 0.5, 0.0));
  8. const vec3 lightColor = vec3(0.0, 0.0, 0.5);
  9. uniform sampler2D tex;
  10.  
  11. in vec3 normal;
  12.  
  13. out vec4 out_frag_color;
  14.  
  15. void main(void)
  16. {
  17.   float diffuse = clamp(dot(lightVecNormalized, normalize(normal)), 0.0, 1.0);
  18.     vec4 color = texture2D(tex,gl_TexCoord[0].st);
  19.  
  20.   //out_frag_color = vec4(color + (ambient+ diffuse * lightColor), 1.0);
  21.     out_frag_color = color+vec4(ambient+ diffuse * lightColor, 0.5);
  22. }
  23. #version 130
  24.  
  25. precision highp float;
  26.  
  27. uniform mat4 projection_matrix;
  28. uniform mat4 modelview_matrix;
  29. attribute vec4 gl_MultiTexCoord0;
  30. in vec3 in_position;
  31. in vec3 in_normal;
  32. in vec4 in_texture;
  33.  
  34. out vec3 normal;
  35.  
  36. void main(void)
  37. {
  38.   gl_TexCoord[0] = in_texture;
  39.   //works only for orthogonal modelview
  40.   normal = (modelview_matrix * vec4(in_normal, 0)).xyz;
  41.   gl_Position = projection_matrix * modelview_matrix * vec4(in_position, 1);
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement