Jump to content

  • Log In with Google      Sign In   
  • Create Account


GL_NEAREST vs GL_LINEAR for Ortho Projection


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 Vincent_M   Members   -  Reputation: 581

Like
0Likes
Like

Posted 28 August 2013 - 05:27 PM

If I'm making 2D game, would it be better for both quality and performance to use GL_NEAREST for interpolation instead of GL_LINEAR? The reason I suggest that is that I'm assuming that although scaling may occur, everything is lined up with the device's screen.



Sponsor:

#2 Cornstalks   Crossbones+   -  Reputation: 6974

Like
2Likes
Like

Posted 28 August 2013 - 05:36 PM

If you're doing scaling or sub-pixel things, GL_LINIEAR will likely give better (visual) results.

 

Sure, GL_NEAREST is "faster," but I doubt GL_NEAREST vs GL_LINEAR is going to be your bottleneck.


[ I was ninja'd 71 times before I stopped counting a long time ago ] [ f.k.a. MikeTacular ] [ My Blog ] [ SWFer: Gaplessly looped MP3s in your Flash games ]

#3 Geometrian   Crossbones+   -  Reputation: 1458

Like
0Likes
Like

Posted 28 August 2013 - 07:28 PM

It depends on your desired look. If you want a pixellated look, you'll want GL_NEAREST with graphics assets that are smaller than the screen's pixels. Otherwise, use GL_LINEAR (and probably mipmapping). Keep in mind that texel boundaries won't be antialiased in screen space with nearest (especially a potential problem if you're handling rotations).
 

Sure, GL_NEAREST is "faster,"

Even though it's four taps, modern hardware optimizes it to be exactly as fast as a nearest tap. Mipmapping might be slower (but only because of caching issues; it's optimized just like linear, for 2D anyway).


And a Unix user said rm -rf *.* and all was null and void...|There's no place like 127.0.0.1|The Application "Programmer" has unexpectedly quit. An error of type A.M. has occurred.

#4 Cornstalks   Crossbones+   -  Reputation: 6974

Like
1Likes
Like

Posted 28 August 2013 - 07:37 PM

 

Sure, GL_NEAREST is "faster,"

Even though it's four taps, modern hardware optimizes it to be exactly as fast as a nearest tap. Mipmapping might be slower (but only because of caching issues; it's optimized just like linear, for 2D anyway).

There's a reason I put that in quotes :)


[ I was ninja'd 71 times before I stopped counting a long time ago ] [ f.k.a. MikeTacular ] [ My Blog ] [ SWFer: Gaplessly looped MP3s in your Flash games ]

#5 Geometrian   Crossbones+   -  Reputation: 1458

Like
0Likes
Like

Posted 28 August 2013 - 07:52 PM

Sure, GL_NEAREST is "faster,"

Even though it's four taps, modern hardware optimizes it to be exactly as fast as a nearest tap. Mipmapping might be slower (but only because of caching issues; it's optimized just like linear, for 2D anyway).

There's a reason I put that in quotes smile.png

I noticed that, but I couldn't parse it with the rest of the sentence so I gave a brief overview of the issue.
And a Unix user said rm -rf *.* and all was null and void...|There's no place like 127.0.0.1|The Application "Programmer" has unexpectedly quit. An error of type A.M. has occurred.

#6 Vincent_M   Members   -  Reputation: 581

Like
0Likes
Like

Posted 29 August 2013 - 11:06 AM

Ok, so staying away from GL_NEAREST is probably best since there could potentially be a lot of scaling involved. I think I should add the ability to enable mipmapping in case massive scaling calls for it. I've heard on other forums that mipmapping can actually be faster than GL_LINEAR due to caching because it doesn't require as many texture lookups internally.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS