/// <summary> /// Stream output /// </summary> /// <param name="effect">Effect for stream out</param> private void StreamOut(EffectDefaultGpuParticles effect) { var graphics = this.Game.Graphics; graphics.IAInputLayout = this.streamOutInputLayout; graphics.IASetVertexBuffers(BufferSlot, this.firstRun ? this.emitterBinding : this.drawingBinding); graphics.IAPrimitiveTopology = PrimitiveTopology.PointList; graphics.SetDepthStencilNone(); graphics.SetStreamOutputTargets(this.streamOutBinding); var techniqueForStreamOut = effect.ParticleStreamOut; for (int p = 0; p < techniqueForStreamOut.PassCount; p++) { graphics.EffectPassApply(techniqueForStreamOut, p, 0); if (this.firstRun) { graphics.Draw(1, 0); this.firstRun = false; } else { graphics.DrawAuto(); } } graphics.SetStreamOutputTargets(null); }
/// <summary> /// Drawing /// </summary> /// <param name="effect">Effect for drawing</param> /// <param name="drawerMode">Drawe mode</param> private void Draw(EffectDefaultGpuParticles effect, DrawerModes drawerMode) { var rot = this.parameters.RotateSpeed != Vector2.Zero; var techniqueForDrawing = rot ? effect.RotationDraw : effect.NonRotationDraw; if (!drawerMode.HasFlag(DrawerModes.ShadowMap)) { Counters.InstancesPerFrame++; } var graphics = this.Game.Graphics; graphics.IAInputLayout = rot ? this.rotatingInputLayout : this.nonRotatingInputLayout; graphics.IASetVertexBuffers(BufferSlot, this.drawingBinding); graphics.IAPrimitiveTopology = PrimitiveTopology.PointList; graphics.SetDepthStencilRDZEnabled(); if (this.parameters.Additive) { graphics.SetBlendAdditive(); } else if (this.parameters.Transparent) { graphics.SetBlendDefaultAlpha(); } else { graphics.SetBlendDefault(); } for (int p = 0; p < techniqueForDrawing.PassCount; p++) { graphics.EffectPassApply(techniqueForDrawing, p, 0); graphics.DrawAuto(); } }