layout (points) in; layout (line_strip) out; layout (max_vertices = 16) out; // OF handled uniforms and attributes. uniform mat4 projectionMatrix; uniform float u_time; uniform int uEnergy; // App specific uniforms and attributes. // uniform float uSpriteSize; in vec4 vPosition[]; in vec4 vPrevPosition[]; 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() { float uSpriteSize = 1; // if (vValid[0] == 0) return; texCoordVarying = vTexCoord[0]; gPos = vPos[0]; gTarget = vTarget[0]; gTemperature = vTemperature[0]; gAge = vAge[0]; if(gAge >= 1) return; for (int i = 0; i < gl_in.length(); ++i) { vec3 vOffset; if(uEnergy > 0) { vOffset = (vPrevPosition[i].xyz - vPosition[i].xyz) * (gAge * 15); // vOffset += normalize(vOffset) * 5; } else { vOffset = (vPrevPosition[i].xyz - vPosition[i].xyz); vOffset += normalize(vOffset) * 2; vOffset = vec3(1,0,0); } // if(length(vOffset) < 4) { // vOffset = normalize(vOffset) * 4; // } vec4 shiftPos = vec4(vOffset, 0) + vPosition[i]; gl_Position = projectionMatrix * (vPosition[i] + vec4(0.0, 0.0, 0.0, 0.0) * uSpriteSize); EmitVertex(); if (u_time > 10) { // hack gl_Position = projectionMatrix * (shiftPos + vec4(0.0, 0.0, 0.0, 0.0) * uSpriteSize); EmitVertex(); // if(gAge > 0 && gTarget.w > 0) { // for(int j = 0; j < 2; 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(); // } // } } EndPrimitive(); } }