|
@@ -56499,21 +56499,25 @@ var BABYLON;
|
|
|
return particleEmitter;
|
|
|
};
|
|
|
/**
|
|
|
- * Source color is added to the destination color without alpha affecting the result.
|
|
|
+ * Source color is added to the destination color without alpha affecting the result
|
|
|
*/
|
|
|
BaseParticleSystem.BLENDMODE_ONEONE = 0;
|
|
|
/**
|
|
|
- * Blend current color and particle color using particle’s alpha.
|
|
|
+ * Blend current color and particle color using particle’s alpha
|
|
|
*/
|
|
|
BaseParticleSystem.BLENDMODE_STANDARD = 1;
|
|
|
/**
|
|
|
- * Add current color and particle color multiplied by particle’s alpha.
|
|
|
+ * Add current color and particle color multiplied by particle’s alpha
|
|
|
*/
|
|
|
BaseParticleSystem.BLENDMODE_ADD = 2;
|
|
|
/**
|
|
|
* Multiply current color with particle color
|
|
|
*/
|
|
|
BaseParticleSystem.BLENDMODE_MULTIPLY = 3;
|
|
|
+ /**
|
|
|
+ * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
|
|
|
+ */
|
|
|
+ BaseParticleSystem.BLENDMODE_MULTIPLYADD = 4;
|
|
|
return BaseParticleSystem;
|
|
|
}());
|
|
|
BABYLON.BaseParticleSystem = BaseParticleSystem;
|
|
@@ -57472,6 +57476,12 @@ var BABYLON;
|
|
|
this._vertexData[offset++] = particle.direction.z;
|
|
|
}
|
|
|
}
|
|
|
+ if (this._useRampGradients) {
|
|
|
+ this._vertexData[offset++] = particle.remapData.x;
|
|
|
+ this._vertexData[offset++] = particle.remapData.y;
|
|
|
+ this._vertexData[offset++] = particle.remapData.z;
|
|
|
+ this._vertexData[offset++] = particle.remapData.w;
|
|
|
+ }
|
|
|
if (!this._useInstancing) {
|
|
|
if (this._isAnimationSheetEnabled) {
|
|
|
if (offsetX === 0)
|
|
@@ -57486,12 +57496,6 @@ var BABYLON;
|
|
|
this._vertexData[offset++] = offsetX;
|
|
|
this._vertexData[offset++] = offsetY;
|
|
|
}
|
|
|
- if (this._useRampGradients) {
|
|
|
- this._vertexData[offset++] = particle.remapData.x;
|
|
|
- this._vertexData[offset++] = particle.remapData.y;
|
|
|
- this._vertexData[offset++] = particle.remapData.z;
|
|
|
- this._vertexData[offset++] = particle.remapData.w;
|
|
|
- }
|
|
|
};
|
|
|
ParticleSystem.prototype._stopSubEmitters = function () {
|
|
|
if (!this.activeSubSystems) {
|
|
@@ -57715,7 +57719,7 @@ var BABYLON;
|
|
|
}
|
|
|
return effectCreationOption;
|
|
|
};
|
|
|
- ParticleSystem.prototype._getEffect = function () {
|
|
|
+ ParticleSystem.prototype._getEffect = function (blendMode) {
|
|
|
if (this._customEffect) {
|
|
|
return this._customEffect;
|
|
|
}
|
|
@@ -57736,7 +57740,7 @@ var BABYLON;
|
|
|
if (this._isAnimationSheetEnabled) {
|
|
|
defines.push("#define ANIMATESHEET");
|
|
|
}
|
|
|
- if (this.blendMode === ParticleSystem.BLENDMODE_MULTIPLY) {
|
|
|
+ if (blendMode === ParticleSystem.BLENDMODE_MULTIPLY) {
|
|
|
defines.push("#define BLENDMULTIPLYMODE");
|
|
|
}
|
|
|
if (this._useRampGradients) {
|
|
@@ -57782,9 +57786,8 @@ var BABYLON;
|
|
|
if (!this._started)
|
|
|
return;
|
|
|
if (!preWarmOnly) {
|
|
|
- var effect = this._getEffect();
|
|
|
// Check
|
|
|
- if (!this.emitter || !this._imageProcessingConfiguration.isReady() || !effect.isReady() || !this.particleTexture || !this.particleTexture.isReady())
|
|
|
+ if (!this.isReady())
|
|
|
return;
|
|
|
if (this._currentRenderId === this._scene.getRenderId()) {
|
|
|
return;
|
|
@@ -57879,26 +57882,29 @@ var BABYLON;
|
|
|
* @return true if the system is ready
|
|
|
*/
|
|
|
ParticleSystem.prototype.isReady = function () {
|
|
|
- var effect = this._getEffect();
|
|
|
- if (!this.emitter || !this._imageProcessingConfiguration.isReady() || !effect.isReady() || !this.particleTexture || !this.particleTexture.isReady()) {
|
|
|
+ if (!this.emitter || !this._imageProcessingConfiguration.isReady() || !this.particleTexture || !this.particleTexture.isReady()) {
|
|
|
return false;
|
|
|
}
|
|
|
+ if (this.blendMode !== ParticleSystem.BLENDMODE_MULTIPLYADD) {
|
|
|
+ if (!this._getEffect(this.blendMode).isReady()) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ if (!this._getEffect(ParticleSystem.BLENDMODE_MULTIPLY).isReady()) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if (!this._getEffect(ParticleSystem.BLENDMODE_ADD).isReady()) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
return true;
|
|
|
};
|
|
|
- /**
|
|
|
- * Renders the particle system in its current state.
|
|
|
- * @returns the current number of particles
|
|
|
- */
|
|
|
- ParticleSystem.prototype.render = function () {
|
|
|
- var effect = this._getEffect();
|
|
|
- // Check
|
|
|
- if (!this.isReady() || !this._particles.length) {
|
|
|
- return 0;
|
|
|
- }
|
|
|
+ ParticleSystem.prototype._render = function (blendMode) {
|
|
|
+ var effect = this._getEffect(blendMode);
|
|
|
var engine = this._scene.getEngine();
|
|
|
// Render
|
|
|
engine.enableEffect(effect);
|
|
|
- engine.setState(false);
|
|
|
var viewMatrix = this._scene.getViewMatrix();
|
|
|
effect.setTexture("diffuseSampler", this.particleTexture);
|
|
|
effect.setMatrix("view", viewMatrix);
|
|
@@ -57928,7 +57934,7 @@ var BABYLON;
|
|
|
this._imageProcessingConfiguration.bind(effect);
|
|
|
}
|
|
|
// Draw order
|
|
|
- switch (this.blendMode) {
|
|
|
+ switch (blendMode) {
|
|
|
case ParticleSystem.BLENDMODE_ADD:
|
|
|
engine.setAlphaMode(BABYLON.Engine.ALPHA_ADD);
|
|
|
break;
|
|
@@ -57947,15 +57953,33 @@ var BABYLON;
|
|
|
}
|
|
|
if (this._useInstancing) {
|
|
|
engine.drawArraysType(BABYLON.Material.TriangleFanDrawMode, 0, 4, this._particles.length);
|
|
|
- engine.unbindInstanceAttributes();
|
|
|
}
|
|
|
else {
|
|
|
engine.drawElementsType(BABYLON.Material.TriangleFillMode, 0, this._particles.length * 6);
|
|
|
}
|
|
|
- engine.setAlphaMode(BABYLON.Engine.ALPHA_DISABLE);
|
|
|
return this._particles.length;
|
|
|
};
|
|
|
/**
|
|
|
+ * Renders the particle system in its current state.
|
|
|
+ * @returns the current number of particles
|
|
|
+ */
|
|
|
+ ParticleSystem.prototype.render = function () {
|
|
|
+ // Check
|
|
|
+ if (!this.isReady() || !this._particles.length) {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ var engine = this._scene.getEngine();
|
|
|
+ engine.setState(false);
|
|
|
+ var outparticles = 0;
|
|
|
+ if (this.blendMode === ParticleSystem.BLENDMODE_MULTIPLYADD) {
|
|
|
+ outparticles = this._render(ParticleSystem.BLENDMODE_MULTIPLY) + this._render(ParticleSystem.BLENDMODE_ADD);
|
|
|
+ }
|
|
|
+ outparticles = this._render(this.blendMode);
|
|
|
+ engine.unbindInstanceAttributes();
|
|
|
+ engine.setAlphaMode(BABYLON.Engine.ALPHA_DISABLE);
|
|
|
+ return outparticles;
|
|
|
+ };
|
|
|
+ /**
|
|
|
* Disposes the particle system and free the associated resources
|
|
|
* @param disposeTexture defines if the particule texture must be disposed as well (true by default)
|
|
|
*/
|