shader
4 years ago in Plain Text
#version 430 core
layout(location = 0) in vec3 positions;
uniform mat4 model;
uniform mat4 view;
uniform mat4 projection;
uniform float col;
uniform float dX, dY;
mat4 X_Rotate(in float col)
{
return (mat4(1.0, 0.0, 0.0, 0.0
, 0.0, cos(col), -sin(col), 0.0
, 0.0, sin(col), cos(col), 0.0
, 0.0, 0.0, 0.0, 1.0));
}
mat4 Y_Rotate(in float col)
{
return (mat4(cos(col), 0.0, -sin(col), 0.0
, 0.0, 1.0, 0.0, 0.0
, sin(col), 0.0, cos(col), 0.0
, 0.0, 0.0, 0.0, 1.0));
}
mat4 Z_Rotate(in float col)
{
return (mat4(cos(col), -sin(col), 0.0, 0.0
, sin(col), cos(col), 0.0, 0.0
, 0.0, 0.0, 1.0, 0.0
, 0.0, 0.0, 0.0, 1.0));
}
mat4 model_rotate()
{
mat4 X = X_Rotate(0.1*col);
mat4 Y = Y_Rotate(0.1*col);
mat4 Z = Z_Rotate(0.1*col);
return (model * X * Y * Z);
}
mat4 projection_rotate()
{
mat4 X = X_Rotate(dX*dX+dY*dY);
mat4 Y = Y_Rotate(1*col);
// mat4 Z = Z_Rotate(col);
return (projection * X * Y);
}
void main()
{
mat4 U_projection = projection_rotate();
mat4 U_model = model_rotate();
gl_Position = U_projection * view * U_model * vec4(positions, 1);
}