You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
lunarium_OLD/src/renderer/shaders/quad.vert

56 lines
1.8 KiB
GLSL

#version 450 core
layout(location = 0) in vec3 pos;
layout(location = 1) in vec2 tex_coords;
layout(location = 2) in vec4 color;
layout(location = 3) in float tex_slot;
layout(location = 4) in vec3 translation;
layout(location = 5) in float angle;
layout(location = 6) in vec3 scale;
layout (location = 0) out vec2 f_tex_coords;
layout (location = 1) out vec4 f_vert_color;
layout (location = 2) flat out int f_tex_index;
uniform mat4 projview;
void main()
{
f_tex_index = int(tex_slot);
f_tex_coords = tex_coords;
f_vert_color = color;
// mat4 ModelTrans = mat4(
// vec4( scale.x * cos(angle), scale.x * -sin(angle), 0.0, 0.0),
// vec4( scale.y * sin(angle), scale.y * cos(angle), 0.0, 0.0),
// vec4( 0.0, 0.0, scale.z, 0.0),
// vec4( translation.xyz, 1.0)
// );
mat4 Translation = mat4(
vec4( 1.0, 0.0, 0.0, 0.0),
vec4( 0.0, 1.0, 0.0, 0.0),
vec4( 0.0, 0.0, 1.0, 0.0),
vec4( translation.xyz, 1.0));
mat4 Rotation = mat4(
vec4( cos(angle), -sin(angle), 0.0, 0.0),
vec4( sin(angle), cos(angle), 0.0, 0.0),
vec4( 0.0, 0.0, 1.0, 0.0),
vec4( 0.0, 0.0, 0.0, 1.0));
mat4 Scale = mat4(
vec4(scale.x, 0.0, 0.0, 0.0),
vec4(0.0, scale.y, 0.0, 0.0),
vec4(0.0, 0.0,scale.z, 0.0),
vec4(0.0, 0.0, 0.0, 1.0));
// mat4 model = Translation * RotationScale;
//gl_Position = Translation * vec4(pos, 1.0);
mat4 model = mat4( vec4(1.0, 0.0, 0.0, 0.0), vec4(0.0, 1.0, 0.0, 0.0), vec4(0.0, 0.0, 1.0, 0.0), vec4(0.0, 0.0, 0.0, 1.0));
model = model * Translation;
model = model * Rotation;
model = model * Scale;
gl_Position = projview * model * vec4(pos, 1.0);
}