GPUParticles: Particles don't follow their source.
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@14838 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
ebb45f8de6
commit
d4b9ccf499
@ -1,6 +1,6 @@
|
||||
#version 130
|
||||
uniform int dt;
|
||||
uniform vec3 source;
|
||||
uniform mat4 sourcematrix;
|
||||
uniform int duration;
|
||||
|
||||
in vec3 particle_position;
|
||||
@ -13,7 +13,8 @@ out vec4 new_particle_velocity;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
new_particle_position = (lifetime > 0.) ? particle_position + particle_velocity.xyz * float(dt) : vec3(0., 0., 0.);
|
||||
vec4 initialposition = sourcematrix * vec4(0., 0., 0., 1.0);
|
||||
new_particle_position = (lifetime > 0.) ? particle_position + particle_velocity.xyz * float(dt) : initialposition.xyz;
|
||||
new_lifetime = (lifetime > 0.) ? lifetime - float(dt) : float(duration);
|
||||
new_particle_velocity = particle_velocity;
|
||||
gl_Position = vec4(0.);
|
||||
|
@ -234,7 +234,7 @@ PointEmitter::PointEmitter(scene::ISceneNode *parent,
|
||||
SimulationProgram = LoadTFBProgram(file_manager->getAsset("shaders/pointemitter.vert").c_str(), varyings, 3);
|
||||
loc_duration = glGetUniformLocation(SimulationProgram, "duration");
|
||||
loc_dt = glGetUniformLocation(SimulationProgram, "dt");
|
||||
loc_source = glGetUniformLocation(SimulationProgram, "source");
|
||||
loc_sourcematrix = glGetUniformLocation(SimulationProgram, "sourcematrix");
|
||||
loc_position = glGetAttribLocation(SimulationProgram, "particle_position");
|
||||
loc_lifetime = glGetAttribLocation(SimulationProgram, "lifetime");
|
||||
loc_velocity = glGetAttribLocation(SimulationProgram, "particle_velocity");
|
||||
@ -272,6 +272,7 @@ PointEmitter::PointEmitter(scene::ISceneNode *parent,
|
||||
|
||||
void PointEmitter::simulate()
|
||||
{
|
||||
core::matrix4 matrix = m_node->getAbsoluteTransformation();
|
||||
glUseProgram(SimulationProgram);
|
||||
glEnable(GL_RASTERIZER_DISCARD);
|
||||
glEnableVertexAttribArray(0);
|
||||
@ -285,7 +286,7 @@ void PointEmitter::simulate()
|
||||
|
||||
glUniform1i(loc_dt, 1);
|
||||
glUniform1i(loc_duration, duration);
|
||||
glUniform3f(loc_source, getPosition().X, getPosition().Y, getPosition().Z);
|
||||
glUniformMatrix4fv(loc_sourcematrix, 1, GL_FALSE, matrix.pointer());
|
||||
glBeginTransformFeedback(GL_POINTS);
|
||||
glDrawArrays(GL_POINTS, 0, count);
|
||||
glEndTransformFeedback();
|
||||
@ -298,13 +299,11 @@ void PointEmitter::simulate()
|
||||
|
||||
void PointEmitter::draw()
|
||||
{
|
||||
updateAbsolutePosition();
|
||||
glDisable(GL_ALPHA_TEST);
|
||||
glDepthMask(GL_FALSE);
|
||||
glEnable(GL_BLEND);
|
||||
core::matrix4 matrix = irr_driver->getVideoDriver()->getTransform(video::ETS_PROJECTION);
|
||||
matrix *= irr_driver->getVideoDriver()->getTransform(video::ETS_VIEW);
|
||||
matrix *= m_node->getAbsoluteTransformation();
|
||||
glEnable(GL_VERTEX_PROGRAM_POINT_SIZE);
|
||||
glEnable(GL_POINT_SPRITE);
|
||||
glBlendEquation(GL_FUNC_ADD);
|
||||
|
@ -29,7 +29,7 @@ class PointEmitter : public GPUParticle
|
||||
{
|
||||
protected:
|
||||
GLuint SimulationProgram, RenderProgram;
|
||||
GLuint loc_duration, loc_source, loc_dt, loc_matrix, loc_texture, loc_normal_and_depths, loc_screen, loc_invproj;
|
||||
GLuint loc_duration, loc_sourcematrix, loc_dt, loc_matrix, loc_texture, loc_normal_and_depths, loc_screen, loc_invproj;
|
||||
GLuint loc_position, loc_velocity, loc_lifetime;
|
||||
GLuint tfb_buffers[2];
|
||||
GLuint texture, normal_and_depth;
|
||||
|
Loading…
Reference in New Issue
Block a user