ab21dfb25b
In some cases, the compiler decided to emit continue block first, which invalidated the expressions used by the condition. Parameters to functions can be evaluated in any order which caused "random" behavior.
35 lines
528 B
GLSL
35 lines
528 B
GLSL
#version 310 es
|
|
|
|
struct Light
|
|
{
|
|
vec3 Position;
|
|
float Radius;
|
|
|
|
vec4 Color;
|
|
};
|
|
|
|
layout(std140) uniform UBO
|
|
{
|
|
mat4 uMVP;
|
|
|
|
Light lights[4];
|
|
};
|
|
|
|
in vec4 aVertex;
|
|
in vec3 aNormal;
|
|
out vec4 vColor;
|
|
|
|
void main()
|
|
{
|
|
gl_Position = uMVP * aVertex;
|
|
|
|
vColor = vec4(0.0);
|
|
|
|
for (int i = 0; i < 4; ++i)
|
|
{
|
|
Light light = lights[i];
|
|
vec3 L = aVertex.xyz - light.Position;
|
|
vColor += dot(aNormal, normalize(L)) * (clamp(1.0 - length(L) / light.Radius, 0.0, 1.0) * lights[i].Color);
|
|
}
|
|
}
|