XNA Creators Club Online
Page 1 of 1 (5 items)
Sort Posts: Previous Next

Antialiasing

Last post 10/11/2009 20:27 by s021666. 4 replies.
  • 07/11/2009 12:44

    Antialiasing

    I am experimenting with XNA at the moment.

    I have a textured quad that gets some heavy aliasing. And whatever I try I cant seem to solve the problem?

    The texture is a closeup of an asphalt pavement:



    I am using XNA in a windows app.

    I have tried to use different combinations of mip, min, mag filters and the only thing that seems to work is the min filters, but it doesnt get it any better than what can be seen on the image.

    Any help would be very appreciated!! Thank you :)
  • 07/11/2009 18:16 In reply to

    Re: Antialiasing

    How big is your texture?
    What format?
    Does it have mipmaps?
    What filter modes are you using when you create this screenshot?
    How much is the texture being scaled (and scaled up or down?) in this screenshot?
    XNA Framework Developer - blog - homepage
  • 08/11/2009 9:08 In reply to

    Re: Antialiasing

    The texture image is a jpg with dimensions 3952x2048 and its size is 729kb. And at the screenshot you see approx. 1200x1200 pixels of it.
    I think it has mipmaps because when I load the texture I call: 

    texture.GenerateMipMaps(
    TextureFilter.Anisotropic);

    and in between the pass.Start() and pass.End() I call:

    device.SamplerStates[0].MipFilter =
    TextureFilter.Anisotropic;

    But it doesnt seem to have any effect if I do it or not?
    I dont know what you mean by which filter modes I use when creating the screenshot I just use ALT + "Prnt Scrn" and paste the result into mspaint. The image looks exactly as it does on the screen.
    The 1200x1200 part of the image is being drawn in an area that is approx. 700x700 pixels, which is the size of the screenshot.

    A thing that I think could be important is that I use a System.Windows.Form and in the main area I insert a usercontrol that I created. This UserControl is the one making all the XNA stuff. And a thing that I have noticed is that the size of the usercontrol in design mode is the same size as the backbuffer of the device, even if I change the size of the usercontrol. Which happened when I inserted it into the Form in design mode. And if I correct this (making the size of the control the same as what the Form wants it to be) It seems like the image is less aliased, but it still is aliased.

    I really appreciate any help with this newb problem :)

  • 09/11/2009 18:00 In reply to

    Re: Antialiasing

    Answer
    Reply Quote
    s021666:
    texture.GenerateMipMaps(TextureFilter.Anisotropic);


    GenerateMipMaps is a somewhat unreliable method: it isn't supported by all drivers, and also requires that you create the texture with the autogen mip usage flag.

    It's generally better to create mipmaps ahead of time. The easiest way is to build your texture through the Content Pipeline and set the "generate mipmaps" content processor parameter.

    s021666:
    I dont know what you mean by which filter modes I use when creating the screenshot I just use ALT + "Prnt Scrn" and paste the result into mspaint. The image looks exactly as it does on the screen.


    I meant what filter mode do you use when you draw the texture onto the screen. From the look of it, I'm guessing you are using point sampling rather than linear. Or possibly you are using linear filtering but don't have mipmaps: it's hard to tell just from that one image.
    XNA Framework Developer - blog - homepage
  • 10/11/2009 20:27 In reply to

    Re: Antialiasing

    Hehe you are my new god :) been working on this for several days!

    I dont know if it makes any difference but Im using the Texture2D.FromFile(...) so I did it in the following way:

    1 public Texture2D LoadTexture(GraphicsDevice device)  
    2         {  
    3             TextureCreationParameters tcp = TextureCreationParameters.Default;  
    4             tcp.Filter = FilterOptions.Linear;  
    5             tcp.MipFilter = FilterOptions.Linear;  
    6             tcp.MipLevels = 5;  
    7               
    8             Texture = Texture2D.FromFile(device, Path, tcp);  
    9             HasTexture = true;  
    10             return Texture;  
    11         } 

    I havent looked into creating a ContentLoader instance which you get automatically in a standard XnaApp. But I guess its the same thing that happens?
Page 1 of 1 (5 items) Previous Next