generated from AfonsoCMSousa/CPP-OpenGLTemplate
feat: added multithreading
This commit is contained in:
@@ -4,7 +4,10 @@ in vec4 vColor;
|
||||
out vec4 FragColor;
|
||||
|
||||
void main() {
|
||||
// Soft circular point — discard corners to make round dots
|
||||
vec2 coord = gl_PointCoord - vec2(0.5);
|
||||
if (dot(coord, coord) > 0.25)
|
||||
discard;
|
||||
|
||||
FragColor = vColor;
|
||||
}
|
||||
|
||||
|
||||
|
||||
+18
-10
@@ -1,18 +1,26 @@
|
||||
#version 330 core
|
||||
layout(location = 0) in vec3 aPos; // Position
|
||||
layout(location = 1) in vec4 aColor; // Color (RGBA)
|
||||
layout(location = 2) in float aLife; // Life
|
||||
layout(location = 0) in vec3 aPos;
|
||||
layout(location = 1) in vec4 aColor;
|
||||
layout(location = 2) in float aLife;
|
||||
layout(location = 4) in float size;
|
||||
|
||||
out vec4 vColor;
|
||||
|
||||
uniform mat4 uMVP;
|
||||
uniform float uScreenHeight;
|
||||
|
||||
void main() {
|
||||
float alpha = aLife;
|
||||
if (aLife > 0.0) {
|
||||
alpha = aLife / 10.0; // Fade mortal particles
|
||||
} else if (aLife < 0.0) {
|
||||
alpha = 1.0; // Eternal particles are fully opaque
|
||||
float alpha;
|
||||
if (aLife < 0.0) {
|
||||
alpha = 1.0; // immortal — fully opaque
|
||||
} else {
|
||||
alpha = clamp(aLife / 2.0, 0.0, 1.0); // fade over last 2 seconds of life
|
||||
}
|
||||
|
||||
vColor = vec4(aColor.rgb, aColor.a * alpha);
|
||||
gl_Position = vec4(aPos, 1.0);
|
||||
gl_PointSize = 10.0; // Make them big enough to see!
|
||||
vec4 clip_pos = uMVP * vec4(aPos, 1.0);
|
||||
gl_Position = clip_pos;
|
||||
|
||||
float base_size = 0.2 + size;
|
||||
gl_PointSize = max(1.0, base_size / clip_pos.w);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user