From 51023ceb81b78ab7f2bd396742a287556589f6bb Mon Sep 17 00:00:00 2001 From: vincentlj Date: Tue, 7 Jan 2014 00:04:43 +0000 Subject: [PATCH] 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 --- data/shaders/pointemitter.vert | 4 +--- src/graphics/gpuparticles.cpp | 6 ------ src/graphics/gpuparticles.h | 2 +- 3 files changed, 2 insertions(+), 10 deletions(-) diff --git a/data/shaders/pointemitter.vert b/data/shaders/pointemitter.vert index 48a192906..9a448228e 100644 --- a/data/shaders/pointemitter.vert +++ b/data/shaders/pointemitter.vert @@ -1,7 +1,6 @@ #version 130 uniform int dt; uniform mat4 sourcematrix; -uniform mat4 tinvsourcematrix; uniform int level; uniform float size_increase_factor; @@ -23,8 +22,7 @@ out float new_size; 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; + vec4 adjusted_initial_velocity = sourcematrix * vec4(particle_position_initial + particle_velocity_initial, 1.0) - initialposition; float adjusted_lifetime = lifetime + (float(dt)/lifetime_initial); bool reset = (adjusted_lifetime > 1.) && (gl_VertexID <= level); reset = reset || (lifetime < 0.); diff --git a/src/graphics/gpuparticles.cpp b/src/graphics/gpuparticles.cpp index 2cbafa660..1625d7cbb 100644 --- a/src/graphics/gpuparticles.cpp +++ b/src/graphics/gpuparticles.cpp @@ -240,7 +240,6 @@ GLuint ParticleSystemProxy::attrib_initial_lifetime; GLuint ParticleSystemProxy::attrib_size; GLuint ParticleSystemProxy::attrib_initial_size; GLuint ParticleSystemProxy::uniform_sourcematrix; -GLuint ParticleSystemProxy::uniform_tinvsourcematrix; GLuint ParticleSystemProxy::uniform_dt; GLuint ParticleSystemProxy::uniform_level; GLuint ParticleSystemProxy::uniform_size_increase_factor; @@ -315,7 +314,6 @@ void ParticleSystemProxy::setEmitter(scene::IParticleEmitter* emitter) uniform_dt = glGetUniformLocation(SimulationProgram, "dt"); uniform_sourcematrix = glGetUniformLocation(SimulationProgram, "sourcematrix"); - uniform_tinvsourcematrix = glGetUniformLocation(SimulationProgram, "tinvsourcematrix"); uniform_level = glGetUniformLocation(SimulationProgram, "level"); uniform_size_increase_factor = glGetUniformLocation(SimulationProgram, "size_increase_factor"); @@ -356,9 +354,6 @@ void ParticleSystemProxy::simulate() LastEmitTime = time; int active_count = getEmitter()->getMaxLifeTime() * getEmitter()->getMaxParticlesPerSecond() / 1000; core::matrix4 matrix = getAbsoluteTransformation(); - core::matrix4 tinvmatrix; - matrix.getInverse(tinvmatrix); - tinvmatrix = tinvmatrix.getTransposed(); glUseProgram(SimulationProgram); glEnable(GL_RASTERIZER_DISCARD); glEnableVertexAttribArray(attrib_position); @@ -384,7 +379,6 @@ void ParticleSystemProxy::simulate() glUniform1i(uniform_dt, timediff); glUniform1i(uniform_level, active_count); glUniformMatrix4fv(uniform_sourcematrix, 1, GL_FALSE, matrix.pointer()); - glUniformMatrix4fv(uniform_tinvsourcematrix, 1, GL_FALSE, tinvmatrix.pointer()); glUniform1f(uniform_size_increase_factor, size_increase_factor); glBeginTransformFeedback(GL_POINTS); glDrawArrays(GL_POINTS, 0, count); diff --git a/src/graphics/gpuparticles.h b/src/graphics/gpuparticles.h index a6579919f..4f0dac86d 100644 --- a/src/graphics/gpuparticles.h +++ b/src/graphics/gpuparticles.h @@ -33,7 +33,7 @@ protected: 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 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 attrib_pos, attrib_lf, attrib_quadcorner, attrib_texcoord, attrib_sz;