public void Render(GraphicsDevice GraphicsDevice, RenderTargetDouble velocity, RenderTargetDouble advected, RenderTargetDouble output) { advect.Parameters["velocity"].SetValue(velocity.Read); advect.Parameters["advected"].SetValue(advected.Read); advect.Parameters["gridSize"].SetValue(new Vector2(w, h)); advect.Parameters["gridScale"].SetValue(1.0f); advect.Parameters["timestep"].SetValue(timestep); advect.Parameters["dissipation"].SetValue(dissipation); GraphicsDevice.SetRenderTarget(output.Write); SpriteBatch spriteBatch = new SpriteBatch(GraphicsDevice); Rectangle r = new Rectangle(0, 0, w, h); spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Opaque, null, null, null, advect); spriteBatch.Draw(Game1.textureWhite, r, Color.White); spriteBatch.End(); GraphicsDevice.SetRenderTarget(null); output.Swap(); }
public void Render(GraphicsDevice GraphicsDevice, RenderTargetDouble x, RenderTargetDouble b, RenderTargetDouble output, Boundary boundary, float scale) { for (var i = 0; i < iterations; i++) { jacobiFx.Parameters["x"].SetValue(x.Read); jacobiFx.Parameters["b"].SetValue(b.Read); jacobiFx.Parameters["gridSize"].SetValue(new Vector2(w, h)); jacobiFx.Parameters["alpha"].SetValue(alpha); jacobiFx.Parameters["beta"].SetValue(beta); GraphicsDevice.SetRenderTarget(output.Write); SpriteBatch spriteBatch = new SpriteBatch(GraphicsDevice); Rectangle r = new Rectangle(0, 0, w, h); spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Opaque, null, null, null, jacobiFx); spriteBatch.Draw(Game1.textureWhite, r, Color.White); spriteBatch.End(); GraphicsDevice.SetRenderTarget(null); output.Swap(); boundary.Render(GraphicsDevice, output, scale, output); } }