GPUParticles: Add an parameter to turn alpha additive particle on/off.
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@14876 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
be93478687
commit
9c163db7c7
@ -230,7 +230,7 @@ ParticleSystemProxy::ParticleSystemProxy(bool createDefaultEmitter,
|
||||
ISceneNode* parent, scene::ISceneManager* mgr, s32 id,
|
||||
const core::vector3df& position,
|
||||
const core::vector3df& rotation,
|
||||
const core::vector3df& scale) : CParticleSystemSceneNode(createDefaultEmitter, parent, mgr, id, position, rotation, scale) {
|
||||
const core::vector3df& scale) : CParticleSystemSceneNode(createDefaultEmitter, parent, mgr, id, position, rotation, scale), m_alpha_additive(false) {
|
||||
static const GLfloat quad_vertex[] = {
|
||||
-.5, -.5, 0., 0.,
|
||||
.5, -.5, 1., 0.,
|
||||
@ -244,6 +244,8 @@ ParticleSystemProxy::ParticleSystemProxy(bool createDefaultEmitter,
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
}
|
||||
|
||||
void ParticleSystemProxy::setAlphaAdditive(bool val) { m_alpha_additive = val; }
|
||||
|
||||
void ParticleSystemProxy::generateParticlesFromPointEmitter(scene::IParticlePointEmitter *emitter)
|
||||
{
|
||||
float *particles = new float[COMPONENTCOUNT * count], *initialvalue = new float[COMPONENTCOUNT * count];
|
||||
@ -485,7 +487,10 @@ void ParticleSystemProxy::draw()
|
||||
glEnable(GL_BLEND);
|
||||
core::matrix4 projm = irr_driver->getVideoDriver()->getTransform(video::ETS_PROJECTION);
|
||||
core::matrix4 viewm = irr_driver->getVideoDriver()->getTransform(video::ETS_VIEW);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
if (m_alpha_additive)
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
|
||||
else
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glUseProgram(RenderProgram);
|
||||
glEnableVertexAttribArray(attrib_pos);
|
||||
glEnableVertexAttribArray(attrib_lf);
|
||||
|
@ -31,6 +31,7 @@ class ParticleSystemProxy : public scene::CParticleSystemSceneNode {
|
||||
protected:
|
||||
GLuint quad_vertex_buffer;
|
||||
GLuint tfb_buffers[2], initial_values_buffer;
|
||||
bool m_alpha_additive;
|
||||
|
||||
GLuint SimulationProgram;
|
||||
GLuint attrib_position, attrib_velocity, attrib_lifetime, attrib_initial_position, attrib_initial_velocity, attrib_initial_lifetime, attrib_size, attrib_initial_size;
|
||||
@ -62,6 +63,7 @@ public:
|
||||
|
||||
virtual void setEmitter(scene::IParticleEmitter* emitter);
|
||||
virtual void render();
|
||||
void setAlphaAdditive(bool);
|
||||
};
|
||||
|
||||
class PointEmitter : public GPUParticle
|
||||
|
@ -335,6 +335,9 @@ public:
|
||||
void onMadeVisible(scene::IMeshBuffer* who);
|
||||
void onHidden(scene::IMeshBuffer* who);
|
||||
void isInitiallyHidden(scene::IMeshBuffer* who);
|
||||
/** For particle system : specify if the particle should be additively blended
|
||||
*/
|
||||
bool isAlphaAdditive() const { return !m_alpha_blending; }
|
||||
} ;
|
||||
|
||||
|
||||
|
@ -371,6 +371,7 @@ void ParticleEmitter::setParticleType(const ParticleKind* type)
|
||||
else
|
||||
{
|
||||
m_node = ParticleSystemProxy::addParticleNode();
|
||||
static_cast<ParticleSystemProxy *>(m_node)->setAlphaAdditive(type->getMaterial()->isAlphaAdditive());
|
||||
}
|
||||
|
||||
if (m_parent != NULL)
|
||||
|
Loading…
Reference in New Issue
Block a user