Game Development Community

Nearest neighbor filter?

by Dave "Jellybit" Freeman · in Torque Game Builder · 04/01/2005 (5:07 pm) · 14 replies

Is there a way to display 2D art by using the "nearest neighbor" kind of filtering?

I'm trying to make a 2D game with clear pixel art. However, the game engine filters and blurs the texture so that it loses the sharp pixel art look. Since the sharp look is a big part of the art style, I'm disappointed that I can't get my art assets to display correctly.

Is there a script command to change the filter? Am I overlooking something?

#1
04/01/2005 (5:09 pm)
Think I saw somewhere that in the future youd have control over this.
#2
04/01/2005 (5:25 pm)
Are you blowing your art up above its original size? That'd make it blurry also.
#3
04/01/2005 (5:36 pm)
Matt,

Well, I'm making it display in several resolutions, seeing as people with LCD monitors get blurry image quality if not in their native resolution. (I'm one of those people)

However, it seems that people with LCD monitors will get a blurry image no matter what.

I'm creating the art in 800x600. So, having a CRT monitor at that resolution will be the only way to see it near the intended artistic design. However, since I don't have a CRT, I can't be sure it won't blur at that resolution too.

If I draw at my monitor's resolution, it may as well be vector art (which I don't want to get near). The blocky retro feel of pixel art is something I strongly feel my type of game in particular should have. I created art assets carefully around this.

Anyway, if it's planned for a future version, I guess I could always just work on scripting and tweaking gameplay until that happens. But I'll probably have to hold off on the visuals until I see how it looks and works...

Thanks guys.
#4
04/01/2005 (5:47 pm)
On this LCD (19") I get blurry text on websites if I don't have it running in its native resolution... just a quirk of LCD's =/ at least some of em
#5
04/01/2005 (6:15 pm)
Yes, that's why it's important to me to get the lower resolution graphics to display correctly on higher resolution LCDs. A lot of people are using them now. Especially the market I'm going after.

But as the engine is now, even if I raise the resolution of the game to LCD native resolution, it will be blurry. If they run in lower proper resolution, it will be blurry. There's no winning.
#6
04/01/2005 (6:21 pm)
Hmm, you try larger textures ?

the off resolution LCD problem is unavoidable as far as I know... I looked at the same pages in both resolutions ones clear the other isnt... just a monitor quirk...
#7
04/01/2005 (6:41 pm)
Oh yes, definitely unavoidable. It's a limitation of the hardware. I was trying to get around that by running in native resolution and turning off filtering. I haven't tried doubling or quadrupling the texture size, but that seems like a waste memory-wise... It's definitely worth a try. Especially since, from what I gathered, it shouldn't be hard to replace them with lower res versions in the future, when they add the nearest neighbor feature.

From what I've gathered in scripting... since it uses "unit" values, instead of pixel values, I could replace a 10x10 texture with a 1000x1000 texture and get the same size of sprite on screen.

Thanks for the idea. Again, I hate to waste memory, but if I can at least work on the visuals now, I'll be happy. Then maybe later, I can plug in the proper sized textures later, and use the new nearest neighbor feature.

Hopefully, all will be right as rain :). Also, I hope that quadrupling the texture size will work. It sounds like it would.

Thanks!
#8
04/01/2005 (6:49 pm)
Yeah... could then just have settings for "detail levels"... bigger resolutions will require bigger resolution textures... Its a pain I know, lol wish these awesome looking LCD's looked awesome at any resolution
#9
04/01/2005 (11:04 pm)
Yikes... I wonder how much size that would add to my download... But... good temporary workaround maybe.
#10
04/02/2005 (12:09 am)
Yeah... and though the game size would increase it would match up to commercial games, considering they usually have detail levels for all sorts of machines to be compatable :)
#11
04/02/2005 (1:40 am)
It is possible to allow this to be selected and we'll definately be adding more fine-grained control over things such as texture sampling as well as other stuff.

- Melv.
#12
04/02/2005 (1:50 am)
Wonderful. Thank you Melv, and Rob.
#13
04/11/2005 (3:19 am)
@David: I added a pretty dirty hack over at the C++ Engine forum.
#14
04/11/2005 (4:50 pm)
That looks wonderful. I can't wait to try it out. I wondered how it'd look if you turned off the filtering, and scrolled a sprite that didn't use the native resolution. Hopefully, working at 800x600 will minimize the effect. Or maybe it will accentuate it?

Thank you much, Hans.