gedeng/Shader/particle_render.gs
karl 5637868200 Add draft for multiple particle types
The type was changed from int to float, because comparing the int to values (e.g. type == 1) never returned true...
2021-05-08 19:03:29 +02:00

55 lines
1.3 KiB
GLSL

#version 430
uniform mat4 projection;
uniform mat4 view;
uniform vec3 camera_pos;
uniform vec3 quad1, quad2;
layout(points) in;
layout(triangle_strip) out;
layout(max_vertices = 4) out;
in vec3 color_pass[];
in float lifetime_pass[];
in float size_pass[];
in float type_pass[];
smooth out vec2 tex_coords;
flat out vec4 color_part;
void main() {
if(type_pass[0] != 0.0) {
// This is not a generator particle
vec3 old_pos = gl_in[0].gl_Position.xyz - camera_pos;
float size = size_pass[0];
mat4 view_projection_matrix = projection * view;
color_part = vec4(color_pass[0], 1.0);
vec3 pos = old_pos + (-quad1 - quad2) * size;
tex_coords = vec2(0.0, 0.0);
gl_Position = view_projection_matrix * vec4(pos, 1.0);
EmitVertex();
pos = old_pos + (-quad1 + quad2) * size;
tex_coords = vec2(0.0, 1.0);
gl_Position = view_projection_matrix * vec4(pos, 1.0);
EmitVertex();
pos = old_pos + (quad1 - quad2) * size;
tex_coords = vec2(1.0, 0.0);
gl_Position = view_projection_matrix * vec4(pos, 1.0);
EmitVertex();
pos = old_pos + (quad1 + quad2) * size;
tex_coords = vec2(1.0, 1.0);
gl_Position = view_projection_matrix * vec4(pos, 1.0);
EmitVertex();
EndPrimitive();
}
}