Archived
1
Fork 0
This repository has been archived on 2025-04-12. You can view files and clone it, but cannot push or open issues or pull requests.
graph/shaders/mesh.frag

29 lines
635 B
GLSL
Raw Normal View History

2018-10-15 19:52:16 -04:00
#version 460 core
2018-10-16 13:03:26 -04:00
layout(location = 0) in vec3 inFragPos;
layout(location = 1) in vec3 inNormal;
2018-10-15 19:52:16 -04:00
layout(location = 0) out vec4 outColor;
2018-10-18 21:46:48 -04:00
struct Light {
vec4 position;
vec3 color;
};
layout(binding = 0) uniform Lights {
Light lights[32];
};
2018-10-15 19:52:16 -04:00
void main() {
2018-10-18 21:46:48 -04:00
vec3 diffuse = vec3(0);
for(int i = 0; i < 32; i++) {
const vec3 norm = normalize(inNormal);
const vec3 lightDir = normalize(lights[i].position.xyz - inFragPos);
const float diff = max(dot(norm, lightDir), 0.0);
diffuse += vec3(diff) * lights[i].color;
}
2018-10-16 13:03:26 -04:00
2018-10-18 21:46:48 -04:00
outColor = vec4(vec3(0.1) + diffuse, 1.0);
2018-10-15 19:52:16 -04:00
}