DesktopGL and Anti-Aliasing (or Polygon Smoothing) for 3D Scenes?

I’m working on a project and think I have everything setup to handle Multi-Sampling/Anti-Aliasing, such that I don’t get grid-lines between my triangles (I’m procedurally generating voxels, apparently).

See the image below:

In the ctor of my Game class, I have the following:

    Graphics = new GraphicsDeviceManager( this )
    {
        PreferredBackBufferHeight = 720,
        PreferredBackBufferWidth = 1280,
        PreferMultiSampling = true
    };

    Graphics.ApplyChanges();

(I have confirmed that PreferMultiSampling is true thereafter as well – so we should be good in regards to that)

I then have the following on my scene render:

            TileMeshEffect = new BasicEffect( GraphicsDevice );
            GraphicsDevice.RasterizerState = new RasterizerState()
                            {
                                CullMode = CullMode.None,
                                MultiSampleAntiAlias = true,
                            };
            TileMeshEffect.CurrentTechnique.Passes[0].Apply();
            GraphicsDevice.SetVertexBuffer( TileMeshVertexBuffers[Coordinate] );
            GraphicsDevice.DrawPrimitives( PrimitiveType.TriangleList, 0, TileMeshVertexBuffers[Coordinate].VertexCount / 3 );

I’ve confirmed that everything “sticks” in the variables and that GraphicsDevice.PresentationParameters.MultiSampleCount = 4.

So, everything should be good – but I’m still getting Grid lines in between triangles (although, interestingly enough, not in between triangles where they join to form a square).

Any thoughts?

So, I adjusted my code a little bit. I created a SpriteBatch and a RenderTarget2D.

re:

            RenderTarget2D SceneBuffer = new RenderTarget2D( GraphicsDevice, GraphicsDevice.PresentationParameters.BackBufferWidth, GraphicsDevice.PresentationParameters.BackBufferHeight, false,
            GraphicsDevice.PresentationParameters.BackBufferFormat, GraphicsDevice.PresentationParameters.DepthStencilFormat, GraphicsDevice.PresentationParameters.MultiSampleCount, RenderTargetUsage.DiscardContents );

            SpriteBatch SceneBatch = new SpriteBatch( GraphicsDevice );

Then, I run the following:

        GraphicsDevice.SetRenderTarget( SceneBuffer );

        TileMeshEffect = new BasicEffect( GraphicsDevice );
        GraphicsDevice.RasterizerState = new RasterizerState()
                        {
                            CullMode = CullMode.None,
                            MultiSampleAntiAlias = true,
                        };
        TileMeshEffect.CurrentTechnique.Passes[0].Apply();
        GraphicsDevice.SetVertexBuffer( TileMeshVertexBuffers[Coordinate] );
        GraphicsDevice.DrawPrimitives( PrimitiveType.TriangleList, 0, TileMeshVertexBuffers[Coordinate].VertexCount / 3 );

            GraphicsDevice.SetRenderTarget( null );

            SceneBatch.Begin( );
            SceneBatch.Draw( SceneBuffer, GraphicsDevice.Viewport.Bounds, Color.White );
            SceneBatch.End();

This gets me EXTREMELY close to where I’m trying to be. Anti-aliasing is working UP UNTIL I rotate. Rotating between 0 and PI/2 looks correct. After that, it looks almost as though the image is inverting somehow where my tile mesh is flipping from showing the top to the bottom.

Not sure if maybe the following is incorrect, but this is more or less how I’m creating my “view”:

                Single AngularUnit = 20;

                Vector3D CameraLocation = new Vector3D( pCamera.Center.X + pCamera.RelativePosition.X + AngularUnit * Math.Cos( pCamera.Rotation ),
                    pCamera.Center.Y + pCamera.RelativePosition.Y + AngularUnit * Math.Sin( pCamera.Rotation ), pCamera.Center.Z + pCamera.RelativePosition.Z );

                TileMeshEffect.View = Matrix.CreateLookAt( CameraLocation.ToVector3(), pCamera.Center.ToVector3(), Vector3.UnitZ );

(Click the image for an animated version)

The end of it looks correct with green grass (that’s from 0 -> PI/2)