move to GLSL (rip rust-gpu 😭)
This commit is contained in:
parent
c1df7bf365
commit
d4623ab21f
14 changed files with 457 additions and 486 deletions
17
shaders/main.frag
Normal file
17
shaders/main.frag
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
#version 450
|
||||
|
||||
layout(location = 0) in vec3 frag_world_position;
|
||||
layout(location = 1) in vec3 frag_world_normal;
|
||||
layout(location = 2) in vec2 frag_tex_coord;
|
||||
|
||||
layout(set = 0, binding = 1) uniform sampler2D tex_sampler;
|
||||
|
||||
layout(location = 0) out vec4 out_color;
|
||||
|
||||
void main() {
|
||||
// Sample the texture
|
||||
vec4 base_color = texture(tex_sampler, frag_tex_coord);
|
||||
|
||||
// Output final color
|
||||
out_color = vec4(base_color.rgb, base_color.a);
|
||||
}
|
||||
32
shaders/main.vert
Normal file
32
shaders/main.vert
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
#version 450
|
||||
|
||||
// Vertex inputs
|
||||
layout(location = 0) in vec3 in_pos;
|
||||
layout(location = 1) in vec3 in_normal;
|
||||
layout(location = 2) in vec2 in_tex_coord;
|
||||
|
||||
// Uniform buffer
|
||||
layout(set = 0, binding = 0) uniform UniformBufferObject {
|
||||
mat4 model;
|
||||
mat4 view;
|
||||
mat4 proj;
|
||||
} ubo;
|
||||
|
||||
// Vertex outputs
|
||||
layout(location = 0) out vec3 out_world_position;
|
||||
layout(location = 1) out vec3 out_world_normal;
|
||||
layout(location = 2) out vec2 out_tex_coord;
|
||||
|
||||
void main() {
|
||||
// Transform position to world space
|
||||
vec4 pos = ubo.model * vec4(in_pos, 1.0);
|
||||
out_world_position = (pos / pos.w).xyz;
|
||||
|
||||
// Transform normal to world space
|
||||
mat3 normal_matrix = transpose(inverse(mat3(ubo.model)));
|
||||
out_world_normal = normal_matrix * in_normal;
|
||||
|
||||
// Calculate clip space position
|
||||
gl_Position = ubo.proj * ubo.view * pos;
|
||||
out_tex_coord = in_tex_coord;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue