GPUParticles: Avoid particle respawning at too old location.

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@14889 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
vincentlj 2014-01-02 17:20:26 +00:00
parent 39d79c555a
commit 96841f5731
2 changed files with 6 additions and 4 deletions

View File

@ -23,9 +23,10 @@ void main(void)
vec4 initialposition = sourcematrix * vec4(particle_position_initial, 1.0);
vec4 adjusted_initial_velocity = tinvsourcematrix * vec4(particle_velocity_initial, 1.0);
adjusted_initial_velocity /= adjusted_initial_velocity.w;
new_particle_position = (lifetime < 1.) ? particle_position + particle_velocity.xyz * float(dt) : initialposition.xyz;
new_lifetime = (lifetime < 1.) ? lifetime + (float(dt)/lifetime_initial) : 0.;
new_particle_velocity = (lifetime < 1.) ? particle_velocity : adjusted_initial_velocity.xyz;
float adjusted_lifetime = lifetime + (float(dt)/lifetime_initial);
new_particle_position = (adjusted_lifetime < 1.) ? particle_position + particle_velocity.xyz * float(dt) : initialposition.xyz;
new_lifetime = (adjusted_lifetime < 1.) ? adjusted_lifetime : 0.;
new_particle_velocity = (adjusted_lifetime < 1.) ? particle_velocity : adjusted_initial_velocity.xyz;
new_size = size_initial;
gl_Position = vec4(0.);
}

View File

@ -246,6 +246,7 @@ ParticleSystemProxy::ParticleSystemProxy(bool createDefaultEmitter,
fakemat.MaterialType = irr_driver->getShader(ES_RAIN);
fakemat.Thickness = 200;
fakemat.setTexture(0, getMaterial(0).getTexture(0));
fakemat.BlendOperation = video::EBO_NONE;
glGenBuffers(1, &initial_values_buffer);
glGenBuffers(2, tfb_buffers);
if (quad_vertex_buffer)
@ -582,7 +583,7 @@ void ParticleSystemProxy::simulate()
glVertexAttribPointer(attrib_initial_size, 1, GL_FLOAT, GL_FALSE, COMPONENTCOUNT * sizeof(float), (GLvoid*)(7 * sizeof(float)));
glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, tfb_buffers[1]);
glUniform1i(uniform_dt, 16);
glUniform1i(uniform_dt, timediff);
glUniformMatrix4fv(uniform_sourcematrix, 1, GL_FALSE, matrix.pointer());
glUniformMatrix4fv(uniform_tinvsourcematrix, 1, GL_FALSE, tinvmatrix.pointer());
glBeginTransformFeedback(GL_POINTS);