zenyx-engine/shaders/shader.vert

38 lines
1.2 KiB
GLSL
Raw Normal View History

2025-04-16 01:24:10 +00:00
#version 450
layout(location = 0) in vec3 position;
layout(location = 1) in vec3 color;
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 vec4 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.);
}
2025-04-16 01:24:10 +00:00
void main() {
float sum_val = sin(TIME / 5);
mat4 model = 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));
gl_Position = view.projection * model * vec4(position, 1.0);
tex_coord = tex_coords * abs(sin(TIME / 4));
// tex_coord.x = tex_coord.x * sin(TIME / 2);
// tex_coord.y = tex_coord.y * cos(TIME / 2);
normal = model * vec4(normal_in, 1.0);
2025-04-16 01:24:10 +00:00
}