Drawing lines: anti-aliasing

Hi everyone:

I’m working on an app that draws a lot of lines rather than using textures (like Asteroids or Battle Zone), and I’m trying to figure out two things:

  1. How to make some of the lines semi-transparent.
  2. How to control anti-aliasing.

Here’s how I’m drawing my lines:

GraphicsDevice gd = ...;
using (var be = new BasicEffect(gd))
{
	be.VertexColorEnabled = true;
	Matrix mat;
	Matrix.CreateOrthographicOffCenter(0, w, h, 0, 0, 1, out mat);
	be.Projection = mat;
	foreach (EffectPass pass in be.CurrentTechnique.Passes)
	{
		pass.Apply();
		gd.DrawUserIndexedPrimitives(
			PrimitiveType.LineList,
			Vertices.ToArray(), 0, Vertices.Count,
			Indices.ToArray(), 0, NLines);
	}
}

Right now alpha is being ignored. And for AA I’ve done “PreferMultiSampling = true” but it looks terrible. I don’t know how to specify 4x, or if there’s some other method I can use.

Thanks in advance!
Mike

Bumping for justice. :slight_smile:

Forget about transparency for now – I’m really much more interested in anti-aliasing. I’ve tried so many combinations and on iOS in particular I see no difference at all. Do you think I’ll have to start looking at other methods of line drawing, like this…?

Thanks,
Mike

It’s a shame no one replied.

Few days ago I’ve stumbled upon this: http://stackoverflow.com/questions/33977226/drawing-bezier-curves-in-monogame-xna-produces-scratchy-lines

Haven’t tried yet, but looks great

That looks very cool, I’ll have to try it!

In the meantime I was able to solve all my problems by stretching a 1x1 pixel using SpriteBatch. It’s probably slower, but it serves my needs 100%.

I’ll post the code as soon as I can.

Mike