Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm working on a 2D game using OpenGL 1.5 that uses rather large textures. I'm seeing aliasing effects and am wondering how to tackle those.

I'm finding lots of material about antialiasing in 3D games, but I don't see how most of that applies to 2D games - e.g. antisoptric filtering seems to make no sense, FSAA doesn't sound like the best bet either.

I suppose this means texture filtering is my best option?

Right now I'm using bilinear filtering, I think:

glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

From what I've read, I'd have to use mipmaps to use trilinear filtering, which would drive memory usage up, so I'd rather not.

I know the final sizes of all the textures when they are loaded, so can't I somehow size them correctly at that point? (Using some form of texture filtering).

share|improve this question
    
You really should add mipmaps for your textures, at least some of them, it will improve visual quality. Other than that, aliasing is usually on the polygon level, so you could use some image-space antialiasing technique to optimize the textures quality. –  Grimshaw May 7 '13 at 14:33
    
Note that mipmaps increase the memory usage only by 33%. –  msell May 7 '13 at 15:22
    
Picture please. Also, how are you using the textures? Will any of them be used at loss of detail zoom out level? –  eBusiness May 7 '13 at 16:10
    
@DevilWithin 33% more is quite a bit in my case. On a MacBook Pro Retina, I'm already at 1 GB of resident memory use for the huge artwork. Also, speculatively generating smaller images seems wasteful, I know exactly how big my texture is going to be on screen at load time. –  futlib May 8 '13 at 9:05
1  
futlib, artwork is not supposed to be at the local RAM memory! Unless you need to manipulate exceptional cases at runtime, you shouldn't have any images in the RAM. You load them, you upload to the GPU as a texture and unload the pixel data. Even if you only have 256MB or RAM and 256MB of video ram, I am sure you can fit everything into it. Most AAA games deal with that in huge worlds, I am sure you could too ;) –  Grimshaw May 8 '13 at 12:35
show 4 more comments

2 Answers

Resample the image as soon as you know the target size.

You can use the GPU to resample with hardware acceleration:

  1. Load your big texture and enable/create mipmaps.
  2. Create your real texture at the perfect size.
  3. Use an FBO to draw the big texture as a quad into the small texture.
  4. Delete the big texture from memory.

Or you can use the CPU if you aren't satisfied with how mipmaps look, but going further than that in image quality would be a much longer answer, and probably more suited to another stack network site as it's more of general programming algorithm question. With that said, SDL_rotozoom can give you the basic idea of how it can work at the lowest level.

share|improve this answer
add comment

Techniques like filtering and mipmaps will be useful when you have projections different from Orthogonal (specially anisotropic filters), or you don't previously know the resulting size of your textures on screen. And this, as you mention it, is not your case.

I think the best answer for your problem is first to ensure the 1:1 aspect ratio between your source art and the presentation of it, and exploring the use of Multisampling, where it will sample a pixel multiple times with slightly variations and then combine them.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.