Game Development Community

Mip Mapping

by James Sayer · in Torque Game Builder · 11/02/2005 (8:28 pm) · 4 replies

The game that I'm working on has a lot of scaling up/down of objects. They are often ten times smaller than the texture that they use. Of course when they get scaled down by that much the artifacts are quite bad.. I was wondering whether T2D supports mip mapping? I read a few threads that mention it but nothing concrete. I was under the impression that OpenGL could do automatic mip mapping (without having to save a bunch of different texture files of different resolutions).

Obviously I could manually do different texture sizes but it would be great if I could just put in one texture (at the highest resolution needed) and then it would get the lower resolutions computed automatically. Will this be in 1.1? Or is it already there and I just don't know? .. even the T2D Shooter demo has some scaling artifacts.. but nothing compared to my game because I'm scaling things by so much.

#1
11/02/2005 (9:48 pm)
Torque seems to support mipmaps (see gTexManager.cc). How exactly I don't know. Maybe you just set the "detail level" and it takes over?

Well I found this in gTexManager.h
line 29: 
/// Generally speaking, all textures will have mipmaps extruded automatically
/// and use linear magnification and linear_mipmap_nearest minification filtering
/// unless trilinear filtering is enabled.  Then, the minification is linear_maipmap_linear.
/// Most texture types have their bitmap data destroyed after texture creation.
/// Also, detail settings affect any of the textures except the ones noted.
/// Detail settings are based on the mip maps, so if the detail level is turned down,
/// the highest resolution detail map will NOT be the one that is in the actual
/// texture file, but one that has been averaged down appropriately.
///
/// @note "Small textures" are a different set of textures, dynamically created with
/// certain texture types whose first mip level is the same as the 4th mip level
/// of the first texture.  So, the full res small texture will be the same as the
/// 4th averaged down version of the origional texture.
Is mipmapping even necessary for a 2D game?
#2
11/03/2005 (5:45 am)
Hmm, that's interesting. I can't find anything in prefs.cs that changes the settings. I tried changing all the "detail" settings. I swear that mip mapping can't be turned on.

You don't usually need it in 2D games, because usually in 2D games you display stuff at the same pixel size that you store in the image file. But in T2D you often don't do this, you can scale sprites to whatever size you want no matter what the size of the texture.

I'm taking a 256*256 texture and displaying it as small as 20*20. Now, if I scaled it down using a good software method, say using photoshop, then the small image would still look good. But if you scale it down in 3D hardware, every frame, at different positions and rotations, then you get some nasty visual artifacts. So that is what I am trying to fix..

In 3D mipmapping prevents things that are far away from having bad texture artifacts.. so it's the same in 2D if you shrink it down. At least I thought that's what mipmapping does, maybe I'm wrong?
#3
11/03/2005 (10:31 pm)
In OGL I'm pretty sure mipmapping is based on distance from the viewport, which is probably flat in 2D. So I think T2D will need some algorithm to change mip levels as an object changes size, instead of distance. In the source it appears mipmapping is made for the 3D engine, but I bet there's a way to hack it to work in T2D. Then again I'm no expert..so hopefully one will come along to comment.

How bad are those artifacts? Got any screens to post?
#4
11/04/2005 (5:51 am)
Hmm, I didn't consider that it might be based on distance.

Here is an example of what it looks like. The main problem is actually the fact that it moves every frame. This creates a very noticeable shimmering effect that draws the eyes attention to it. The image on the right is just one that I scaled down in the Gimp. It's kind of blurry here, but it looks way better in motion.

www.dingogames.com/graphics/scaledownartifact.jpg