Texture image file sizes

I believe that for automatic texture mipmapping to work, or at least to work efficiently, the image width and height must be powers of two.  Do I understand that part correctly; and is there any requirement that width == height?  For example, would 512 x 1024 meet the optimal size requirements?



Is there some way for me to detect whether mipmap transitions are occurring?  I looked though some jME texture classes and it looks like the mipmap transitions occur automatically at the OpenGL or hardware level, so I dont' think anything would work programmatically.  I think that ColorMipMapGenerator would defeat my attempt to test what happens by my own images, because I think it generates its own images.  I have tried observing effects as I move the camera with different minif/magnif settings, but I don't see any.  However, I don't really expect to see any since transition effects due to the interpolation settings probably depend largely on the texture and on the model positions, and the primary effect of mipmapping is to reduce resource usage while maintaining the same final visual quality (i.e. to make final visual quality match that of the non-mipmapped case).

Most video cards prefer power-of-two image sizes as they are faster. Older cards (i.e before OGL2) don't support textures that are not power-of-two. I am not sure about width == height because some (old) games I saw use textures with sizes like you specified 512x1024.

Is there some way for me to detect whether mipmap transitions are occurring?

mipmap transition, you mean fading between mipmaps? That's the linear mipmap modes, e.g NearestLinearMipMap and Trilinear that blend between mips.

E.g
Image and it's mipmaps


And how it's blended in hardware:
Momoko_Fan said:

Most video cards prefer power-of-two image sizes as they are faster. Older cards (i.e before OGL2) don't support textures that are not power-of-two. I am not sure about width == height because some (old) games I saw use textures with sizes like you specified 512x1024.
Is there some way for me to detect whether mipmap transitions are occurring?

mipmap transition, you mean fading between mipmaps? That's the linear mipmap modes, e.g NearestLinearMipMap and Trilinear that blend between mips.

I mean transitioning fron one mipmap image to another as camera distance vaires, whether or not interpolation is involved.


E.g
Image and it's mipmaps
...

And how it's blended in hardware:
...


That is excellent.  Thanks very much.  How the hell can I do that?  My ultimate goal is that I want to make sure that my game is actually taking advantage of mipmapping.  If I can't see any difference, I can't tell.
Momoko_Fan said:

... I am not sure about width == height because some (old) games I saw use textures with sizes like you specified 512x1024.


Momoko_Fan, my favorite jME buddy:

Any chance that I could get you to repeat the excellent demo that you ran below, after chopping one of the texture file dimensions in half?  That would verify that mipmapping is working with some multiple of 512x1024.

Blaine if you ask this to use it for HottBJ-Models (I love the exporters name  XD) then I wrote

yesterday a small fix. Don't know if that makes all sense but it works for me.



Just feed the method with your model's geometry . Maybe you can use it…


   public static void fixTexture(Geometry geom)
   {
      TextureState ts2 = (TextureState)geom.getRenderState(StateType.Texture);
      
      if (ts2!=null)
      {
         for (int i=0; i<ts2.getNumberOfSetTextures();i++)
         {
            Texture t = ts2.getTexture(i);
            if (t!=null)
            {
               t.setMinificationFilter(Texture.MinificationFilter.Trilinear);
               t.setMagnificationFilter(Texture.MagnificationFilter.Bilinear);
               t.setCombineFuncAlpha(CombinerFunctionAlpha.Modulate);
               t.setCombineFuncRGB(CombinerFunctionRGB.Modulate);
               t.setApply(ApplyMode.Modulate);
            }
         }
      }
   }



Might be that this only works for my special purposes at the moment! You have to play
with the modulate! Evtuall set to decal or so. Just started with textures and this is brain-feeding
stuff :D
ttrocha said:

Blaine if you ask this to use it for HottBJ-Models (I love the exporters name  XD) then I wrote
yesterday a small fix. Don't know if that makes all sense but it works for me.

Just feed the method with your model's geometry . Maybe you can use it....

   public static void fixTexture(Geometry geom)
...




Thanks, ToM, but I just want to know the image requirements for optimal mipmapping, and how to detect if the mipmapping is working.

I recommend that you do not use code as you have posted to overwrite all of those settings as written by HottBJ.  HottBJ makes the Apply setting based precisely on what the modeler has specified in the Blender interface.  About a wek ago I committed code which accurately does the same thing for the mini and magni filters.  Overwriting these on the jME side clobbers the settings which the modeler has made.  Just yesterday I was working with the Blender's texture Alpha and RGB settings.  I am certain that I can support normal transparency fully automatically by direct use of Blender's texture toggle buttons, once I have an hour to dedicate.

Ah,…yes! I saw the changes and it is working with transparency! Actually I don't know the way to fill in the apply

type in blender… but I will have a look now…

mipmap transition, you mean fading between mipmaps? That's the linear mipmap modes, e.g NearestLinearMipMap and Trilinear that blend between mips.

I mean transitioning fron one mipmap image to another as camera distance vaires, whether or not interpolation is involved.

Transitions from one mipmap image to another == Fading between mipmaps, that's what I meant. You know mipmaps are used if they are specified in the image (Image.hasMipmaps) and if either NearestLinearMipMap mode or Trilinear mode is used for minification filter. That's how you know programmatically if your mipmaps will be used on the hardware. If the GPU does not support non-power-of-two textures then they are scaled automatically by jME to be power-of-two so mipmaps still work even if the texture is NPOT. In other words, mipmaps are used regardless of what kind of texture you throw at jME, as long as the proper minification filter is set.

How the hell can I do that?  My ultimate goal is that I want to make sure that my game is actually taking advantage of mipmapping.  If I can't see any difference, I can't tell.

It's usually easy to tell this. One purpose of mipmaps is to reduce shimmering, as you go away from the model you'll notice pixels "shimmer" if mipmaps aren't used. Otherwise they will appear a little blurry but no shimmer as you go away from the model. Of course you can make a more concrete test by using ColorMipMapGenerator.

Momoko_Fan, my favorite jME buddy:

Any chance that I could get you to repeat the excellent demo that you ran below, after chopping one of the texture file dimensions in half?

That was not a demo, buddy blaine, but a wiki: http://www.modwiki.net/wiki/Editing_MIP_Maps
ttrocha said:

Ah,..yes! I saw the changes and it is working with transparency! Actually I don't know the way to fill in the apply
type in blender.... but I will have a look now....


You use the Texture Blend Mode pulldown, which is in Blender's Map To panel.
Momoko_Fan said:

...


As usual, you have saved me much research time.  Thanks very much!

This may be of interest regarding which cards support Non-Power of Two textures, as I've always understood the cutoff to be OpenGL2, but it seems that there was at least one exception:



NPOT Texture - OpenGL Wiki


Older hardware
The R300 and R400-based cards (Radeon 9500+ and X500+) are incapable of generic NPOT usage. You can use NPOTs, but only if the texture has no mipmaps.
NV30-based cards (GeForce FX of any kind) are incapable of NOPTs at all, despite implementing OpenGL 2.0 (which requires NPOT). It will do software rendering if you try to use it.
All newer hardware can handle NPOTs of any kind perfectly.