ScaleEX: New scaling filter for 2D art!

Community Forums/Showcase/ScaleEX: New scaling filter for 2D art!

ErikT(Posted 2010) [#1]
Hello everybody!

This here is my own addition to the scaling filters designed to make old-school pixel art more appealing to modern eyes. In contrast to filters like Bilinear and Bicubic Filtering which turns everything into a blurry mess, these smooth images by checking pixels around the source pixel to be scaled, then pick the most appropriate one out of those. So they're great for scaling lo-res art with few colors! There's only one problem: most of them are released under the GPL license, which kinda sucks for anyone wanting to use them in commercial projects. So I tried to rewrite the Scale2X algorithm without using any of the GPL'ed source code while borrowing a couple of tricks from Xenowhirl's RotSprite tool and Screaming Duck's Scale2X version. This is what I got so far. It produces smoother results than regular Scale2X but also runs a little slower:


Nearest neighbour:


ScaleEX:


Nearest neighbour:


ScaleEX:


Nearest neighbour:


ScaleEX:









The code is free to use for whatever you please. It's too slow to scale the entire screen in real-time, but definitely fast enough to pre-process images on loading a level for instance. I've also included a port of the standard Scale2X filter so you can compare them for speed and quality.

Last edited 2010

Last edited 2010


Robert Cummings(Posted 2010) [#2]
Looks really nice


RifRaf(Posted 2010) [#3]
Indeed.. now make it work realtime!


Robert Cummings(Posted 2010) [#4]
Don't think realtime is possible without the engine being 2D with serious SSE style optimisations for mid range machines. However, if one was to use shaders to achieve this it would be :)

Last edited 2010


Panno(Posted 2010) [#5]
cool looks much better imho


ErikT(Posted 2010) [#6]
Glad you all like :)

@RifRaf: Well the Scale2X filter is pretty much as fast as they get and even that one's too slow for realtime scaling in Blitzmax. So that leaves doing it with a pixel shader I guess.

Thing is I don't have a very good understanding of how shaders actually work. I know that a shader is a small program you apply to 3D surfaces and then it does nice things to them and stuff, but that's pretty much where my understanding ends. Can I read and write to pixels easily within a pixel shader? How do I get it to output a processed image for access inside bmax code? How does Blitzmax interact with shaders in the first place? Etc, etc.. I tried to read up on this but now my head hurts :P


EDIT:
Ok, been reading a lot and it's starting to seep in finally. I'm gonna give it a try and see what turns out.

Last edited 2010


Jesse(Posted 2010) [#7]
a bit faster. Input any valid format but it processes rgba images only:


Last edited 2010


ErikT(Posted 2010) [#8]
Oh crap, that's brilliant! How? I thought Read/Writepixel was the only way to get to pixels.

On my netbook, I get 87 millisecs now as opposed to 192 with the old code. Thx for sharing 8)

Last edited 2010


Jesse(Posted 2010) [#9]
take sometime and go through the modules source that interest you the most. you'll find a gold mind of information that I am sure you'll find useful for other projects as well.

Last edited 2010


GfK(Posted 2010) [#10]
cor, Moonstone!


MGE(Posted 2010) [#11]
For real time use, if you're just using x2 scaling, you can turn smoothing off and it looks great.


Leto(Posted 2010) [#12]
Sorry to be off-topic, but what is that second game? (with the angel)


ErikT(Posted 2010) [#13]
1. Final Fight
2. Castlevania: Order of Ecclesia
3. Moonstone


Chugs40(Posted 2010) [#14]
This looks really cool - right up my alley.

Sorry to be off-topic, but what is that second game? (with the angel)


Definately Castlevania: Order of Ecclesia


ErikT(Posted 2010) [#15]
Uploaded a fixed version to the code archives along with high quality versions:
http://blitzbasic.com/codearcs/codearcs.php?code=2791