1. Hey! Guest! The 32nd GMC Jam will take place between Feb 22nd, 12:00 UTC (Friday noon) and Feb 25th, 12:00 UTC (Monday noon). Why not join in! Click here to find out more!
    Dismiss Notice

anti aliasing

Discussion in 'Programming' started by Didjynn, Feb 13, 2019 at 6:13 PM.

  1. Didjynn

    Didjynn Member

    Joined:
    Oct 8, 2016
    Posts:
    69
    Hello everyone,

    I was trying to understand all the anti aliasing we have in Gamemaker but it seems tricky to me.

    gpu_set_texfilter(true)
    This one is quite good already

    display_reset(aa, vsync);
    I never really saw any difference with it on or off even at 8 (maximum level)

    gpu_set_tex_mip_filter(tf_anisotropic)
    It seems to go the exact same than gpu_set_texfilter(true)
    I really compared the 2 in real time and if I activate texfilter and deactivate tex_mip then it is exactly the same, pixel perfect.
    I'm trying to improve the aliasing as much as possible in my game and I'm trying to not activate everything to keep performances as good as possible, any help about that and anti aliasing understanding (of these 3 lines of code and more if possible ? I do know how anti aliasing normally work, my problem is only to understand gamemaker about that)

    Thanks for your time,

    Cheers
     
    AIrlan Bragi likes this.
  2. Misu

    Misu The forum's immigrant

    Joined:
    Jun 20, 2016
    Posts:
    597
    I'd like to see some answers to this too because from all I know, Ive experimented with anti-alias before and I too have never noticed any difference at all with display_aa. Its almost as if it does not work at all.

    What I normally do to recreate anti-alias is by downsampling the application_surface to create super smooth pixels just like the ones in films but they can cost a lot on performance depending on the size and destination size. It may work best for powerful devices like gaming computers and game consoles but I wouldn't recommend it for mobile (Even though I did manage to run it on mobile at decent rate once).
     
    Didjynn likes this.
  3. flyingsaucerinvasion

    flyingsaucerinvasion Member

    Joined:
    Jun 20, 2016
    Posts:
    1,846
    I guess a simple way of putting it is that aa will blend the edges of your polygons with the background, rather than affecting the textures in any way.

    MIP mapping is basically for making textures look better at a distance. It basically uses smaller sized textures at times when sampling a larger texture would cause sparkling. I really wish MIP mapping was built into GMS1! Also if yoyo is reading, it'd be great to be able to change culling direction and z testing function!
     
  4. Smiechu

    Smiechu Member

    Joined:
    Jul 14, 2017
    Posts:
    613
    If you want a to have full screen aa you need to set the camera and application surface resulution to x times of screen resolution and manually draw and rescale the application surface.
    Bulit in aa works only for some bulit in primitive functions and has no bigger influance on drawing of sprites...
     
  5. Misu

    Misu The forum's immigrant

    Joined:
    Jun 20, 2016
    Posts:
    597
    Thats called downscaling. Thats what I normally do. Trick simple but heavy on gpu.
    Code:
    ///draw gui event
    if (!surface_exists(screen)){
         surface_create(screen,width,height);}
    surface_set_target(screen);
    draw_clear(0);
    draw_surface_ext(application_surface,0,0,0.5,0.5,0,-1,1);
    surface_reset_target();
    
    draw_surface_ext(screen,0,0,0.5,0.5,0,-1,1);
     
  6. The Sorcerer

    The Sorcerer Member

    Joined:
    Jan 3, 2019
    Posts:
    138
    I use display_reset(aa_level, true) all the time It works great!

    It wont affect textures one bit though, so you won't notice it at all in normal 2D games. But if your sprites go right to the edge of their image, you will notice the difference on rotations.

    [​IMG]

    Again, doesn't have a huge place in 2D, but really shines when you move in to 3D as all of the geometry benefits from the AA.
     
  7. Misu

    Misu The forum's immigrant

    Joined:
    Jun 20, 2016
    Posts:
    597
    @The Sorcerer It goes to show that display_aa only helps geometry. If thats the case than its useless if there are better techniques that help more than the edges of your drawing structure. Im happy with the results of downscaling since it smoothen every pixel on screen (both edges and texture). Also not to mention that display_aa only works for some devices. I know there may be a better way (and efficient) with shaders but display_aa is not the best option in my opinion.
     
  8. The Sorcerer

    The Sorcerer Member

    Joined:
    Jan 3, 2019
    Posts:
    138
    Seems that you don't fully understand what display_aa is or when you would use it.

    Agreed, in normal 2D mainstream games. You will not notice one pixel of difference in normal operation. But display_aa isn't designed to be a texture filter, it is a geometry filter.

    Below is display_aa in action. Sure you could say I blurred it in Photoshop or something, but then closer inspection will reveal that there is no difference in texture inside the geometry. That is what AA is and what AA is designed to do.

    [​IMG]

    This rule applies to any engine in existence and is not a GM bug or oversight.


    I have never met a device that doesn't support it. ;)
     
    Last edited: Feb 13, 2019 at 9:32 PM
  9. Misu

    Misu The forum's immigrant

    Joined:
    Jun 20, 2016
    Posts:
    597
    I still think display_aa sucks :p
     
    The Sorcerer likes this.
  10. Smiechu

    Smiechu Member

    Joined:
    Jul 14, 2017
    Posts:
    613
    You've totally missed what I've said...

    Example...
    Your target screen resolution is 800x600...
    You set the application surface to i.e. 1600x1200 and you draw your camera or whatever you use on this surface.
    Then you downscale (with resampling) the application surface to fit the screen resolution - 800x1600.
    This is the FSAA 2x - Full Screen Anti Aliasing with oversampling factor 2 - the most basic approach to aa
     
    Misu likes this.
  11. The Sorcerer

    The Sorcerer Member

    Joined:
    Jan 3, 2019
    Posts:
    138
    Hehe!

    No display_aa sucks harder :p
     
    Misu likes this.
  12. Misu

    Misu The forum's immigrant

    Joined:
    Jun 20, 2016
    Posts:
    597
    Thats what she said... ;D
     
    The Sorcerer likes this.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice