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

32 lines
763 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-11-06 09:08:55 -05:00
layout(location = 2) in vec2 inUV;
2018-10-16 13:03:26 -04:00
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;
};
2018-11-06 09:08:55 -05:00
layout(set = 0, binding = 0) uniform Lights {
2018-10-18 21:46:48 -04:00
Light lights[32];
};
2018-11-06 09:08:55 -05:00
layout(set = 1, binding = 0) uniform sampler2D albedoSampler;
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);
2018-11-06 09:08:55 -05:00
const vec3 lightDir = normalize(lights[i].position.xyz - inFragPos);
2018-10-18 21:46:48 -04:00
const float diff = max(dot(norm, lightDir), 0.0);
diffuse += vec3(diff) * lights[i].color;
}
2018-11-06 09:08:55 -05:00
outColor = vec4(vec3(0.1) + diffuse * texture(albedoSampler, inUV).rgb, 1.0);
2018-10-15 19:52:16 -04:00
}