Also factorize particles related state changes.
This commit is contained in:
parent
a9258500b8
commit
e93cfd8b8e
@ -415,9 +415,6 @@ void ParticleSystemProxy::setEmitter(scene::IParticleEmitter* emitter)
|
||||
return;
|
||||
has_height_map = false;
|
||||
flip = false;
|
||||
// Pass a fake material type to force irrlicht to update its internal states on rendering
|
||||
setMaterialType(irr_driver->getShader(ES_RAIN));
|
||||
setAutomaticCulling(0);
|
||||
|
||||
count = emitter->getMaxParticlesPerSecond() * emitter->getMaxLifeTime() / 1000;
|
||||
switch (emitter->getType())
|
||||
@ -527,11 +524,6 @@ void ParticleSystemProxy::simulate()
|
||||
|
||||
void ParticleSystemProxy::drawFlip()
|
||||
{
|
||||
glDepthMask(GL_FALSE);
|
||||
glDisable(GL_CULL_FACE);
|
||||
glEnable(GL_BLEND);
|
||||
|
||||
glBlendEquation(GL_FUNC_ADD);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
|
||||
glUseProgram(ParticleShader::FlipParticleRender::Program);
|
||||
|
||||
@ -547,20 +539,10 @@ void ParticleSystemProxy::drawFlip()
|
||||
|
||||
glBindVertexArray(current_rendering_flip_vao);
|
||||
glDrawArraysInstanced(GL_TRIANGLE_STRIP, 0, 4, count);
|
||||
|
||||
glBindVertexArray(0);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glDisable(GL_BLEND);
|
||||
|
||||
}
|
||||
|
||||
void ParticleSystemProxy::drawNotFlip()
|
||||
{
|
||||
glDepthMask(GL_FALSE);
|
||||
glDisable(GL_CULL_FACE);
|
||||
glEnable(GL_BLEND);
|
||||
|
||||
if (m_alpha_additive)
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
|
||||
else
|
||||
@ -579,12 +561,6 @@ void ParticleSystemProxy::drawNotFlip()
|
||||
|
||||
glBindVertexArray(current_rendering_vao);
|
||||
glDrawArraysInstanced(GL_TRIANGLE_STRIP, 0, 4, count);
|
||||
|
||||
glBindVertexArray(0);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glDisable(GL_BLEND);
|
||||
|
||||
}
|
||||
|
||||
void ParticleSystemProxy::draw()
|
||||
@ -603,10 +579,6 @@ void ParticleSystemProxy::render() {
|
||||
}
|
||||
simulate();
|
||||
draw();
|
||||
// We need to force irrlicht to update its internal states
|
||||
irr::video::IVideoDriver * const drv = irr_driver->getVideoDriver();
|
||||
drv->setMaterial(fakemat);
|
||||
static_cast<irr::video::COpenGLDriver*>(drv)->setRenderStates3DMode();
|
||||
}
|
||||
|
||||
void ParticleSystemProxy::OnRegisterSceneNode()
|
||||
|
@ -309,6 +309,10 @@ void IrrDriver::renderGLSL(float dt)
|
||||
|
||||
PROFILER_PUSH_CPU_MARKER("- Particles", 0xFF, 0xFF, 0x00);
|
||||
m_renderpass = scene::ESNRP_CAMERA | scene::ESNRP_TRANSPARENT_EFFECT;
|
||||
glDepthMask(GL_FALSE);
|
||||
glDisable(GL_CULL_FACE);
|
||||
glEnable(GL_BLEND);
|
||||
glBlendEquation(GL_FUNC_ADD);
|
||||
m_scene_manager->drawAll(m_renderpass);
|
||||
PROFILER_POP_CPU_MARKER();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user