public void LoadContent()
{
if (NOWATER)
return;
spriteBatch = new SpriteBatch(Game.GraphicsDevice);
ParticleEffect = new BasicEffect(Game.GraphicsDevice);
ParticleEffect.EnableDefaultLighting();
ParticleEffect.DiffuseColor = new Vector3(1, 1, 1);
ParticleEffect.VertexColorEnabled = true;
ParticleEffect.LightingEnabled = false;
ParticleEffect.TextureEnabled = false;
WaterEffect = Game.Content.Load<Effect>("Effects/Water");
WaterRenderTarget = new RenderTarget2D(Game.GraphicsDevice, Game.GraphicsDevice.Viewport.Width, Game.GraphicsDevice.Viewport.Height);
MetaBallTexture = new Texture2D(Game.GraphicsDevice, MetaBallWidth, MetaBallWidth);
var metaBallData = new byte[MetaBallWidth * MetaBallWidth * 4];
int i = 0;
for(int x = 0; x < MetaBallWidth; x++)
{
for(int y = 0; y < MetaBallWidth; y++)
{
var dx = x - MetaBallRadius;
var dy = y - MetaBallRadius;
var distance = Math.Sqrt(dx * dx + dy * dy) / MetaBallRadius;
var blob = 1 - (0.1 + 0.9 * distance);
var b = (byte)(127 * Math.Max(0, Math.Min(1, blob)));
metaBallData[i++] = b;
metaBallData[i++] = b;
metaBallData[i++] = b;
metaBallData[i++] = 255;// (byte)(d > 14 ? 0 : 128);
}
}
MetaBallTexture.SetData(metaBallData);
FullscreenQuad = new VertexPositionTexture[]
{
new VertexPositionTexture(new Vector3(0, 0, 0.5f), new Vector2(0, 1)),
new VertexPositionTexture(new Vector3(1, 1, 0.5f), new Vector2(1, 0)),
new VertexPositionTexture(new Vector3(0, 1, 0.5f), new Vector2(0, 0)),
new VertexPositionTexture(new Vector3(0, 0, 0.5f), new Vector2(0, 1)),
new VertexPositionTexture(new Vector3(1, 0, 0.5f), new Vector2(1, 1)),
new VertexPositionTexture(new Vector3(1, 1, 0.5f), new Vector2(1, 0)),
};
}