2020-10-31 17:40:31 +00:00
|
|
|
|
|
|
|
layout (points) in;
|
2020-10-31 19:24:50 +00:00
|
|
|
layout (line_strip) out;
|
|
|
|
layout (max_vertices = 16) out;
|
2020-10-31 17:40:31 +00:00
|
|
|
|
|
|
|
// OF handled uniforms and attributes.
|
|
|
|
uniform mat4 projectionMatrix;
|
|
|
|
|
2020-10-31 18:47:59 +00:00
|
|
|
uniform float u_time;
|
|
|
|
|
2020-10-31 17:40:31 +00:00
|
|
|
// App specific uniforms and attributes.
|
|
|
|
// uniform float uSpriteSize;
|
|
|
|
|
|
|
|
in vec4 vPosition[];
|
2020-10-31 18:47:59 +00:00
|
|
|
in vec4 vPrevPosition[];
|
2020-10-31 17:40:31 +00:00
|
|
|
in vec2 vTexCoord[];
|
|
|
|
flat in int vValid[];
|
|
|
|
|
|
|
|
out vec2 texCoordVarying;
|
|
|
|
in vec3 vPos[];
|
|
|
|
in vec4 vTarget[];
|
|
|
|
in float vTemperature[];
|
|
|
|
in float vAge[];
|
|
|
|
|
|
|
|
// out vec2 gTexCoord;
|
|
|
|
out vec3 gPos;
|
|
|
|
out vec4 gTarget;
|
|
|
|
out float gTemperature;
|
|
|
|
out float gAge;
|
|
|
|
|
|
|
|
void main()
|
|
|
|
{
|
2020-10-31 18:47:59 +00:00
|
|
|
float uSpriteSize = 1;
|
2020-10-31 17:40:31 +00:00
|
|
|
// if (vValid[0] == 0) return;
|
|
|
|
|
|
|
|
texCoordVarying = vTexCoord[0];
|
|
|
|
gPos = vPos[0];
|
|
|
|
gTarget = vTarget[0];
|
|
|
|
gTemperature = vTemperature[0];
|
|
|
|
gAge = vAge[0];
|
|
|
|
|
2020-10-31 19:24:50 +00:00
|
|
|
if(gAge >= 1) return;
|
2020-10-31 17:40:31 +00:00
|
|
|
for (int i = 0; i < gl_in.length(); ++i)
|
|
|
|
{
|
2020-10-31 19:24:50 +00:00
|
|
|
vec3 vOffset = (vPrevPosition[i].xyz - vPosition[i].xyz) * (gAge * 5);
|
|
|
|
vOffset += normalize(vOffset) * 5;
|
2020-10-31 18:47:59 +00:00
|
|
|
// if(length(vOffset) < 4) {
|
|
|
|
// vOffset = normalize(vOffset) * 4;
|
|
|
|
// }
|
2020-10-31 19:24:50 +00:00
|
|
|
vec4 shiftPos = vec4(vOffset, 0) + vPosition[i];
|
2020-10-31 17:40:31 +00:00
|
|
|
|
2020-10-31 19:24:50 +00:00
|
|
|
gl_Position = projectionMatrix * (vPosition[i] + vec4(0.0, 0.0, 0.0, 0.0) * uSpriteSize);
|
2020-10-31 17:40:31 +00:00
|
|
|
EmitVertex();
|
|
|
|
|
2020-10-31 18:47:59 +00:00
|
|
|
if (u_time > 10) { // hack
|
2020-10-31 19:24:50 +00:00
|
|
|
gl_Position = projectionMatrix * (shiftPos + vec4(0.0, 0.0, 0.0, 0.0) * uSpriteSize);
|
2020-10-31 18:47:59 +00:00
|
|
|
EmitVertex();
|
|
|
|
|
2020-10-31 19:24:50 +00:00
|
|
|
if(gAge > 0 && gTarget.w > 0) {
|
|
|
|
for(int j = 0; j < 3; j++) {
|
|
|
|
gl_Position = projectionMatrix * (vPosition[i] + vec4(0.0, float(j+1), 0.0, 0.0) * uSpriteSize);
|
|
|
|
EmitVertex();
|
|
|
|
gl_Position = projectionMatrix * (shiftPos + vec4(0.0, float(j+1), 0.0, 0.0) * uSpriteSize);
|
|
|
|
EmitVertex();
|
|
|
|
}
|
|
|
|
}
|
2020-10-31 18:47:59 +00:00
|
|
|
}
|
2020-10-31 17:40:31 +00:00
|
|
|
|
|
|
|
|
|
|
|
EndPrimitive();
|
|
|
|
}
|
|
|
|
}
|