Sign in to follow this  
Vincent_M

GL_NEAREST vs GL_LINEAR for Ortho Projection

Recommended Posts

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

 

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 :)

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this