mirror of
https://github.com/slendidev/lunar.git
synced 2025-12-08 10:29:52 +02:00
@@ -17,6 +17,8 @@ shader_sources = files(
|
||||
'gradient.comp',
|
||||
'triangle.frag',
|
||||
'triangle.vert',
|
||||
'triangle_mesh.frag',
|
||||
'triangle_mesh.vert',
|
||||
)
|
||||
|
||||
spirv_shaders = []
|
||||
|
||||
11
shaders/triangle_mesh.frag
Normal file
11
shaders/triangle_mesh.frag
Normal file
@@ -0,0 +1,11 @@
|
||||
#version 450
|
||||
|
||||
layout (location = 0) in vec3 in_color;
|
||||
layout (location = 1) in vec3 in_uv;
|
||||
|
||||
layout (location = 0) out vec4 out_frag_color;
|
||||
|
||||
void main() {
|
||||
out_frag_color = vec4(in_color, 1.0f);
|
||||
}
|
||||
|
||||
32
shaders/triangle_mesh.vert
Normal file
32
shaders/triangle_mesh.vert
Normal file
@@ -0,0 +1,32 @@
|
||||
#version 450
|
||||
#extension GL_EXT_buffer_reference : require
|
||||
|
||||
layout (location = 0) out vec3 out_color;
|
||||
layout (location = 1) out vec3 out_uv;
|
||||
|
||||
struct Vertex {
|
||||
vec3 position;
|
||||
float uv_x;
|
||||
vec3 normal;
|
||||
float uv_y;
|
||||
vec4 color;
|
||||
};
|
||||
|
||||
layout(buffer_reference, std430) readonly buffer VertexBuffer{
|
||||
Vertex vertices[];
|
||||
};
|
||||
|
||||
layout(push_constant) uniform constants {
|
||||
mat4 world_matrix;
|
||||
VertexBuffer vertex_buffer;
|
||||
} PushConstants;
|
||||
|
||||
void main() {
|
||||
Vertex v = PushConstants.vertex_buffer.vertices[gl_VertexIndex];
|
||||
|
||||
gl_Position = PushConstants.world_matrix * vec4(v.position, 1.0f);
|
||||
out_color = v.color.xyz;
|
||||
out_uv.x = v.uv_x;
|
||||
out_uv.y = v.uv_y;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user