-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsimple_shader.vert
40 lines (33 loc) · 970 Bytes
/
simple_shader.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
#version 450
layout (location = 0) in vec3 position;
layout (location = 1) in vec3 color;
layout (location = 2) in vec3 normal;
layout (location = 3) in vec2 uv;
layout (location = 0) out vec3 fragColor;
layout (location = 1) out vec3 fragPosWorld;
layout (location = 2) out vec3 fragNormalWorld;
layout (location = 3) out vec2 fragUV;
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 {
mat4 modelMatrix;
mat4 normalMatrix;
} push;
void main() {
vec4 positionWorld = push.modelMatrix * vec4(position, 1.0);
gl_Position = ubo.projection * ubo.view * positionWorld;
fragNormalWorld = normalize(mat3(push.normalMatrix) * normal);
fragPosWorld = positionWorld.xyz;
fragColor = color;
fragUV = uv;
}