Factorise attribute location of simulation program.
This commit is contained in:
parent
e6eac5b57f
commit
8117260bf6
@ -9,15 +9,15 @@ uniform float track_x_len;
|
|||||||
uniform float track_z_len;
|
uniform float track_z_len;
|
||||||
uniform samplerBuffer heightmap;
|
uniform samplerBuffer heightmap;
|
||||||
|
|
||||||
in vec3 particle_position_initial;
|
layout (location = 4) in vec3 particle_position_initial;
|
||||||
in float lifetime_initial;
|
layout (location = 5) in float lifetime_initial;
|
||||||
in vec3 particle_velocity_initial;
|
layout (location = 6) in vec3 particle_velocity_initial;
|
||||||
in float size_initial;
|
layout (location = 7) in float size_initial;
|
||||||
|
|
||||||
in vec3 particle_position;
|
layout (location = 0) in vec3 particle_position;
|
||||||
in float lifetime;
|
layout (location = 1) in float lifetime;
|
||||||
in vec3 particle_velocity;
|
layout (location = 2) in vec3 particle_velocity;
|
||||||
in float size;
|
layout (location = 3) in float size;
|
||||||
|
|
||||||
out vec3 new_particle_position;
|
out vec3 new_particle_position;
|
||||||
out float new_lifetime;
|
out float new_lifetime;
|
||||||
|
@ -3,15 +3,15 @@ uniform mat4 sourcematrix;
|
|||||||
uniform int level;
|
uniform int level;
|
||||||
uniform float size_increase_factor;
|
uniform float size_increase_factor;
|
||||||
|
|
||||||
in vec3 particle_position_initial;
|
layout (location = 4) in vec3 particle_position_initial;
|
||||||
in float lifetime_initial;
|
layout (location = 5) in float lifetime_initial;
|
||||||
in vec3 particle_velocity_initial;
|
layout (location = 6) in vec3 particle_velocity_initial;
|
||||||
in float size_initial;
|
layout (location = 7) in float size_initial;
|
||||||
|
|
||||||
in vec3 particle_position;
|
layout (location = 0) in vec3 particle_position;
|
||||||
in float lifetime;
|
layout (location = 1) in float lifetime;
|
||||||
in vec3 particle_velocity;
|
layout (location = 2) in vec3 particle_velocity;
|
||||||
in float size;
|
layout (location = 3) in float size;
|
||||||
|
|
||||||
out vec3 new_particle_position;
|
out vec3 new_particle_position;
|
||||||
out float new_lifetime;
|
out float new_lifetime;
|
||||||
|
@ -286,44 +286,29 @@ void ParticleSystemProxy::AppendQuaternionRenderingVAO(GLuint QuaternionBuffer)
|
|||||||
glVertexAttribDivisor(6, 1);
|
glVertexAttribDivisor(6, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
void ParticleSystemProxy::CommonSimulationVAO(GLuint position_vbo, GLuint initialValues_vbo)
|
||||||
void setSimulationBind(GLuint position_vbo, GLuint initialValues_vbo)
|
|
||||||
{
|
{
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, position_vbo);
|
glBindBuffer(GL_ARRAY_BUFFER, position_vbo);
|
||||||
glEnableVertexAttribArray(T::attrib_position);
|
glEnableVertexAttribArray(0);
|
||||||
glVertexAttribPointer(T::attrib_position, 3, GL_FLOAT, GL_FALSE, sizeof(ParticleSystemProxy::ParticleData), (GLvoid*)0);
|
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(ParticleSystemProxy::ParticleData), (GLvoid*)0);
|
||||||
glEnableVertexAttribArray(T::attrib_lifetime);
|
glEnableVertexAttribArray(1);
|
||||||
glVertexAttribPointer(T::attrib_lifetime, 1, GL_FLOAT, GL_FALSE, sizeof(ParticleSystemProxy::ParticleData), (GLvoid*)(3 * sizeof(float)));
|
glVertexAttribPointer(1, 1, GL_FLOAT, GL_FALSE, sizeof(ParticleSystemProxy::ParticleData), (GLvoid*)(3 * sizeof(float)));
|
||||||
glEnableVertexAttribArray(T::attrib_velocity);
|
glEnableVertexAttribArray(2);
|
||||||
glVertexAttribPointer(T::attrib_velocity, 4, GL_FLOAT, GL_FALSE, sizeof(ParticleSystemProxy::ParticleData), (GLvoid*)(4 * sizeof(float)));
|
glVertexAttribPointer(2, 4, GL_FLOAT, GL_FALSE, sizeof(ParticleSystemProxy::ParticleData), (GLvoid*)(4 * sizeof(float)));
|
||||||
if (T::attrib_size < 30)
|
glEnableVertexAttribArray(3);
|
||||||
{
|
glVertexAttribPointer(3, 1, GL_FLOAT, GL_FALSE, sizeof(ParticleSystemProxy::ParticleData), (GLvoid*)(7 * sizeof(float)));
|
||||||
glEnableVertexAttribArray(T::attrib_size);
|
|
||||||
glVertexAttribPointer(T::attrib_size, 1, GL_FLOAT, GL_FALSE, sizeof(ParticleSystemProxy::ParticleData), (GLvoid*)(7 * sizeof(float)));
|
|
||||||
}
|
|
||||||
|
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, initialValues_vbo);
|
glBindBuffer(GL_ARRAY_BUFFER, initialValues_vbo);
|
||||||
glEnableVertexAttribArray(T::attrib_initial_position);
|
glEnableVertexAttribArray(4);
|
||||||
glVertexAttribPointer(T::attrib_initial_position, 3, GL_FLOAT, GL_FALSE, sizeof(ParticleSystemProxy::ParticleData), (GLvoid*)0);
|
glVertexAttribPointer(4, 3, GL_FLOAT, GL_FALSE, sizeof(ParticleSystemProxy::ParticleData), (GLvoid*)0);
|
||||||
glEnableVertexAttribArray(T::attrib_initial_lifetime);
|
glEnableVertexAttribArray(5);
|
||||||
glVertexAttribPointer(T::attrib_initial_lifetime, 1, GL_FLOAT, GL_FALSE, sizeof(ParticleSystemProxy::ParticleData), (GLvoid*)(3 * sizeof(float)));
|
glVertexAttribPointer(5, 1, GL_FLOAT, GL_FALSE, sizeof(ParticleSystemProxy::ParticleData), (GLvoid*)(3 * sizeof(float)));
|
||||||
glEnableVertexAttribArray(T::attrib_initial_velocity);
|
glEnableVertexAttribArray(6);
|
||||||
glVertexAttribPointer(T::attrib_initial_velocity, 4, GL_FLOAT, GL_FALSE, sizeof(ParticleSystemProxy::ParticleData), (GLvoid*)(4 * sizeof(float)));
|
glVertexAttribPointer(6, 4, GL_FLOAT, GL_FALSE, sizeof(ParticleSystemProxy::ParticleData), (GLvoid*)(4 * sizeof(float)));
|
||||||
glEnableVertexAttribArray(T::attrib_initial_size);
|
glEnableVertexAttribArray(7);
|
||||||
glVertexAttribPointer(T::attrib_initial_size, 1, GL_FLOAT, GL_FALSE, sizeof(ParticleSystemProxy::ParticleData), (GLvoid*)(7 * sizeof(float)));
|
glVertexAttribPointer(7, 1, GL_FLOAT, GL_FALSE, sizeof(ParticleSystemProxy::ParticleData), (GLvoid*)(7 * sizeof(float)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ParticleSystemProxy::SimpleSimulationBind(GLuint PositionBuffer, GLuint InitialValuesBuffer)
|
|
||||||
{
|
|
||||||
setSimulationBind<ParticleShader::SimpleSimulationShader>(PositionBuffer, InitialValuesBuffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ParticleSystemProxy::HeightmapSimulationBind(GLuint PositionBuffer, GLuint InitialValuesBuffer)
|
|
||||||
{
|
|
||||||
setSimulationBind<ParticleShader::HeightmapSimulationShader>(PositionBuffer, InitialValuesBuffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void ParticleSystemProxy::simulateHeightmap()
|
void ParticleSystemProxy::simulateHeightmap()
|
||||||
{
|
{
|
||||||
int timediff = int(GUIEngine::getLatestDt() * 1000.f);
|
int timediff = int(GUIEngine::getLatestDt() * 1000.f);
|
||||||
@ -453,15 +438,9 @@ void ParticleSystemProxy::generateVAOs()
|
|||||||
glGenVertexArrays(1, &non_current_simulation_vao);
|
glGenVertexArrays(1, &non_current_simulation_vao);
|
||||||
|
|
||||||
glBindVertexArray(current_simulation_vao);
|
glBindVertexArray(current_simulation_vao);
|
||||||
if (has_height_map)
|
CommonSimulationVAO(tfb_buffers[0], initial_values_buffer);
|
||||||
HeightmapSimulationBind(tfb_buffers[0], initial_values_buffer);
|
|
||||||
else
|
|
||||||
SimpleSimulationBind(tfb_buffers[0], initial_values_buffer);
|
|
||||||
glBindVertexArray(non_current_simulation_vao);
|
glBindVertexArray(non_current_simulation_vao);
|
||||||
if (has_height_map)
|
CommonSimulationVAO(tfb_buffers[1], initial_values_buffer);
|
||||||
HeightmapSimulationBind(tfb_buffers[1], initial_values_buffer);
|
|
||||||
else
|
|
||||||
SimpleSimulationBind(tfb_buffers[1], initial_values_buffer);
|
|
||||||
|
|
||||||
float *quaternions = new float[4 * count];
|
float *quaternions = new float[4 * count];
|
||||||
glBindVertexArray(0);
|
glBindVertexArray(0);
|
||||||
|
@ -25,8 +25,7 @@ protected:
|
|||||||
unsigned count;
|
unsigned count;
|
||||||
static void CommonRenderingVAO(GLuint PositionBuffer);
|
static void CommonRenderingVAO(GLuint PositionBuffer);
|
||||||
static void AppendQuaternionRenderingVAO(GLuint QuaternionBuffer);
|
static void AppendQuaternionRenderingVAO(GLuint QuaternionBuffer);
|
||||||
static void SimpleSimulationBind(GLuint PositionBuffer, GLuint InitialValuesBuffer);
|
static void CommonSimulationVAO(GLuint position_vbo, GLuint initialValues_vbo);
|
||||||
static void HeightmapSimulationBind(GLuint PositionBuffer, GLuint InitialValuesBuffer);
|
|
||||||
|
|
||||||
void generateVAOs();
|
void generateVAOs();
|
||||||
void cleanGL();
|
void cleanGL();
|
||||||
|
Loading…
Reference in New Issue
Block a user