vengine  0.0.1
3D graphics engine
Loading...
Searching...
No Matches
vertex_point_light.vert
Go to the documentation of this file.
1#version 450
2
3const vec2 OFFSETS[6] = vec2[](
4vec2(-1.0, -1.0),
5vec2(-1.0, 1.0),
6vec2(1.0, -1.0),
7vec2(1.0, -1.0),
8vec2(-1.0, 1.0),
9vec2(1.0, 1.0)
10);
11
12layout(location = 0) out vec2 fragOffset;
13
14struct PointLight {
15 vec4 position; // ignore w
16 vec4 color; // w is intensity
17 float shininess;
18};
19
20layout(set = 0, binding = 0) uniform GlobalUbo {
21 mat4 projection;
22 mat4 view;
23 mat4 invView;
24 vec4 ambientLightColor; // w is intensity
25 PointLight pointLights[10];
26 int numLights;
27} ubo;
28
29layout(push_constant) uniform Push {
30 vec4 position;
31 vec4 color;
32 float radius;
33} push;
34
35void main() {
36 fragOffset = OFFSETS[gl_VertexIndex];
37 vec3 cameraRightWorld = vec3(ubo.view[0][0], ubo.view[1][0], ubo.view[2][0]);
38 vec3 cameraUpWorld = vec3(ubo.view[0][1], ubo.view[1][1], ubo.view[2][1]);
39
40 vec3 positionWorld = push.position.xyz
41 + push.radius * fragOffset.x * cameraRightWorld
42 + push.radius * fragOffset.y * cameraUpWorld;
43
44 gl_Position = ubo.projection * ubo.view * vec4(positionWorld, 1.0);
45}