Asset - Shaders Better Scaling (free)

Dragon47

Member



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:















 
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



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:

Dragon47

Member
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



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.
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.
 

Dragon47

Member
The original file works great in gamemaker2. I only started to have problems when I tried importing the project.
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.
 
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.
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?
 

Dragon47

Member
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.
 

ShaunJS

Just Another Dev
GMC Elder
Hey dude!

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

Dragon47

Member
Hey dude!

I can't seem to get this working in GMS2. It complains that 5xbrb and 5xbrc are invalid shaders, any ideas? :(
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.
 
I'm using the better scale surface draw command, and a room has a scaling sprite.

The scaled sprite moves bigger as if it is getting closer.

The sprite has the GM interpolation on it when moving bigger, even though the code for the surface draw command turns off the interpolation.

This is what it looks like with the better scale command
interpolation.png

And this is what it looks like without.
not interpolation.png

I'm using the 5xbra depixel shader and using it from bigger_sprite_draw_surface.
I'm also using GameMaker:Studio 1.4
How do I make it so that there is no interpolation?
 

Dragon47

Member
I'm using the better scale surface draw command, and a room has a scaling sprite.

The scaled sprite moves bigger as if it is getting closer.

The sprite has the GM interpolation on it when moving bigger, even though the code for the surface draw command turns off the interpolation.

This is what it looks like with the better scale command
View attachment 27692

And this is what it looks like without.
View attachment 27693

I'm using the 5xbra depixel shader and using it from bigger_sprite_draw_surface.
I'm also using GameMaker:Studio 1.4
How do I make it so that there is no interpolation?
Weird, not sure what's going on. Download the example and see if you can modify it to what you want.
 
I would like to know if atleast better downscaling can be compatible with mobile devices? Because mobile devices have different screen resolutions and suppose i make a game targetting resolution 1280x720 and run it on a device with 960x640 display then it looks jagged. If you can fix it at least then that would be a great help.
 
I would like to know if atleast better downscaling can be compatible with mobile devices? Because mobile devices have different screen resolutions and suppose i make a game targetting resolution 1280x720 and run it on a device with 960x640 display then it looks jagged. If you can fix it at least then that would be a great help.
It's a free asset. Be happy it exists. If you really want a specific option, perhaps consider seeing if you can hire the OP and pay for their time spent developing the features you want.
 
It's a free asset. Be happy it exists. If you really want a specific option, perhaps consider seeing if you can hire the OP and pay for their time spent developing the features you want.
It exists and it's a great work. That's exactly why i want it to be compatible with android and become useful. Also there is no need to put it as a free asset. I would be be willing to pay for it if it's possible and i bet many people are facing similar issues and they would be willing to buy it too.
 

Dragon47

Member
It exists and it's a great work. That's exactly why i want it to be compatible with android and become useful. Also there is no need to put it as a free asset. I would be be willing to pay for it if it's possible and i bet many people are facing similar issues and they would be willing to buy it too.
I don't have time to continue working on this, but the code is pretty simple if you know a little about shaders. Part of the reason I put it up as free is because the asset is relatively simple/quickly made compared to my other assets. Glad you like it!
 
oh yeah, i never was able to find a fix for the interpolation issue, but since the project i was using it for is basically scrapped now, i dont really have a need to find a fix anymore
thanks for the help tho! 👍
 

Dragon47

Member
oh yeah, i never was able to find a fix for the interpolation issue, but since the project i was using it for is basically scrapped now, i dont really have a need to find a fix anymore
thanks for the help tho! 👍
You probably thought this was a PM. No problem though! Haha
 
Top