GMS 2 image_angle and distorted pixels

Discussion in 'Programming' started by Cautious Cactus, Jun 13, 2019 at 7:10 PM.

  1. Cautious Cactus

    Cautious Cactus Member

    Joined:
    May 27, 2019
    Posts:
    12
    Hey, I'm working on a topdown game at low resolution and I use image_angle to rotate my wepons, I use a 320x240 resolution scaled to 960x720 or 1280x960.

    The weapons sprites get really distorted, see image : https://imgur.com/a/qSHJssF

    I tried pixel interpolation but it only makes everything blurry.

    Anyway I can fix this without scaling up all my sprites ?

    Thanks
     
  2. nacho_chicken

    nacho_chicken Member

    Joined:
    Jun 21, 2016
    Posts:
    302
    Pixels are square. You can't rotate anything on a display that uses square pixels without distortion. The trick is finding ways to minimize the distortion.

    How are you upscaling the original picture? If you're just upscaling the application surface, you will get the same amount of distortion you get at 320x240, meaning there's a ton of horrible-looking distortion. If you instead upscale all your sprites (e.g. 3x Scale for 720p), distortion will be far less noticable. This is what games like Terraria do.
     
  3. Cautious Cactus

    Cautious Cactus Member

    Joined:
    May 27, 2019
    Posts:
    12
    I use the viewport to scale the resolution, I see games like Nuclear Throne and you can play the game at like 320x180 and there's no distortion, really wish there would be another way than scaling all the sprites up manually
     
  4. nacho_chicken

    nacho_chicken Member

    Joined:
    Jun 21, 2016
    Posts:
    302
    There likely is another way, since the example you gave looks distorted beyond what I'd consider normal. I'd wait for someone else to chip in before doing anything drastic, if only because I'm not the best when it comes to this topic.
     
  5. Nocturne

    Nocturne Friendly Tyrant Forum Staff Admin

    Joined:
    Apr 13, 2016
    Posts:
    6,644
    Increase the size of the application surface to double the pixel count. My game Alpha Dog is actually programmed at a resolution of 90x45 (!), yet the app surface is more like 5 times that, so the rotations are silky smooth. Basically, just get the size of the camera width/height and then set the app surface to the same values time 2 or times 3 (eg: a camera of 320x240 would have an app surface of 640x480 or even 960x720).

    Here's how my game looks, btw...

    [​IMG]
     
    Last edited: Jun 13, 2019 at 7:41 PM
  6. Cautious Cactus

    Cautious Cactus Member

    Joined:
    May 27, 2019
    Posts:
    12
    Exactly what I needed, I did a

    view_w = camera_get_view_width(view_camera[0]);
    view_h = camera_get_view_height(view_camera[0]);
    surface_resize(application_surface, view_w*4,view_h*4);

    at the start of the game and it already looks better, I will play around the multiplier to get it right, thanks Nocture :)
     
    Nocturne likes this.
  7. NightFrost

    NightFrost Member

    Joined:
    Jun 24, 2016
    Posts:
    1,757
    I do my pixel stuff with the multiplier method as well, except I calculate the multiplier at the start of the game, comparing my target size (like 480x270) to display size. This global.Scaling is then used to scale up everything siuch as app surface, camera, sprite draws and movement speeds. A noninteger multiplier is not desirable for much of that so I floor it, and if necessary calculate a stretch ratio for when app surface gets drawn to buffer. For example if there existed a 2100 wide display, 2100/480=4.375 which floors to 4 and gives an app surface width of 1920, and 2100/1920=1.09375 for surface draw stretch. The same of course is done with height so aspect ratio can be taken into account and centering values can be calculated if display's aspect is not the same.

    EDIT - also image_xscale and image_yscale. Since we're stretching sprites here we must set these to stretch the mask too. Otherwise GMS will use original sprite values for masks.
     

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