GL_NEAREST instead of GL_LINEAR

Oh yea. Works like a charm. Makes my game look crisp and clear! This is exactly what I want, and what Corona devs using pixel art need!!! Now instead of people saying it looks blurry for a pixel game, They will say it looks sharp for a pixel game and I can tell them, Well that’s because I use Corona. :wink:

Really, I think it was a great move on Corona’s part. [import]uid: 100299 topic_id: 35825 reply_id: 143095[/import]

Great to hear!
Eric, can I ask what the name of your game is? I’d like to see it in action. :slight_smile:

Brent
[import]uid: 200026 topic_id: 35825 reply_id: 143098[/import]

Yeah, just tried it on my project as well, and it works perfectly!

Until the docs reflect this, here’s how it works:

display.setDefault( "magTextureFilter", "nearest" ) display.setDefault( "minTextureFilter", "nearest" )

Set that either in main.lua (if you want all art to abide) or as needed (if you need it piecemeal.) Changing “nearest” to “linear” goes back to the old scaling. (Not really intuitive, but ‘min’ means ‘minimized’ while ‘mag’ means ‘magnified’…)

There are three big reasons why Corona users are going to want to consider using this mode:

  1. For assets that are meant to be pixelated, this means you don’t need to use the 1px extrude method. (That means you don’t need to use TexturePacker or something, no Tiled special settings, just go!) Saves a little bit on space and an awful lot on confusion.

  2. For assets that are meant to be pixelated, they should look crisp “pixel doubled” at most even scales. (So you don’t have to provide different assets for iPhone/iPad/etc) If you’re using, say, 16x16 assets instead of 48x48, that’s a huge savings in filesize.

  3. You also don’t have to provide @2x assets! Again, a big savings in file size; since the assets scale crisply you’ll only need @assets for uneven zoom modes where you’re not comfortable with the nearest neighbor scaling results. [import]uid: 41884 topic_id: 35825 reply_id: 143099[/import]

Hmm. Something weird going on, not directly related to this I suppose:

old tilemap: 500x400, RGB8 png: 12kb
save the old tilemap as a new name (no format changes): 154kb
new tilemap: 80x64, RGB8 png: 54kb

Is there some space saver I’m missing or is OSX reporting the wrong filesize?

EDIT: Dropbox is saying the files are all sub 10kb, so maybe it is…

[import]uid: 41884 topic_id: 35825 reply_id: 143104[/import]

Brent Sorrentino:

http://phandroid.com/2013/02/13/hands-on-questlord-is-like-an-8-bit-skyrim-lite-for-your-smartphone-video/

looks like he was getting to eager to swipe out of his turn (Its turn based), yet enjoying it anyhow!

My user reviews are plenty and holding strong at 4.5 stars!!!
Richard:

I actually x2 my pixel graphics to minimize the ‘blur’ effect as is. So I could be using 1/4th the TextMem space if I didn’t do that. I was getting desperate for a solution and the guys on irc were suggesting @2 for my pixel graphics for a quick fix!! So glad this came out when it did! I currently clock in at 18mb, mostly sound. :smiley: [import]uid: 100299 topic_id: 35825 reply_id: 143109[/import]

For anyone interested, here is what the new settings ‘look’ like:

http://snag.gy/dirjD.jpg

The graphic (soda_can.png from the Corona SampleCode -> Physics ->Bullet folder) is a 22x40 png. I show the original, and a 3x scaled version right next to each other. (The bottom right is scaled 2.7x … just playing with the settings :slight_smile: )

I used 4 distinct copies of the file so that I could load each with different settings.

Here’s the code: http://pastebin.com/2YC3npQh [import]uid: 135765 topic_id: 35825 reply_id: 143112[/import]

Maybe I’m doing something wrong but I can’t get this to work with sprites using imageSheets.

On a normal image it works fine but I can’t understand how I can use it for animations?

I presume it’s because the new call affects only the display.* namespace, however imageSheets use graphics.*

I suppose I could create the original frames in the correct dimension, but I thought the case was that this allowed visuals to scale up appropriately? e.g my tiddly 16x16 scales perfectly up to 64x64?!?

If anybody can point me in the right direction I’d be very appreciative. [import]uid: 33275 topic_id: 35825 reply_id: 143498[/import]

I tested only with imageSheets and it worked fine, so maybe you’re using the command in the wrong place? (You’re right that it affects display.* but in order to use that imageSheet you should be using display.newSprite or display.newImage…)

Remember that when you use display.setDefault it only applies to sprites made AFTER the command is issued, which is why I recommend using it at the start. It can’t turn a display object using one method into the other. [import]uid: 41884 topic_id: 35825 reply_id: 143539[/import]

Hi Richard9, I’m using the following code, can’t seem to find any problem in the following code:

local sheetInfo = require("Episode1.1.frogFrames")  
  
--graphics.setDefault( "minTextureFilter", "nearest" )  
--graphics.setDefault( "magTextureFilter", "nearest" )  
  
local myImageSheet = graphics.newImageSheet( "Episode1/1/frogFrames.png", sheetInfo:getSheet() )  
  
local sequenceData = {  
 { name="jump", frames={1,2,1}, loopCount=1, time = 100 },  
 { name="lick", frames={ 1,3,1}, time=50, loopCount=4 },  
}   
  
display.setDefault( "minTextureFilter", "nearest" )  
display.setDefault( "magTextureFilter", "nearest" )  
avatar = display.newSprite( myImageSheet, sequenceData )  
--avatar = display.newImageRect(group2,"Episode1/1/images/frog.png", 60,60)  
avatar.xScale = 4  
avatar.yScale = 4  

