summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/bgfx/3rdparty/spirv-cross/shaders/flatten/struct.flatten.vert
blob: 936bb41b852be4cfd5ce13a6f6d2fe61ebde681c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#version 310 es

struct Light
{
    vec3 Position;
    float Radius;

    vec4 Color;
};

layout(std140) uniform UBO
{
    mat4 uMVP;

    Light light;
};

layout(location = 0) in vec4 aVertex;
layout(location = 1) in vec3 aNormal;
layout(location = 0) out vec4 vColor;

void main()
{
    gl_Position = uMVP * aVertex;

    vColor = vec4(0.0);

    vec3 L = aVertex.xyz - light.Position;
    vColor += dot(aNormal, normalize(L)) * (clamp(1.0 - length(L) / light.Radius, 0.0, 1.0) * light.Color);
}