Port heightmap simulation shader.
This commit is contained in:
@@ -314,20 +314,13 @@ void ParticleSystemProxy::simulateHeightmap()
|
||||
int timediff = int(GUIEngine::getLatestDt() * 1000.f);
|
||||
int active_count = getEmitter()->getMaxLifeTime() * getEmitter()->getMaxParticlesPerSecond() / 1000;
|
||||
core::matrix4 matrix = getAbsoluteTransformation();
|
||||
glUseProgram(ParticleShader::HeightmapSimulationShader::Program);
|
||||
glUseProgram(ParticleShader::HeightmapSimulationShader::getInstance()->Program);
|
||||
glEnable(GL_RASTERIZER_DISCARD);
|
||||
|
||||
glUniform1i(ParticleShader::HeightmapSimulationShader::uniform_dt, timediff);
|
||||
glUniform1i(ParticleShader::HeightmapSimulationShader::uniform_level, active_count);
|
||||
glUniformMatrix4fv(ParticleShader::HeightmapSimulationShader::uniform_sourcematrix, 1, GL_FALSE, matrix.pointer());
|
||||
glUniform1f(ParticleShader::HeightmapSimulationShader::uniform_size_increase_factor, size_increase_factor);
|
||||
glActiveTexture(GL_TEXTURE2);
|
||||
glActiveTexture(GL_TEXTURE0 + ParticleShader::HeightmapSimulationShader::getInstance()->TU_heightmap);
|
||||
glBindTexture(GL_TEXTURE_BUFFER, heightmaptexture);
|
||||
glUniform1i(ParticleShader::HeightmapSimulationShader::uniform_heightmap, 2);
|
||||
glUniform1f(ParticleShader::HeightmapSimulationShader::uniform_track_x, track_x);
|
||||
glUniform1f(ParticleShader::HeightmapSimulationShader::uniform_track_z, track_z);
|
||||
glUniform1f(ParticleShader::HeightmapSimulationShader::uniform_track_x_len, track_x_len);
|
||||
glUniform1f(ParticleShader::HeightmapSimulationShader::uniform_track_z_len, track_z_len);
|
||||
|
||||
ParticleShader::HeightmapSimulationShader::getInstance()->setUniforms(matrix, timediff, active_count, size_increase_factor, track_x, track_x_len, track_z, track_z_len);
|
||||
|
||||
glBindVertexArray(current_simulation_vao);
|
||||
glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, tfb_buffers[1]);
|
||||
|
||||
@@ -414,7 +414,6 @@ void Shaders::loadShaders()
|
||||
LightShader::PointLightShader::init();
|
||||
MeshShader::SkyboxShader::init();
|
||||
MeshShader::ViewFrustrumShader::init();
|
||||
ParticleShader::HeightmapSimulationShader::init();
|
||||
UtilShader::ColoredLine::init();
|
||||
}
|
||||
|
||||
@@ -1388,26 +1387,7 @@ namespace ParticleShader
|
||||
AssignUniforms("sourcematrix", "dt", "level", "size_increase_factor");
|
||||
}
|
||||
|
||||
GLuint HeightmapSimulationShader::Program;
|
||||
GLuint HeightmapSimulationShader::attrib_position;
|
||||
GLuint HeightmapSimulationShader::attrib_velocity;
|
||||
GLuint HeightmapSimulationShader::attrib_lifetime;
|
||||
GLuint HeightmapSimulationShader::attrib_initial_position;
|
||||
GLuint HeightmapSimulationShader::attrib_initial_velocity;
|
||||
GLuint HeightmapSimulationShader::attrib_initial_lifetime;
|
||||
GLuint HeightmapSimulationShader::attrib_size;
|
||||
GLuint HeightmapSimulationShader::attrib_initial_size;
|
||||
GLuint HeightmapSimulationShader::uniform_sourcematrix;
|
||||
GLuint HeightmapSimulationShader::uniform_dt;
|
||||
GLuint HeightmapSimulationShader::uniform_level;
|
||||
GLuint HeightmapSimulationShader::uniform_size_increase_factor;
|
||||
GLuint HeightmapSimulationShader::uniform_track_x;
|
||||
GLuint HeightmapSimulationShader::uniform_track_z;
|
||||
GLuint HeightmapSimulationShader::uniform_track_x_len;
|
||||
GLuint HeightmapSimulationShader::uniform_track_z_len;
|
||||
GLuint HeightmapSimulationShader::uniform_heightmap;
|
||||
|
||||
void HeightmapSimulationShader::init()
|
||||
HeightmapSimulationShader::HeightmapSimulationShader()
|
||||
{
|
||||
const char *varyings[] = {
|
||||
"new_particle_position",
|
||||
@@ -1416,26 +1396,9 @@ namespace ParticleShader
|
||||
"new_size",
|
||||
};
|
||||
Program = LoadTFBProgram(file_manager->getAsset("shaders/particlesimheightmap.vert").c_str(), varyings, 4);
|
||||
|
||||
uniform_dt = glGetUniformLocation(Program, "dt");
|
||||
uniform_sourcematrix = glGetUniformLocation(Program, "sourcematrix");
|
||||
uniform_level = glGetUniformLocation(Program, "level");
|
||||
uniform_size_increase_factor = glGetUniformLocation(Program, "size_increase_factor");
|
||||
|
||||
attrib_position = glGetAttribLocation(Program, "particle_position");
|
||||
attrib_lifetime = glGetAttribLocation(Program, "lifetime");
|
||||
attrib_velocity = glGetAttribLocation(Program, "particle_velocity");
|
||||
attrib_size = glGetAttribLocation(Program, "size");
|
||||
attrib_initial_position = glGetAttribLocation(Program, "particle_position_initial");
|
||||
attrib_initial_lifetime = glGetAttribLocation(Program, "lifetime_initial");
|
||||
attrib_initial_velocity = glGetAttribLocation(Program, "particle_velocity_initial");
|
||||
attrib_initial_size = glGetAttribLocation(Program, "size_initial");
|
||||
|
||||
uniform_heightmap = glGetUniformLocation(Program, "heightmap");
|
||||
uniform_track_x = glGetUniformLocation(Program, "track_x");
|
||||
uniform_track_x_len = glGetUniformLocation(Program, "track_x_len");
|
||||
uniform_track_z = glGetUniformLocation(Program, "track_z");
|
||||
uniform_track_z_len = glGetUniformLocation(Program, "track_z_len");
|
||||
TU_heightmap = 2;
|
||||
AssignTextureUnit(Program, TexUnit(TU_heightmap, "heightmap"));
|
||||
AssignUniforms("sourcematrix", "dt", "level", "size_increase_factor", "track_x", "track_x_len", "track_z", "track_z_len");
|
||||
}
|
||||
|
||||
SimpleParticleRender::SimpleParticleRender()
|
||||
|
||||
@@ -494,15 +494,12 @@ public:
|
||||
|
||||
|
||||
|
||||
class HeightmapSimulationShader
|
||||
class HeightmapSimulationShader : public ShaderHelperSingleton<HeightmapSimulationShader, core::matrix4, int, int, float, float, float, float, float>
|
||||
{
|
||||
public:
|
||||
static GLuint Program;
|
||||
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_dt, uniform_level, uniform_size_increase_factor;
|
||||
static GLuint uniform_track_x, uniform_track_z, uniform_track_x_len, uniform_track_z_len, uniform_heightmap;
|
||||
GLuint TU_heightmap;
|
||||
|
||||
static void init();
|
||||
HeightmapSimulationShader();
|
||||
};
|
||||
|
||||
class SimpleParticleRender : public ShaderHelperSingleton<SimpleParticleRender, video::SColorf, video::SColorf>
|
||||
|
||||
Reference in New Issue
Block a user