GeorgeOu

How to achieve anti alias in XNA, after a quick search in the document and forums, I got no idea, will some one tell me if it's possible in XNA If not, is there anyway to wrap around that Because without anti alias , the game sometimes looks a little weired!

Many thanks!




Re: XNA Game Studio Express How to do anti alias in XNA?

George Clingerman

Here's an article here that talks about achieving a type of anti-aliasing with 2D images. You can also look at RederState setting MultiSampleAntiAlias (true by default) when you work with multi-sampling. You can look at some sample code for that here.

Hope that helps.





Re: XNA Game Studio Express How to do anti alias in XNA?

Kyle_W

I believe when using the Game class, setting your GraphicsDeviceManager.PreferMultiSampling property to true should do the trick.



Re: XNA Game Studio Express How to do anti alias in XNA?

GeorgeOu

I have turned both the option on, but it still looks jagged, what is wrong with my code

graphics.GraphicsDevice.SetRenderTarget(0, reflection);

graphics.PreferMultiSampling = true;
graphics.GraphicsDevice.RenderState.MultiSampleAntiAlias = true;

reflection.GraphicsDevice.Clear(ClearOptions.Target,new Color(0,0,0,0),0,0);

mirrorCameraAlongXplane();
graphics.GraphicsDevice.RenderState.CullMode = CullMode.CullCounterClockwiseFace;
//Draw the reflection into rendertarget
foreach (ModelMesh mesh in myModel2.Meshes)
{
foreach (ModelMeshPart meshPart in mesh.MeshParts)
{
meshPart.Effect = content.Load<Effect>("Content\\Shaders\\ReallySimpleEffect");
meshPart.Effect.CurrentTechnique = effect.Techniques["textured"];
meshPart.Effect.Parameters["worldViewProj"].SetValue(worldViewProjection);
meshPart.Effect.Parameters["camposition"].SetValue(camposition);
meshPart.Effect.Parameters["lightDir"].SetValue(Lightposition);
meshPart.Effect.Parameters["world"].SetValue(world);
meshPart.Effect.Parameters["shininess"].SetValue(8.0f);
Vector4 ambient = new Vector4(0.4f, 0.2f, 0.2f, 1.0f);
meshPart.Effect.Parameters["ambientColor"].SetValue(ambient);
meshPart.Effect.Parameters["UserTexture"].SetValue(texture);
meshPart.Effect.Parameters["BumpTexture"].SetValue(bumptexture);
meshPart.Effect.Parameters["cubeMap"].SetValue(Cubetexture);
meshPart.Effect.Parameters["bumpAmplitude"].SetValue(0f);

}
mesh.Draw();
}


graphics.GraphicsDevice.ResolveRenderTarget(0);

graphics.GraphicsDevice.SetRenderTarget(0, null);






Re: XNA Game Studio Express How to do anti alias in XNA?

Kyle_W

I think you may need to adjust these properties on your render target:

RenderTarget2D.MultiSampleQuality

RenderTarget2D.MultiSampleType





Re: XNA Game Studio Express How to do anti alias in XNA?

Kyle_W

I just noticed that those properties are apparently read-only, but you can specify them in the constructor when you create the RenderTarget2D.