summary refs log tree commit diff
path: root/shader/tri.vert
blob: dc7389ca1a9e2ac90eaf0a7206a9b6e5ec3c7118 (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
#version 450

layout(set = 1, binding = 0) uniform UBO {
	mat4 camera;
};

layout(location = 0) out vec2 out_uv;
layout(location = 1) out vec4 out_color;
layout(location = 2) flat out int out_type;

struct Particle {
	vec2 pos;
	float radius, life;
	vec3 color;
	int type;
};

layout(binding = 0) buffer Particles {
	Particle pts[];
};

uint tri_idx[6] = { 0, 1, 2, 3, 2, 1 };
vec2 tri_pos[4] = { {0,0}, {1,0}, {0,1}, {1,1} };

void main() {
	Particle p = pts[gl_VertexIndex / 6];
	vec2 ofs = tri_pos[tri_idx[gl_VertexIndex % 6]];
	out_uv = ofs;
	gl_Position = camera * vec4((ofs - 0.5) * p.radius * p.life + p.pos, 0.0, 1.0);
	out_color = vec4(p.color,1);
	out_type = p.type;
}