#version 460

#extension GL_GOOGLE_include_directive : require
#extension GL_EXT_nonuniform_qualifier : require

#include "structures.layout"

layout (location = 0) in vec4 in_pos;
layout (location = 1) in vec4 in_normal;
layout (location = 2) in vec2 in_uv;
layout (location = 3) in vec4 in_col;

layout (location = 0) out vec4 out_col;
layout (location = 1) out vec2 out_uv;

mat4 y_matrix = mat4(
	1.0, 0.0, 0.0, 0.0,
	0.0, -1.0, 0.0, 0.0,
	0.0, 0.0, 1.0, 0.0,
	0.0, 0.0, 0.0, 1.0
);

void main()
{
	gl_Position = in_pos * y_matrix;

	if (Materials[nonuniformEXT(PC.mat_id)].albedo_has_texture)
	{
		out_col = texture(sampler2D(Textures[nonuniformEXT(Materials[nonuniformEXT(PC.mat_id)].albedo_texture)], SamplerNearest), in_uv);
	}
	else
	{
		out_col = Materials[nonuniformEXT(PC.mat_id)].diffuse;
	}
}