If I’m doing something wrong here I’d be very grateful for a point in the right direction. When I uncomment the newImageRect line - it works perfectly, just can’t get display.newSprite to work accurately. [import]uid: 33275 topic_id: 35825 reply_id: 143559[/import]

Just tried to pull out a static image from the imageSheet with the following code, and still getting a blurred image ?!?!

  
local sheetInfo = require("Episode1.1.frogFrames")  
  
--graphics.setDefault( "minTextureFilter", "nearest" )  
--graphics.setDefault( "magTextureFilter", "nearest" )  
  
local myImageSheet = graphics.newImageSheet( "Episode1/1/frogFrames.png", sheetInfo:getSheet() )  
  
local sequenceData = {  
 { name="jump", frames={1,2,1}, loopCount=1, time = 100 },  
 { name="lick", frames={ 1,3,1}, time=50, loopCount=4 },  
}   
  
display.setDefault( "minTextureFilter", "nearest" )  
display.setDefault( "magTextureFilter", "nearest" )  
avatar = display.newImage( myImageSheet, 1 )  
--avatar = display.newSprite( myImageSheet, sequenceData )  
--avatar = display.newImageRect(group2,"Episode1/1/images/frog.png", 60,60)  
avatar.xScale = 4  
avatar.yScale = 4  

So to summarise:

I can correctly display a scaled up pixeled graphic using avatar = display.newImageRect(group2,“Episode1/1/images/frog.png”, 60,60).

I can’t create an animated sprite and scale it up.

I can’t get a static image out of the imageSheet and scale it up.

Must be doing something really wrong. [import]uid: 33275 topic_id: 35825 reply_id: 143561[/import]

*Duplicated post* [import]uid: 33275 topic_id: 35825 reply_id: 143562[/import]

Maybe a Corona dev can chime in, because your code looks mostly right. The fact that it still blurs means that it’s likely an order issue. Perhaps your getSheet() code is trying to scale something before it gets to display.newSprite? What happens if you move setDefault to the top of that code sample?

(Oh, and are you using 1031?) [import]uid: 41884 topic_id: 35825 reply_id: 143577[/import]

Apologies - I have this all working now, damn forward reference was cancelling out something :slight_smile:

Thanks for your input. [import]uid: 33275 topic_id: 35825 reply_id: 143587[/import]

Hello Eric,
I just wanted to write and address this. I mentioned your issue to the engineers last week, and today (Saturday, Feb. 16), I see a new feature rolled into Daily Build 1031. Can you let me know if this will solve your dilemma? As a Pro subscriber, you can test it immediately.

http://developer.coronalabs.com/release/2013/1031/

Sincerely,
Brent Sorrentino

[import]uid: 200026 topic_id: 35825 reply_id: 143078[/import]

Holy crap.

This should fix a few bug report issues and solve one of the feature requests. Will try to test this ASAP. [import]uid: 41884 topic_id: 35825 reply_id: 143090[/import]

richard9: Yes, it also instantly solves the ‘sliver’ or ‘thin lines’ when making tile graphics. Because each tile is not sampling to the blank ‘alpha’ that surrounds each tile.

KUDOS CORONA!!! [import]uid: 100299 topic_id: 35825 reply_id: 143096[/import]

Oh yea. Works like a charm. Makes my game look crisp and clear! This is exactly what I want, and what Corona devs using pixel art need!!! Now instead of people saying it looks blurry for a pixel game, They will say it looks sharp for a pixel game and I can tell them, Well that’s because I use Corona. :wink:

Really, I think it was a great move on Corona’s part. [import]uid: 100299 topic_id: 35825 reply_id: 143095[/import]

Great to hear!
Eric, can I ask what the name of your game is? I’d like to see it in action. :slight_smile:

Brent
[import]uid: 200026 topic_id: 35825 reply_id: 143098[/import]

Yeah, just tried it on my project as well, and it works perfectly!

Until the docs reflect this, here’s how it works:

display.setDefault( "magTextureFilter", "nearest" ) display.setDefault( "minTextureFilter", "nearest" )

Set that either in main.lua (if you want all art to abide) or as needed (if you need it piecemeal.) Changing “nearest” to “linear” goes back to the old scaling. (Not really intuitive, but ‘min’ means ‘minimized’ while ‘mag’ means ‘magnified’…)

There are three big reasons why Corona users are going to want to consider using this mode:

  1. For assets that are meant to be pixelated, this means you don’t need to use the 1px extrude method. (That means you don’t need to use TexturePacker or something, no Tiled special settings, just go!) Saves a little bit on space and an awful lot on confusion.

  2. For assets that are meant to be pixelated, they should look crisp “pixel doubled” at most even scales. (So you don’t have to provide different assets for iPhone/iPad/etc) If you’re using, say, 16x16 assets instead of 48x48, that’s a huge savings in filesize.

  3. You also don’t have to provide @2x assets! Again, a big savings in file size; since the assets scale crisply you’ll only need @assets for uneven zoom modes where you’re not comfortable with the nearest neighbor scaling results. [import]uid: 41884 topic_id: 35825 reply_id: 143099[/import]

Hmm. Something weird going on, not directly related to this I suppose:

old tilemap: 500x400, RGB8 png: 12kb
save the old tilemap as a new name (no format changes): 154kb
new tilemap: 80x64, RGB8 png: 54kb

Is there some space saver I’m missing or is OSX reporting the wrong filesize?

EDIT: Dropbox is saying the files are all sub 10kb, so maybe it is…

[import]uid: 41884 topic_id: 35825 reply_id: 143104[/import]