static public void SwapBuffer(ComputeShaderParameterBuffer a, ComputeShaderParameterBuffer b) { var temp = a.Value; a.Value = b.Value; b.Value = temp; }
protected override void Update() { if (Input.GetMouseButton(0)) { var pos = new float2(Input.mousePosition.x, Input.mousePosition.y) / new float2(Screen.width, Screen.height); var posWorld = this.particleArea.LocalToWordPosition(new Vector3(pos.x, pos.y, 0)); this.PtoTparameter.mousePos.Value = new Vector4(posWorld.x, posWorld.y, 0, 0); this.Emit(512); } this.PtoTparameter.dt.Value = Time.deltaTime; base.Update(); ComputeShaderParameterBuffer.SwapBuffer(this.bufferParameter.particlesDataBufferRead, this.bufferParameter.particlesDataBufferWrite); this.PtoTparameter.particleBuffer.Value = this.bufferParameter.particlesDataBufferRead.Value; this.bufferParameter.particlesDataBufferEmitWrite.Value = this.bufferParameter.particlesDataBufferRead.Value; (this.PtoTparameter.trailTexture.Value as RenderTexture).Clear(); (this.PtoTparameter.diffuseTrail.Value as RenderTexture).Clear(); //Deposit this.MapParticleToTrail(); //Diffuse this.BlurTrail(); //Decay this.DecayTrail(); }