SHARE
TWEET

Untitled

a guest Apr 10th, 2019 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #version 330
  2.  
  3. // Uniforms: Transformation Matrices
  4. uniform mat4 matrixProjection;
  5. uniform mat4 matrixModelView;
  6. // uniform mat4 matrixView; - not in use
  7.  
  8. // Particle-specific Uniforms
  9. uniform vec3 initialPos = vec3(0, 0, 0);            // Initial Position (source of the fountain)
  10. uniform vec3 gravity = vec3(0.0, -0.05, 0.0);       // Gravity Acceleration in world coords
  11. uniform float particleLifetime;                     // Max Particle Lifetime
  12. uniform float time;                                 // Animation Time
  13.  
  14. uniform float scaleFactor = 1.0;            // Scale factor (for setting the point size)
  15.  
  16. // Special Vertex Attributes
  17. layout (location = 0) in vec3 aVelocity;            // Particle initial velocity
  18. layout (location = 1) in float aStartTime;          // Particle "birth" time
  19.  
  20. // Output Variable (sent to Fragment Shader)
  21. out float age;                              // age of the particle (0..1)
  22. out vec4 position;                          // needed to determine the size of a droplet
  23.  
  24. void main()
  25. {
  26.     float t = mod(time - aStartTime, particleLifetime);
  27.     vec3 pos = initialPos + aVelocity * t + gravity * t * t;
  28.     age = t / particleLifetime;
  29.  
  30.     // calculate position (normal calculation not applicable here)
  31.     position = matrixModelView * vec4(pos, 1.0);
  32.     gl_Position = matrixProjection * position;
  33.  
  34.     gl_PointSize = scaleFactor * clamp(10 / length(position), 1, 5);
  35. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top