mesh_render.frag 448 B

1234567891011121314151617181920212223
  1. #version 460
  2. struct material_type {
  3. vec3 ambient;
  4. vec3 diffuse;
  5. };
  6. struct light_property {
  7. vec3 direction;
  8. };
  9. uniform material_type material;
  10. uniform light_property light;
  11. in vec3 frag_normal;
  12. layout (location = 0) out vec4 frag_color;
  13. void main() {
  14. float diffuse_weight = max(-dot(frag_normal, light.direction), 0.0);
  15. vec3 color = material.ambient + diffuse_weight * material.diffuse;
  16. frag_color = vec4(color, 1.0);
  17. }