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 {
|
2024-10-19 01:08:55 +00:00
|
|
|
mat4 clip_from_world;
|
|
|
|
// Other attributes exist that can be described here.
|
|
|
|
// See full definition in: crates/bevy_render/src/view/view.wgsl
|
|
|
|
// Attributes added here must be in the same order as they are defined
|
|
|
|
// in view.wgsl, and they must be contiguous starting from the top to
|
|
|
|
// ensure they have the same layout.
|
|
|
|
//
|
|
|
|
// Needing to maintain this mapping yourself is one of the harder parts of using
|
|
|
|
// GLSL with Bevy. WGSL provides a much better user experience!
|
|
|
|
} camera_view;
|
2022-01-05 19:43:11 +00:00
|
|
|
|
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
|
2023-11-28 22:26:22 +00:00
|
|
|
layout(set = 1, binding = 0) uniform Mesh Meshes[#{PER_OBJECT_BUFFER_BATCH_SIZE}];
|
2023-07-31 13:14:40 +00:00
|
|
|
#else
|
2023-11-28 22:26:22 +00:00
|
|
|
layout(set = 1, binding = 0) readonly buffer _Meshes {
|
2023-07-31 13:14:40 +00:00
|
|
|
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;
|
2024-10-19 01:08:55 +00:00
|
|
|
gl_Position = camera_view.clip_from_world
|
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
|
|
|
}
|