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