Pixels noticeably distorted

Discussion in 'Programming' started by snowy1996, Dec 23, 2017.

Tags:
  1. snowy1996

    snowy1996 Member

    Joined:
    Sep 9, 2017
    Posts:
    15
    I've been having an issue for a bit now in which the pixels making up my game warp and distort as the camera moves, never settling into their properly square selves. Pictured here as evidence: https://imgur.com/a/n3mcn
    The issue should be noticeable in the characters bloated eye or when comparing the usually visually the same trees.
    I'm not sure if this is considered screen tearing, but checking "use synchronization to avoid tearing" hasn't changed anything. My cameras are set to as 544x306 to match my 16:9 monitor resolution as well, so I don't think it's just a matter of the resolution being off.
    Searching the web hasn't been able to help me, and at this point I'm hoping to just bounce around ideas until something sticks.
     
    Last edited: Dec 23, 2017
  2. obscene

    obscene Member

    Joined:
    Jun 21, 2016
    Posts:
    2,424
    I think your calculator is broke. How did you figure you could scale 544 into 1600 evenly?
     
  3. snowy1996

    snowy1996 Member

    Joined:
    Sep 9, 2017
    Posts:
    15
    9:16 = 306:544
    Is that not correct? I figured I could have my camera properties be anything so long as they used whole numbers matching a 9 to 16 ratio, no?
     
  4. Joe Ellis

    Joe Ellis Member

    Joined:
    Aug 30, 2016
    Posts:
    936
    maybe just in the draw event making everything floor(x), floor(y) will work, cus that makes it always a whole number, that usually fixes any problems with (on purpose) lower res games

    oh and the camera if youv got one, floor that's coordinates in the draw event,
     
  5. obscene

    obscene Member

    Joined:
    Jun 21, 2016
    Posts:
    2,424
    The problem is you stretched 544x306 to 1600x900 which is a factor of 2.941176470588235.
     
  6. Joe Ellis

    Joe Ellis Member

    Joined:
    Aug 30, 2016
    Posts:
    936
    yeah that is true, 64 bit numbers never work well with integers, but thats why I was saying floor them in the draw event cus they will always be pixel exact, even if while theyre moving theyre at 17.07927040

    dont floor them in the step event, cus that'll ruin the smooth motions, but temp set where they actually draw to whole coords
     
    Last edited: Dec 23, 2017
  7. snowy1996

    snowy1996 Member

    Joined:
    Sep 9, 2017
    Posts:
    15
    Ok so the problem is the resolution being an imperfect conversion? Is there a more commonly used dimension close to what I'm using that would work properly? I'm trying to pull off something reminiscent of the 32-bit era.

    Looloo, I'm not sure which you're referring to when you say draw event. My cameras dimensions are being set in the room properties.
     
  8. trentallain

    trentallain Member

    Joined:
    Aug 6, 2016
    Posts:
    521
    I use this website a bit when picking resolutions https://pacoup.com/2011/06/12/list-of-true-169-resolutions/
     
  9. RangerX

    RangerX Member

    Joined:
    Jun 20, 2016
    Posts:
    2,594
    As soon as you will scale your game up by a factor that isn't an integer, you'll get distortion. As simple as that.
    If ever you always want to be "pixel perfect", you can disable the automatic drawing of the application surface and draw it yourself at the desired size and position every step. See the "pixel perfect" method in my tutorial there.
    https://forum.yoyogames.com/index.php?threads/how-to-properly-scale-your-game.995/
     
    IndianaBones likes this.
  10. icuurd12b42

    icuurd12b42 TMC Founder GMC Elder

    Joined:
    Apr 22, 2016
    Posts:
    1,839
    choose a resolution that will evenly, throughout most common resolutions, scale by adding the same number of fill data per scan line.

    like one line becomes 2 lines, 3 line, or 4 lines and so one when scaled up...

    the problem you have is as you scale, many of the lines double, but some don't...

    for example if you have 200 tall image and you scale it up to 398... mose the lines will be double except for 2 lines that will stay a single line, giving a compressed effect for that region

    Your image, the tree on the right is the opposite of that... say you scale a 200 tall image to become 202... most of the image will have 1 line per line while 2 of them will have 2 lines per line, making a blockish stretch for that region


    upload_2017-12-24_1-8-27.png
     
    IndianaBones likes this.
  11. Joe Ellis

    Joe Ellis Member

    Joined:
    Aug 30, 2016
    Posts:
    936
    Its the camera's position i was referring to, (which is dynamic so it gets updated every step) not the size of the view, if its position is not an integer you'll get problems,
    so thats why i was saying floor or round the position coordinates, which can be either in the step event or draw event depending how your setting the view,
    but its actual position variables should be floats to keep the smooth movement, so have a separate pair of "view position" variables which are basically a rounded version of its position

    have you ever used d3d_set_projection_ortho? thats usually easier to use than views, you just set it in the draw event with the camera's x, y, width and height
     
    Last edited: Dec 29, 2017
  12. icuurd12b42

    icuurd12b42 TMC Founder GMC Elder

    Joined:
    Apr 22, 2016
    Posts:
    1,839
    something fishy happened to this thread. many posts have gone, including my 2nd response... about view position and sprite position
     
  13. Nocturne

    Nocturne Friendly Tyrant Forum Staff Admin

    Joined:
    Apr 13, 2016
    Posts:
    6,891
    Not true! Make the application surface the same size as the screen/viewport window and you'll find that things look much better. This DOES mean that you will be drawing more pixels than the base resolution, but it eliminates the issues you are experiencing. ;)

    Topic logs show that nothing has been removed...
     
    gamedev4life likes this.
  14. icuurd12b42

    icuurd12b42 TMC Founder GMC Elder

    Joined:
    Apr 22, 2016
    Posts:
    1,839
  15. RangerX

    RangerX Member

    Joined:
    Jun 20, 2016
    Posts:
    2,594
    Please, its pure logic here. No fraction of pixels can exist.
    The more pixel you have to represent an image that would be unevenly scaled up, the less apparent the distortion will be though. But its there. Don't give false information.
     
    Last edited: Dec 29, 2017
  16. Nocturne

    Nocturne Friendly Tyrant Forum Staff Admin

    Joined:
    Apr 13, 2016
    Posts:
    6,891
    It's not false information. It's an easy workaround that gives a result that is, in most cases, perfectly acceptable. ;)
     
    gamedev4life likes this.
  17. icuurd12b42

    icuurd12b42 TMC Founder GMC Elder

    Joined:
    Apr 22, 2016
    Posts:
    1,839
    well, pixel artist would disagree depending on the game style and their perfectionistic view on things

    it is true that the artefact would be less pronounced on a higher density canvas, if a 1x1 pixel is scaled to a 8x8 and a few are scaled to 7x8 or 9x8 due to rounding... you would be darned to find the exact scan line this is happening on, especially in a dynamic picture, like a game where everything is moving
     
  18. RangerX

    RangerX Member

    Joined:
    Jun 20, 2016
    Posts:
    2,594
    Exactly what I am saying. At some point it doesn't matter anymore but the statement stays true, if you don't scale by an integer factor, you get distortion. Its important to understand it in my opinion.
     

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