#version 460

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

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

layout (std140, binding = 0) uniform Properties
{
	vec4 ambient;
	vec4 diffuse;
	vec4 specular;
	float shininess;
} Props;

layout (std140, binding = 1) uniform PBRState
{
	uint channels;
	bool albedo_tex;
	bool ambient_tex;
	bool specular_tex;
} State;

layout (binding = 0) uniform sampler2D albedo_texture;
layout (binding = 1) uniform sampler2D ambient_texture;
layout (binding = 2) uniform sampler2D specular_texture;

void main()
{
	vec4 col = in_color;
	
	if (State.albedo_tex)
		col = texture(albedo_texture, in_uv);

	if (State.channels == 1)
		col.rgb = col.rrr;

	gl_Position = vec4(in_pos, 1.0);
	out_color = col;
}
