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/triangle.frag
2018-10-18 21:49:07 -04:00

28 lines
635 B
GLSL

#version 460 core
layout(location = 0) in vec3 inFragPos;
layout(location = 1) in vec3 inNormal;
layout(location = 0) out vec4 outColor;
struct Light {
vec4 position;
vec3 color;
};
layout(binding = 0) uniform Lights {
Light lights[32];
};
void main() {
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;
}
outColor = vec4(vec3(0.1) + diffuse, 1.0);
}