aboutsummaryrefslogtreecommitdiff
path: root/shaders/rect.vert
blob: 09f1917fca52d16417aa457c235f025726c83ae0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/* The vertex shader is trivial, but forwards scaled UV coordinates (in pixels)
   to the fragment shader for drawing the border. */

UBO(binding = 0) uniform UniformBufferObject
{
	mat4 projection;
} ubo;

layout(location = 0) in vec2 v_position;
layout(location = 1) in vec2 v_origin;
layout(location = 2) in vec2 v_size;
layout(location = 3) in vec4 v_fillColor;

INTER(location = 0) noperspective out vec2 f_uv;
INTER(location = 1) noperspective out vec2 f_size;
INTER(location = 2) noperspective out vec4 f_fillColor;

void
main()
{
	// clang-format off
	mat4 m = mat4(v_size[0],   0.0,         0.0, 0.0,
	              0.0,         v_size[1],   0.0, 0.0,
	              0.0,         0.0,         1.0, 0.0,
	              v_origin[0], v_origin[1], 0.0, 1.0);
	// clang-format on

	mat4 MVP = ubo.projection * m;

	f_uv        = v_position * v_size;
	f_size      = v_size;
	f_fillColor = v_fillColor;

	gl_Position = MVP * vec4(v_position, 0.0, 1.0);
}