2023-04-02 23:49:58 -04:00
|
|
|
#ifdef __cplusplus
|
|
|
|
#include <string>
|
|
|
|
std::string shader_geom = R"("
|
2023-04-02 22:11:47 -04:00
|
|
|
#version 460
|
|
|
|
|
|
|
|
layout (points) in;
|
|
|
|
layout (triangle_strip, max_vertices = 4) out;
|
|
|
|
|
2023-04-02 23:49:58 -04:00
|
|
|
in vec4 pos_[];
|
|
|
|
|
|
|
|
out vec2 uv_;
|
|
|
|
out float index;
|
|
|
|
|
|
|
|
uniform mat4 pvm;
|
|
|
|
uniform vec4 up;
|
|
|
|
uniform vec4 right;
|
|
|
|
|
2023-04-04 22:02:11 -04:00
|
|
|
void transform(vec3 pos){
|
2023-04-02 23:49:58 -04:00
|
|
|
// passthough index
|
|
|
|
index = pos_[0].w;
|
|
|
|
gl_Position = pvm * vec4(pos, 1.0);
|
|
|
|
}
|
|
|
|
|
2023-04-02 22:11:47 -04:00
|
|
|
void main() {
|
2023-04-02 23:49:58 -04:00
|
|
|
const float quad_size = 0.5;
|
|
|
|
vec3 pos = pos_[0].xyz;
|
2023-04-02 22:11:47 -04:00
|
|
|
|
2023-04-04 22:02:11 -04:00
|
|
|
// using the up and right vectors to generate the verticies for this particle ensures that the particle always faces the camera
|
|
|
|
transform(pos + up.xyz * quad_size + right.xyz * quad_size);
|
2023-04-02 23:49:58 -04:00
|
|
|
uv_ = vec2(0, 0);
|
|
|
|
EmitVertex();
|
|
|
|
|
2023-04-04 22:02:11 -04:00
|
|
|
transform(pos + up.xyz * quad_size - right.xyz * quad_size);
|
2023-04-02 23:49:58 -04:00
|
|
|
uv_ = vec2(0, 1);
|
|
|
|
EmitVertex();
|
|
|
|
|
2023-04-04 22:02:11 -04:00
|
|
|
transform(pos - up.xyz * quad_size + right.xyz * quad_size);
|
2023-04-02 23:49:58 -04:00
|
|
|
uv_ = vec2(1, 0);
|
|
|
|
EmitVertex();
|
|
|
|
|
2023-04-04 22:02:11 -04:00
|
|
|
transform(pos - up.xyz * quad_size - right.xyz * quad_size);
|
2023-04-02 23:49:58 -04:00
|
|
|
uv_ = vec2(1, 1);
|
|
|
|
EmitVertex();
|
|
|
|
|
|
|
|
EndPrimitive();
|
2023-04-02 22:11:47 -04:00
|
|
|
}
|
2023-04-02 23:49:58 -04:00
|
|
|
|
|
|
|
")";
|
|
|
|
#endif
|