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

Asset - Shaders Better Scaling (free)

Discussion in 'Marketplace' started by Dragon47, Jul 27, 2016.

  1. Dragon47

    Dragon47 Member

    Joined:
    Jul 6, 2016
    Posts:
    179
    [​IMG]


    This asset consists of two functions: better_scaling_draw_sprite and better_scaling_draw_surface. These are just like draw_sprite_ext and draw_surface_ext except they improve how your image is scaled.

    Depending on whether you scale down or scale up, the functions will choose between 8 different shaders to improve the scaling. Scaling down draws the image with a supersampling shader (meaning more detail is kept since more pixels are sampled). When scaling up, you can choose between a bicubic interpolation shader (smoother lines) or a set of depixelization shaders (specialized for finding and scaling patterns in pixel art, like the filters you see in emulators).

    Marketplace link: https://marketplace..../better-scaling


    Screenshots:
    [​IMG]


    [​IMG]


    [​IMG]


    [​IMG]


    [​IMG]


    [​IMG]
     
    TheSnidr and Jaqueta like this.
  2. origamihero

    origamihero Member

    Joined:
    Jul 11, 2016
    Posts:
    12
    These shaders are really awesome and easy to use. Thanks for sharing!
     
  3. Bacon&Onions

    Bacon&Onions Member

    Joined:
    Aug 2, 2017
    Posts:
    43
    Great job!
     
  4. Dragon47

    Dragon47 Member

    Joined:
    Jul 6, 2016
    Posts:
    179
    Thanks!
     
  5. Bacon&Onions

    Bacon&Onions Member

    Joined:
    Aug 2, 2017
    Posts:
    43
    Hey dragon, as much as I love your better scaling function I'm experiencing a strange bug that's preventing me from using them after I imported it to my game. When sprites scale up across all tested platforms(windows and html5) I'm getting a black box around the sprite image
    [​IMG]
    [​IMG]

    I'm using gamemakerstudio2 in the draw event where draw_sprite_ext would function normally, using filter 5. The shrinking filter works fine and looks great.
    Just using it normally as
    better_scaling_draw_sprite(sprite_index,image_index,x,y,image_xscale,image_yscale,image_angle,image_blend,image_alpha,5) instead of draw_sprite_ext() in any sprite causes the problem and I have no idea why.
     
    Last edited: Aug 15, 2017
  6. Dragon47

    Dragon47 Member

    Joined:
    Jul 6, 2016
    Posts:
    179
    It's probably a GameMaker Studio 2 bug. The asset was made in GameMaker Studio 1, and I haven't tested it on GameMaker Studio 2.
     
  7. Bacon&Onions

    Bacon&Onions Member

    Joined:
    Aug 2, 2017
    Posts:
    43
    The original file works great in gamemaker2. I only started to have problems when I tried importing the project.
     
  8. Dragon47

    Dragon47 Member

    Joined:
    Jul 6, 2016
    Posts:
    179
    Oh, with a second look it looks like it might not be a GameMaker 2 bug after all. Filter 5 doesn't support transparency very well. If you want to you can go into the better_scaling_draw_sprite script and set the color that should be made transparent by typing it in on line 52 were the negative ones are. Or you can draw everything to an opaque surface without scaling applied, and then draw the surface scaled with better_scaling_draw_surface. This way everything will be scaled with filter 5 in one draw pass.
     
  9. Bacon&Onions

    Bacon&Onions Member

    Joined:
    Aug 2, 2017
    Posts:
    43
    I understand the drawing everything to a single surface idea. I may do that. For the setting the color to be transparent, I don't understand. The sprites have a transparent background. What value would I put in for that? Would I have to manually fill all the images with a color and then have it be taken out?
     
  10. Dragon47

    Dragon47 Member

    Joined:
    Jul 6, 2016
    Posts:
    179
    You can do it manually or you can look at the transparent area's color and enter this into line 52. You can use a color copy tool in an image editor to see the color of the transparent area.

    If you're interested, filter 2 is a depixelation shader that supports transparency completely.
     
  11. Bacon&Onions

    Bacon&Onions Member

    Joined:
    Aug 2, 2017
    Posts:
    43
    Thanks Dragon, I ended up going with filter 2 This is a great fix for having some of my art assets made at too low of a resolution.
     
    Dragon47 likes this.
  12. ShaunJS

    ShaunJS Just Another Dev GMC Elder

    Joined:
    Apr 12, 2016
    Posts:
    148
    Hey dude!

    I can't seem to get this working in GMS2. It complains that 5xbrb and 5xbrc are invalid shaders, any ideas? :(
     
  13. Dragon47

    Dragon47 Member

    Joined:
    Jul 6, 2016
    Posts:
    179
    This is a GMS1 asset, so I think the problem is a result of that. I remember having a similar issue when porting a GMS1 asset to GMS2 once. Try to create a new shader, copy the contents of the invalid shader into this one and rename it to the same name as the invalid shader (after deleting the invalid shader). I think this should work.
     
  14. Chreech Okash

    Chreech Okash Member

    Joined:
    Sep 29, 2016
    Posts:
    48
    Can you make this shader compatible with mobile devices? It will be very useful for them.
     
  15. Dragon47

    Dragon47 Member

    Joined:
    Jul 6, 2016
    Posts:
    179
    I'm sorry, but it would take quite some time to do, and most of my focus lies elsewhere, so I don't currently have any plans for 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