Guest User

Untitled

a guest
Jan 22nd, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. uniform sampler2D base_texture;
  2. uniform sampler2D height_texture;
  3. varying vec2 coord;
  4. varying vec3 normal;
  5.  
  6. void main()
  7. {
  8. vec4 baseCol = texture2D(base_texture, coord * 128) * vec4(1.0, 1.0, 1.0, 1.0);
  9. float NdotL0 = max(dot(normalize(normal), gl_LightSource[0].position.xyz), 0.0);
  10.  
  11. vec4 ambient = vec4(0.0, 0.0, 0.0, 1.0);
  12. ambient.rgb += gl_LightSource[0].ambient.rgb;
  13. ambient *= gl_FrontMaterial.ambient * baseCol;
  14.  
  15. vec4 diffuse = vec4(0.0, 0.0, 0.0, 1.0);
  16. diffuse.rgb += NdotL0 * gl_LightSource[0].diffuse.rgb;
  17. diffuse *= gl_FrontMaterial.diffuse * baseCol;
  18.  
  19. vec4 specular = vec4(0.0, 0.0, 0.0, 1.0);
  20. specular += clamp(dot(reflect(vec3(0, 0, 1), normal), normalize(gl_LightSource[0].position.xyz)), 0.0, 1.0);
  21. specular *= gl_FrontMaterial.specular * baseCol;
  22.  
  23. gl_FragColor = clamp(ambient + diffuse + specular, 0.0, 1.0);
  24. }
Add Comment
Please, Sign In to add comment