#version 430 uniform mat4 proj; uniform mat4 view; uniform float time; uniform float timeFactor; uniform float age; uniform vec3 position; uniform int seedBase; int seed = 0; out vec3 varOffsetA; out vec3 varOffsetB; out float varFade; float random() { seed = seed * 534534569 + 42334571; return float(seed & 0xFFFFFF) / float(0xFFFFFF); } void main(void) { seed = gl_VertexID * 3895924481 + seedBase * 2434483; float lengthAngle = random() * 6.283185307; float widthAngle = random() * 3.141592654 - 1.570796327; float sinWidth = sin(widthAngle); float cosWidth = cos(widthAngle); float sinLength = sin(lengthAngle); float cosLength = cos(lengthAngle); vec3 v = vec3(cosWidth * cosLength, sinWidth, -sinLength * cosWidth) * random(); float realTime = max(time - age, 0.0) * timeFactor; float life = random() * 20.0 * float(realTime > 0.0); varFade = max(life - realTime, 0.0f) / life; varOffsetA = vec3(random(), random(), random()) * 2.0 - 1.0; varOffsetB = vec3(random(), random(), random()) * 2.0 - 1.0; gl_Position = vec4(position + v * realTime, 1.0); }