48 lines
1.2 KiB
GLSL
48 lines
1.2 KiB
GLSL
#version 330 core
|
|
layout (location = 0) in vec2 p0;
|
|
layout (location = 1) in vec2 p1;
|
|
layout (location = 2) in vec4 color;
|
|
layout (location = 3) in float border_radius;
|
|
layout (location = 4) in float border_thickness;
|
|
layout (location = 5) in vec4 border_color;
|
|
layout (location = 6) in float edge_softness;
|
|
|
|
uniform mat4 projection;
|
|
|
|
out vec4 frag_color;
|
|
out vec2 frag_dest_position;
|
|
out vec2 frag_dest_center;
|
|
out vec2 frag_dest_half_size;
|
|
out float frag_softness;
|
|
out float frag_border_radius;
|
|
out float frag_border_thickness;
|
|
out vec4 frag_border_color;
|
|
|
|
const vec2 rectangle_vertices[4] = vec2[](
|
|
vec2(-1, -1),
|
|
vec2(-1, 1),
|
|
vec2( 1, -1),
|
|
vec2( 1, 1)
|
|
);
|
|
|
|
void main() {
|
|
vec2 dest_half_size = (p1 - p0) / 2;
|
|
vec2 dest_center = (p1 + p0) / 2;
|
|
vec2 dest_position = rectangle_vertices[gl_VertexID] * dest_half_size + dest_center;
|
|
|
|
gl_Position = projection * vec4(
|
|
dest_position,
|
|
0,
|
|
1
|
|
);
|
|
|
|
frag_color = color;
|
|
frag_dest_position = dest_position;
|
|
frag_dest_center = dest_center;
|
|
frag_dest_half_size = dest_half_size;
|
|
frag_border_radius = border_radius;
|
|
frag_border_thickness = border_thickness;
|
|
frag_border_color = border_color;
|
|
frag_softness = edge_softness;
|
|
}
|