feat(render): time-based rotation in shaders

This commit is contained in:
Chance 2025-04-27 17:22:05 -04:00
parent 22a58044d5
commit 0e8209f9b9
Signed by: caznix
GPG key ID: 489D213143D753FD
3 changed files with 55 additions and 12 deletions

View file

@ -6,13 +6,26 @@ layout(location = 2) in vec3 normal_in;
layout(location = 3) in vec2 tex_coords;
layout(location = 0) out vec2 tex_coord;
layout(location = 1) out vec3 normal;
layout(push_constant) uniform float TIME;
layout(set = 0, binding = 0) uniform UniformBufferObject {
mat4x4 projection;
} view;
mat4 rotation(float lerp) {
return mat4(cos(lerp), -sin(lerp), 0., 0.,
sin(lerp), cos(lerp), 0., 0.,
0., 0., 1., 0.,
0., 0., 0., 1.);
}
void main() {
gl_Position = view.projection * vec4(position, 1.0);
float sum_val = sin(TIME / 5);
gl_Position = view.projection * transpose(mat4(
1.0, 0.0, 0.0, sum_val,
0.0, 1.0, 0.0, sum_val,
0.0, 0.0, 1.0, sum_val,
0.0, 0.0, 0.0, 1.0) * mat4((sin(TIME) + 1.0) / 2, 0.0, 0.0, 0.0,
0.0, (sin(TIME) + 1.0) / 2, 0.0, 0.0,
0.0, 0.0, (sin(TIME) + 1.0) / 2, 0.0,
0.0, 0.0, 0.0, 1) * rotation(TIME * 2.5)) * vec4(position, 1.0);
tex_coord = tex_coords;
normal = normal_in;
// gl_Position
// out_color = color;
}