realityplayground-of/zoneb/bin/data/shaders/particles/draw.geom

82 lines
1.9 KiB
Text
Raw Normal View History

2020-10-31 17:40:31 +00:00
layout (points) in;
2020-10-31 19:24:50 +00:00
layout (line_strip) out;
2020-11-01 15:08:56 +00:00
layout (max_vertices = 4) 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;
uniform int uEnergy;
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-11-01 15:08:56 +00:00
in vec4 vOrgPosition[];
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)
{
vec3 vOffset;
if(uEnergy > 0) {
2020-11-01 15:08:56 +00:00
if(gAge < 0.005) return;
// if(length(gTarget.xyz) > 1000) return;
2020-10-31 19:59:19 +00:00
vOffset = (vPrevPosition[i].xyz - vPosition[i].xyz);
2020-11-01 15:36:07 +00:00
vOffset += normalize(vOffset) * 10;
}
else {
2020-11-01 15:08:56 +00:00
// vOffset = (vPrevPosition[i].xyz - vPosition[i].xyz);
// vOffset = normalize(vOffset) * 2;
vOffset = vec3(1,0,0);
}
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 17:40:31 +00:00
2020-11-01 15:08:56 +00:00
EndPrimitive();
// gl_Position = projectionMatrix * (vOrgPosition[i] + vec4(0.0, 0.0, 0.0, 0.0) * uSpriteSize);
// EmitVertex();
// gl_Position = projectionMatrix * (vec4(1,0,0,0) + vOrgPosition[i]);
// EmitVertex();
}
2020-10-31 17:40:31 +00:00
EndPrimitive();
}
}