2022-01-05 19:43:11 +00:00
|
|
|
#version 450
|
|
|
|
|
|
|
|
layout(location = 0) in vec3 Vertex_Position;
|
|
|
|
layout(location = 1) in vec3 Vertex_Normal;
|
|
|
|
layout(location = 2) in vec2 Vertex_Uv;
|
|
|
|
|
2022-07-08 01:14:22 +00:00
|
|
|
layout(location = 0) out vec2 v_Uv;
|
|
|
|
|
2022-01-05 19:43:11 +00:00
|
|
|
layout(set = 0, binding = 0) uniform CameraViewProj {
|
|
|
|
mat4 ViewProj;
|
2022-02-16 22:57:15 +00:00
|
|
|
mat4 View;
|
2022-01-05 19:43:11 +00:00
|
|
|
mat4 InverseView;
|
|
|
|
mat4 Projection;
|
|
|
|
vec3 WorldPosition;
|
|
|
|
float width;
|
|
|
|
float height;
|
|
|
|
};
|
|
|
|
|
2023-07-31 13:14:40 +00:00
|
|
|
struct Mesh {
|
2023-08-21 07:58:21 +00:00
|
|
|
mat3x4 Model;
|
2022-01-05 19:43:11 +00:00
|
|
|
mat4 InverseTransposeModel;
|
|
|
|
uint flags;
|
|
|
|
};
|
|
|
|
|
2023-07-31 13:14:40 +00:00
|
|
|
#ifdef PER_OBJECT_BUFFER_BATCH_SIZE
|
|
|
|
layout(set = 2, binding = 0) uniform Mesh Meshes[#{PER_OBJECT_BUFFER_BATCH_SIZE}];
|
|
|
|
#else
|
|
|
|
layout(set = 2, binding = 0) readonly buffer _Meshes {
|
|
|
|
Mesh Meshes[];
|
|
|
|
};
|
|
|
|
#endif // PER_OBJECT_BUFFER_BATCH_SIZE
|
|
|
|
|
2023-08-21 07:58:21 +00:00
|
|
|
mat4 affine_to_square(mat3x4 affine) {
|
|
|
|
return transpose(mat4(
|
|
|
|
affine[0],
|
|
|
|
affine[1],
|
|
|
|
affine[2],
|
|
|
|
vec4(0.0, 0.0, 0.0, 1.0)
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
2022-01-05 19:43:11 +00:00
|
|
|
void main() {
|
2022-07-08 01:14:22 +00:00
|
|
|
v_Uv = Vertex_Uv;
|
2023-07-31 13:14:40 +00:00
|
|
|
gl_Position = ViewProj
|
2023-08-21 07:58:21 +00:00
|
|
|
* affine_to_square(Meshes[gl_InstanceIndex].Model)
|
2023-07-31 13:14:40 +00:00
|
|
|
* vec4(Vertex_Position, 1.0);
|
2022-01-05 19:43:11 +00:00
|
|
|
}
|