diff --git a/cocos/3d/framework/particle/renderer/particle-system-renderer.ts b/cocos/3d/framework/particle/renderer/particle-system-renderer.ts index e3e208f7ee..106a311085 100644 --- a/cocos/3d/framework/particle/renderer/particle-system-renderer.ts +++ b/cocos/3d/framework/particle/renderer/particle-system-renderer.ts @@ -144,19 +144,24 @@ export default class ParticleSystemRenderer extends RenderableComponent { } if (this._model == null) { this._model = this._getRenderScene().createModel(ParticleBatchModel, this.node) as ParticleBatchModel; + } + if (!this._model.inited) { this._model.setCapacity(this.particleSystem.capacity); this._model.setVertexAttributes(this._vertAttrs); this._model.node = this.node; + } + this._model.enabled = this.enabledInHierarchy; + } + + public onDisable () { + if (this._model) { this._model.enabled = this.enabledInHierarchy; } } - public onDisable () { - this._getRenderScene().destroyModel(this._model!); - } - public onDestroy () { - this._model!.destroy(); + this._getRenderScene().destroyModel(this._model!); + this._model = null; } public clear () { @@ -316,8 +321,12 @@ export default class ParticleSystemRenderer extends RenderableComponent { } else { console.warn(`particle system renderMode ${this._renderMode} not support.`); } + const ea = mat!.effectAsset; mat!.destroy(); - mat!.initialize({ defines: this._defines }); + mat!.initialize({ + defines: this._defines, + effectAsset: ea, + }); if (this.particleSystem.textureAnimationModule.enable) { mat!.setProperty('frameTile_velLenScale', vec2.set(this.frameTile_velLenScale, this.particleSystem.textureAnimationModule.numTilesX, this.particleSystem.textureAnimationModule.numTilesY)); diff --git a/cocos/pipeline/render-view.ts b/cocos/pipeline/render-view.ts index 14f8b858dd..fec9cd2a39 100644 --- a/cocos/pipeline/render-view.ts +++ b/cocos/pipeline/render-view.ts @@ -126,6 +126,7 @@ export class RenderView { } else { this._stages.push('ForwardFlow'); this._stages.push('ToneMapFlow'); + this._stages.push('SMAAFlow'); } return true; diff --git a/cocos/renderer/models/particle-batch-model.ts b/cocos/renderer/models/particle-batch-model.ts index 3d26a8e3fa..f9c166a84a 100644 --- a/cocos/renderer/models/particle-batch-model.ts +++ b/cocos/renderer/models/particle-batch-model.ts @@ -67,9 +67,9 @@ export default class ParticleBatchModel extends Model { // rebuid this._vBuffer = this._createSubMeshData(); this._vertAttrsFloatCount = this._vertSize / 4; // number of float - this._vBuffer = new ArrayBuffer(this._capacity * this._vertSize * 4); this._vdataF32 = new Float32Array(this._vBuffer); this._vdataUint32 = new Uint32Array(this._vBuffer); + this._inited = true; } public _createSubMeshData (): ArrayBuffer { @@ -156,8 +156,8 @@ export default class ParticleBatchModel extends Model { offset += 2; } else if (curAttr.format === GFXFormat.RGB32F) { this._vdataF32![offset] = pvdata[i].x; - this._vdataF32![offset + 1] = pvdata[i].y; this._vdataF32![offset + 2] = pvdata[i].z; + this._vdataF32![offset + 1] = pvdata[i].y; offset += 3; } else if (curAttr.format === GFXFormat.RGBA8) { this._vdataUint32![offset] = pvdata[i]; @@ -181,9 +181,13 @@ export default class ParticleBatchModel extends Model { public destroy () { super.destroy(); + this._vBuffer = null; this._vdataF32 = null; - this.destroySubMeshData(); + if (this._subMeshData) { + this.destroySubMeshData(); + } this._iaInfoBuffer.destroy(); + this._subMeshData = null; } private destroySubMeshData () {