How to do it...

  1. Within the vertex shader, add the following uniforms:
uniform float MinParticleSize = 0.1; 
uniform float MaxParticleSize = 2.5;
  1. Also, within the vertex shader, in the render function, we'll update the size of the particle based on its age:
void render() {
Transp = 0.0;
vec3 posCam = vec3(0.0);
if( VertexAge >= 0.0 ) {
float agePct = VertexAge / ParticleLifetime;
Transp = clamp(1.0 - agePct, 0, 1);
posCam =
(MV * vec4(VertexPosition,1)).xyz +
offsets[gl_VertexID] *
mix(MinParticleSize, MaxParticleSize, agePct);
}
TexCoord = texCoords[gl_VertexID];
gl_Position = Proj * vec4(posCam,1);
}
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.143.239