2017-01-16 22:19:49 +00:00
|
|
|
#version 310 es
|
|
|
|
|
|
|
|
struct Light
|
|
|
|
{
|
|
|
|
vec3 Position;
|
|
|
|
float Radius;
|
|
|
|
vec4 Color;
|
|
|
|
};
|
|
|
|
|
|
|
|
uniform vec4 UBO[12];
|
2017-06-21 07:39:08 +00:00
|
|
|
layout(location = 0) in vec4 aVertex;
|
|
|
|
layout(location = 0) out vec4 vColor;
|
|
|
|
layout(location = 1) in vec3 aNormal;
|
2017-01-16 22:19:49 +00:00
|
|
|
|
|
|
|
void main()
|
|
|
|
{
|
2017-01-17 20:06:06 +00:00
|
|
|
gl_Position = mat4(UBO[0], UBO[1], UBO[2], UBO[3]) * aVertex;
|
2017-01-16 22:19:49 +00:00
|
|
|
vColor = vec4(0.0);
|
2019-06-06 09:10:39 +00:00
|
|
|
Light light;
|
2017-01-16 22:19:49 +00:00
|
|
|
for (int i = 0; i < 4; i++)
|
|
|
|
{
|
2018-07-06 08:57:23 +00:00
|
|
|
Light _52 = Light(UBO[i * 2 + 4].xyz, UBO[i * 2 + 4].w, UBO[i * 2 + 5]);
|
|
|
|
light.Position = _52.Position;
|
|
|
|
light.Radius = _52.Radius;
|
|
|
|
light.Color = _52.Color;
|
2017-01-16 22:19:49 +00:00
|
|
|
vec3 L = aVertex.xyz - light.Position;
|
2018-07-05 12:14:18 +00:00
|
|
|
vColor += ((UBO[i * 2 + 5] * clamp(1.0 - (length(L) / light.Radius), 0.0, 1.0)) * dot(aNormal, normalize(L)));
|
2017-01-16 22:19:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|