GPUParticles: Fix adjusted_initial_velocity computation.
Thank to Auria and hiker for their help. git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@14947 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
6e3466c838
commit
51023ceb81
@ -1,7 +1,6 @@
|
|||||||
#version 130
|
#version 130
|
||||||
uniform int dt;
|
uniform int dt;
|
||||||
uniform mat4 sourcematrix;
|
uniform mat4 sourcematrix;
|
||||||
uniform mat4 tinvsourcematrix;
|
|
||||||
uniform int level;
|
uniform int level;
|
||||||
uniform float size_increase_factor;
|
uniform float size_increase_factor;
|
||||||
|
|
||||||
@ -23,8 +22,7 @@ out float new_size;
|
|||||||
void main(void)
|
void main(void)
|
||||||
{
|
{
|
||||||
vec4 initialposition = sourcematrix * vec4(particle_position_initial, 1.0);
|
vec4 initialposition = sourcematrix * vec4(particle_position_initial, 1.0);
|
||||||
vec4 adjusted_initial_velocity = tinvsourcematrix * vec4(particle_velocity_initial, 1.0);
|
vec4 adjusted_initial_velocity = sourcematrix * vec4(particle_position_initial + particle_velocity_initial, 1.0) - initialposition;
|
||||||
adjusted_initial_velocity /= adjusted_initial_velocity.w;
|
|
||||||
float adjusted_lifetime = lifetime + (float(dt)/lifetime_initial);
|
float adjusted_lifetime = lifetime + (float(dt)/lifetime_initial);
|
||||||
bool reset = (adjusted_lifetime > 1.) && (gl_VertexID <= level);
|
bool reset = (adjusted_lifetime > 1.) && (gl_VertexID <= level);
|
||||||
reset = reset || (lifetime < 0.);
|
reset = reset || (lifetime < 0.);
|
||||||
|
@ -240,7 +240,6 @@ GLuint ParticleSystemProxy::attrib_initial_lifetime;
|
|||||||
GLuint ParticleSystemProxy::attrib_size;
|
GLuint ParticleSystemProxy::attrib_size;
|
||||||
GLuint ParticleSystemProxy::attrib_initial_size;
|
GLuint ParticleSystemProxy::attrib_initial_size;
|
||||||
GLuint ParticleSystemProxy::uniform_sourcematrix;
|
GLuint ParticleSystemProxy::uniform_sourcematrix;
|
||||||
GLuint ParticleSystemProxy::uniform_tinvsourcematrix;
|
|
||||||
GLuint ParticleSystemProxy::uniform_dt;
|
GLuint ParticleSystemProxy::uniform_dt;
|
||||||
GLuint ParticleSystemProxy::uniform_level;
|
GLuint ParticleSystemProxy::uniform_level;
|
||||||
GLuint ParticleSystemProxy::uniform_size_increase_factor;
|
GLuint ParticleSystemProxy::uniform_size_increase_factor;
|
||||||
@ -315,7 +314,6 @@ void ParticleSystemProxy::setEmitter(scene::IParticleEmitter* emitter)
|
|||||||
|
|
||||||
uniform_dt = glGetUniformLocation(SimulationProgram, "dt");
|
uniform_dt = glGetUniformLocation(SimulationProgram, "dt");
|
||||||
uniform_sourcematrix = glGetUniformLocation(SimulationProgram, "sourcematrix");
|
uniform_sourcematrix = glGetUniformLocation(SimulationProgram, "sourcematrix");
|
||||||
uniform_tinvsourcematrix = glGetUniformLocation(SimulationProgram, "tinvsourcematrix");
|
|
||||||
uniform_level = glGetUniformLocation(SimulationProgram, "level");
|
uniform_level = glGetUniformLocation(SimulationProgram, "level");
|
||||||
uniform_size_increase_factor = glGetUniformLocation(SimulationProgram, "size_increase_factor");
|
uniform_size_increase_factor = glGetUniformLocation(SimulationProgram, "size_increase_factor");
|
||||||
|
|
||||||
@ -356,9 +354,6 @@ void ParticleSystemProxy::simulate()
|
|||||||
LastEmitTime = time;
|
LastEmitTime = time;
|
||||||
int active_count = getEmitter()->getMaxLifeTime() * getEmitter()->getMaxParticlesPerSecond() / 1000;
|
int active_count = getEmitter()->getMaxLifeTime() * getEmitter()->getMaxParticlesPerSecond() / 1000;
|
||||||
core::matrix4 matrix = getAbsoluteTransformation();
|
core::matrix4 matrix = getAbsoluteTransformation();
|
||||||
core::matrix4 tinvmatrix;
|
|
||||||
matrix.getInverse(tinvmatrix);
|
|
||||||
tinvmatrix = tinvmatrix.getTransposed();
|
|
||||||
glUseProgram(SimulationProgram);
|
glUseProgram(SimulationProgram);
|
||||||
glEnable(GL_RASTERIZER_DISCARD);
|
glEnable(GL_RASTERIZER_DISCARD);
|
||||||
glEnableVertexAttribArray(attrib_position);
|
glEnableVertexAttribArray(attrib_position);
|
||||||
@ -384,7 +379,6 @@ void ParticleSystemProxy::simulate()
|
|||||||
glUniform1i(uniform_dt, timediff);
|
glUniform1i(uniform_dt, timediff);
|
||||||
glUniform1i(uniform_level, active_count);
|
glUniform1i(uniform_level, active_count);
|
||||||
glUniformMatrix4fv(uniform_sourcematrix, 1, GL_FALSE, matrix.pointer());
|
glUniformMatrix4fv(uniform_sourcematrix, 1, GL_FALSE, matrix.pointer());
|
||||||
glUniformMatrix4fv(uniform_tinvsourcematrix, 1, GL_FALSE, tinvmatrix.pointer());
|
|
||||||
glUniform1f(uniform_size_increase_factor, size_increase_factor);
|
glUniform1f(uniform_size_increase_factor, size_increase_factor);
|
||||||
glBeginTransformFeedback(GL_POINTS);
|
glBeginTransformFeedback(GL_POINTS);
|
||||||
glDrawArrays(GL_POINTS, 0, count);
|
glDrawArrays(GL_POINTS, 0, count);
|
||||||
|
@ -33,7 +33,7 @@ protected:
|
|||||||
|
|
||||||
static GLuint SimulationProgram;
|
static GLuint SimulationProgram;
|
||||||
static GLuint attrib_position, attrib_velocity, attrib_lifetime, attrib_initial_position, attrib_initial_velocity, attrib_initial_lifetime, attrib_size, attrib_initial_size;
|
static GLuint attrib_position, attrib_velocity, attrib_lifetime, attrib_initial_position, attrib_initial_velocity, attrib_initial_lifetime, attrib_size, attrib_initial_size;
|
||||||
static GLuint uniform_sourcematrix, uniform_tinvsourcematrix, uniform_dt, uniform_level, uniform_size_increase_factor;
|
static GLuint uniform_sourcematrix, uniform_dt, uniform_level, uniform_size_increase_factor;
|
||||||
|
|
||||||
static GLuint RenderProgram;
|
static GLuint RenderProgram;
|
||||||
static GLuint attrib_pos, attrib_lf, attrib_quadcorner, attrib_texcoord, attrib_sz;
|
static GLuint attrib_pos, attrib_lf, attrib_quadcorner, attrib_texcoord, attrib_sz;
|
||||||
|
Loading…
Reference in New Issue
Block a user