|
@@ -583,7 +583,7 @@
|
|
this._scene.particleSystems.push(this);
|
|
this._scene.particleSystems.push(this);
|
|
|
|
|
|
this._updateEffectOptions = {
|
|
this._updateEffectOptions = {
|
|
- attributes: ["position", "age", "life", "seed", "size", "color", "direction", "initialDirection", "angle", "cellIndex", "cellStartOffset"],
|
|
|
|
|
|
+ attributes: ["position", "age", "life", "seed", "size", "color", "direction", "initialDirection", "angle", "cellIndex", "cellStartOffset", "noiseCoordinates1", "noiseCoordinates2"],
|
|
uniformsNames: ["currentCount", "timeDelta", "emitterWM", "lifeTime", "color1", "color2", "sizeRange", "scaleRange","gravity", "emitPower",
|
|
uniformsNames: ["currentCount", "timeDelta", "emitterWM", "lifeTime", "color1", "color2", "sizeRange", "scaleRange","gravity", "emitPower",
|
|
"direction1", "direction2", "minEmitBox", "maxEmitBox", "radius", "directionRandomizer", "height", "coneAngle", "stopFactor",
|
|
"direction1", "direction2", "minEmitBox", "maxEmitBox", "radius", "directionRandomizer", "height", "coneAngle", "stopFactor",
|
|
"angleRange", "radiusRange", "cellInfos", "noiseStrength", "limitVelocityDamping"],
|
|
"angleRange", "radiusRange", "cellInfos", "noiseStrength", "limitVelocityDamping"],
|
|
@@ -668,7 +668,14 @@
|
|
updateVertexBuffers["cellStartOffset"] = source.createVertexBuffer("cellStartOffset", offset, 1);
|
|
updateVertexBuffers["cellStartOffset"] = source.createVertexBuffer("cellStartOffset", offset, 1);
|
|
offset += 1;
|
|
offset += 1;
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (this.noiseTexture) {
|
|
|
|
+ updateVertexBuffers["noiseCoordinates1"] = source.createVertexBuffer("noiseCoordinates1", offset, 3);
|
|
|
|
+ offset += 3;
|
|
|
|
+ updateVertexBuffers["noiseCoordinates2"] = source.createVertexBuffer("noiseCoordinates2", offset, 3);
|
|
|
|
+ offset += 3;
|
|
|
|
+ }
|
|
|
|
|
|
let vao = this._engine.recordVertexArrayObject(updateVertexBuffers, null, this._updateEffect);
|
|
let vao = this._engine.recordVertexArrayObject(updateVertexBuffers, null, this._updateEffect);
|
|
this._engine.bindArrayBuffer(null);
|
|
this._engine.bindArrayBuffer(null);
|
|
@@ -711,7 +718,14 @@
|
|
renderVertexBuffers["cellStartOffset"] = source.createVertexBuffer("cellStartOffset", offset, 1, this._attributesStrideSize, true);
|
|
renderVertexBuffers["cellStartOffset"] = source.createVertexBuffer("cellStartOffset", offset, 1, this._attributesStrideSize, true);
|
|
offset += 1;
|
|
offset += 1;
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (this.noiseTexture) {
|
|
|
|
+ renderVertexBuffers["noiseCoordinates1"] = source.createVertexBuffer("noiseCoordinates1", offset, 3, this._attributesStrideSize, true);
|
|
|
|
+ offset += 3;
|
|
|
|
+ renderVertexBuffers["noiseCoordinates2"] = source.createVertexBuffer("noiseCoordinates2", offset, 3, this._attributesStrideSize, true);
|
|
|
|
+ offset += 3;
|
|
|
|
+ }
|
|
|
|
|
|
renderVertexBuffers["offset"] = spriteSource.createVertexBuffer("offset", 0, 2);
|
|
renderVertexBuffers["offset"] = spriteSource.createVertexBuffer("offset", 0, 2);
|
|
renderVertexBuffers["uv"] = spriteSource.createVertexBuffer("uv", 2, 2);
|
|
renderVertexBuffers["uv"] = spriteSource.createVertexBuffer("uv", 2, 2);
|
|
@@ -747,7 +761,11 @@
|
|
if (this.spriteRandomStartCell) {
|
|
if (this.spriteRandomStartCell) {
|
|
this._attributesStrideSize += 1;
|
|
this._attributesStrideSize += 1;
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (this.noiseTexture) {
|
|
|
|
+ this._attributesStrideSize += 6;
|
|
|
|
+ }
|
|
|
|
|
|
for (var particleIndex = 0; particleIndex < this._capacity; particleIndex++) {
|
|
for (var particleIndex = 0; particleIndex < this._capacity; particleIndex++) {
|
|
// position
|
|
// position
|
|
@@ -802,7 +820,16 @@
|
|
if (this.spriteRandomStartCell) {
|
|
if (this.spriteRandomStartCell) {
|
|
data.push(0.0);
|
|
data.push(0.0);
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (this.noiseTexture) { // Random coordinates for reading into noise texture
|
|
|
|
+ data.push(Math.random());
|
|
|
|
+ data.push(Math.random());
|
|
|
|
+ data.push(Math.random());
|
|
|
|
+ data.push(Math.random());
|
|
|
|
+ data.push(Math.random());
|
|
|
|
+ data.push(Math.random());
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
// Sprite data
|
|
// Sprite data
|
|
@@ -898,7 +925,12 @@
|
|
if (this.spriteRandomStartCell) {
|
|
if (this.spriteRandomStartCell) {
|
|
this._updateEffectOptions.transformFeedbackVaryings.push("outCellStartOffset");
|
|
this._updateEffectOptions.transformFeedbackVaryings.push("outCellStartOffset");
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (this.noiseTexture) {
|
|
|
|
+ this._updateEffectOptions.transformFeedbackVaryings.push("outNoiseCoordinates1");
|
|
|
|
+ this._updateEffectOptions.transformFeedbackVaryings.push("outNoiseCoordinates2");
|
|
|
|
+ }
|
|
|
|
|
|
this._updateEffectOptions.defines = defines;
|
|
this._updateEffectOptions.defines = defines;
|
|
this._updateEffect = new Effect("gpuUpdateParticles", this._updateEffectOptions, this._scene.getEngine());
|
|
this._updateEffect = new Effect("gpuUpdateParticles", this._updateEffectOptions, this._scene.getEngine());
|