#version 150

uniform bool use_group_point_size;
uniform float group_point_sizes[250];
uniform bool use_color_index;
uniform vec4 palette[16];

in float point_size;
in vec4 position;
in vec3 normal;
in vec4 color;
in uint color_index;

in int group_index;

out vec3 normal_gs;
out vec4 color_gs;

vec4 group_color(in vec4 color, int group_index);
vec3 group_transformed_position(in vec3 position, int group_index);
vec3 group_transformed_normal(in vec3 nml, int group_index);

void main()
{
	if (use_group_point_size) {
		gl_PointSize = group_point_sizes[group_index];
	}
	else {
		gl_PointSize = point_size;
	}
	if (use_color_index)
		color_gs = group_color(vec4(palette[color_index]), group_index);
	else
		color_gs = group_color(color, group_index);
	normal_gs = group_transformed_normal(normal, group_index);
	gl_Position = vec4(group_transformed_position(position.xyz, group_index), 1.0);
}