mipmapping issue

I’ve specified my own mipmaps for a texture starting at 512x512, and I’ve noticed that OpenGL decides which level to use based on distance AND size.

So if I have 2 polygons right next to each other, one being about .2 units in width and height and the other 1 unit in width and height, the smaller will be textured with the last mipmap while the largest will be textured with the 512x512.

Is there any way to manually tell OpenGL to only use distance instead of size to determine mipmap level? Or is this a pixel shader solution?

I doubt you’ll achieve something in pxsh. But mip lavels are used depending on how much of the screen is covered. (poly-wise LOD’ing?)

Mipmap selection doesn’t have anything to do with size or distance as such. It’s also not “per-poly LOD” as madman suggests – a single poly can have multiple mipmap levels on it.

The goal of mipmapping is to reduce texture aliasing. Mipmaps are chosen so as to achieve a texel-to-pixel ratio that’s as close as possible to 1:1.

Check section 3.8.8 of the spec for details on the mipmap selection procedure. There are a few parameters that you can override to influence the decision. There’s also the TXB instruction in ARB_fp and the TXP instruction in NV_fp that give you some control over texture LOD.

– Tom

And if you want better visual effects, look for anisotropic filtering.

SeskaPeel.

Hey thanks for the replies.

Basically what I was going for is, let’s say I have a terrain with mountains in the background you can walk to. I have a single mud texture being tiled across the terrain, and I wanted the distance mountains to only appear as a smudge of brown, instead of having detail. Then as you walk closer, the smudge slowly fades into the actual texture.

I tried specifiying my own mipmaps starting with 512x512, and made everything 64x64 and under just a single colored texture. But the mountains never switch to these levels, they always stay at 128x128 or above. This is my problem.

But I’ll take a look at those specs.

There is “Texture LOD Bias” demo in NVEffectBrowser, probably that may give you some idea. The link to specification is:
oss.sgi.com/projects/ogl-sample/registry/ EXT/texture_lod_bias.txt

Well I found two parameters for controlling the lod bias.

GL_TEXTURE_MIN_LOD and GL_TEXTURE_MAX_LOD

Now, when I set the GL_TEXTURE_MAX_LOD to any value, all the sudden my program takes 60% of my cpu and the frame rate is about 0.1 fps. It’s really wierd, anybody have any ideas why setting this value causes it to run so slow?

And I am only executing this command along with loading the textures at the beginning of the program, not during the main loop.

Is your video card in this list?
http://www.delphi3d.net/hardware/extsupport.php?extension=GL_EXT_texture_lod

– Tom

No, it’s not. But I have a program that displays all extensions supported by your video card, and that extension does show up for mine. I’m using a Radeon 9800 Pro 128MB. Although I’m not using the GL_EXT_texture_lod extension itself, I’m simply changing the OpenGL variables I specified above. So there should not be this slowdown should there?

Using MIP mapping to fake distance fade is not a good idea, because glancing surfaces (sides of objects, etc) will also use a higher MIP map level. MIP map selection is done typically based on the magnitude of the per-pixel interpolands of texture coordinates.