-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpoint_light.vert
45 lines (36 loc) · 991 Bytes
/
point_light.vert
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#version 450
const vec2 OFFSETS[6] = vec2[](
vec2(-1.0, -1.0),
vec2(-1.0, 1.0),
vec2(1.0, -1.0),
vec2(1.0, -1.0),
vec2(-1.0, 1.0),
vec2(1.0, 1.0)
);
layout (location = 0) out vec2 fragOffset;
struct PointLight {
vec4 position; // ignore w
vec4 color; // w = intensity
};
layout (set = 0, binding = 0) uniform GlobalUbo {
mat4 projection;
mat4 view;
mat4 inverseView;
vec4 ambientLightColor;
PointLight pointLights[10];
int numLights;
} ubo;
layout(push_constant) uniform Push {
vec4 position;
vec4 color;
float radius;
} push;
void main() {
fragOffset = OFFSETS[gl_VertexIndex];
vec3 cameraRightWorld = { ubo.view[0][0], ubo.view[1][0], ubo.view[2][0]};
vec3 cameraUpWorld = { ubo.view[0][1], ubo.view[1][1], ubo.view[2][1]};
vec3 positionWorld = push.position.xyz
+ push.radius * fragOffset.x * cameraRightWorld
+ push.radius * fragOffset.y * cameraUpWorld;
gl_Position = ubo.projection * ubo.view * vec4(positionWorld, 1.0);
}