Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #version 330
- // Uniforms: Transformation Matrices
- uniform mat4 matrixProjection;
- uniform mat4 matrixModelView;
- // uniform mat4 matrixView; - not in use
- // Particle-specific Uniforms
- uniform vec3 initialPos = vec3(0, 0, 0); // Initial Position (source of the fountain)
- uniform vec3 gravity = vec3(0.0, -0.05, 0.0); // Gravity Acceleration in world coords
- uniform float particleLifetime; // Max Particle Lifetime
- uniform float time; // Animation Time
- uniform float scaleFactor = 1.0; // Scale factor (for setting the point size)
- // Special Vertex Attributes
- layout (location = 0) in vec3 aVelocity; // Particle initial velocity
- layout (location = 1) in float aStartTime; // Particle "birth" time
- // Output Variable (sent to Fragment Shader)
- out float age; // age of the particle (0..1)
- out vec4 position; // needed to determine the size of a droplet
- void main()
- {
- float t = mod(time - aStartTime, particleLifetime);
- vec3 pos = initialPos + aVelocity * t + gravity * t * t;
- age = t / particleLifetime;
- // calculate position (normal calculation not applicable here)
- position = matrixModelView * vec4(pos, 1.0);
- gl_Position = matrixProjection * position;
- gl_PointSize = scaleFactor * clamp(10 / length(position), 1, 5);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement