[SOLVED] General OpenGL question - Mipmap level decided on only one axis

All,

I have an annoying problem. I am mipmapping my road texture and it works fine when you look straight at it. However, when you make either the X or the Y axis really small compared to the other axis by looking at it in a slope (see attached picture) it takes the mip map of the lower quality and applies it instead of using the higher quality one.

Any good way to solve it? What I’d expect is that seeing as, for example, the X axis needs the higher quality texture it’d use the higher quality one instead of using the Y axis lower quality one (seeing as the Y axis is squeezed together).

Any solution to this? It doesn’t matter if I generate my own mip maps or use the opengl generatemipmap function, both give the same problem.

If I’m not mistaken, the solution to your problem would be to use anisotropic filtering. OpenGL supports this through an extension but it’s pretty easy to use. I’d post an example, but I’m at work :persecutioncomplex:

this is one thing I dislike on hardwae as you are dependant on : GPU / GC drivers / OpenGL and user setting … and then finally you never know how it will really look like on end users computers…

enabling anisotropic filtering may help if user GC & its custom setting support it, but I guess that trying your demo on another computers or with differents GC and/or drivers (wich may use different mipmap algos) may be another solution too :-\

EDIT : you should be able to force anysitropic in your GC panel setting to test

can you put it online ?

Another option, if you’re only concerned with the blurryness is to mess with texture lod bias, which you can set to bias against choosing the lowest mip levels except under extreme angles (at the tradeoff of a certain amount of temporal aliasing).

Thanks for all the tips. It’s online at dreamlandz.com (just fill in something random as username and password). It isn’t the newest version but it has this issue present.

I’ll look into the different advices when I’m at work :slight_smile:

as the road looks sort of pixelly, i was curious as to what minFilter, and magFilter you are actually using?

I use:

GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR_MIPMAP_LINEAR);
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
GL11.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_MODULATE);

and iv never had results that ugly.

Also the road pixel size looks different to the grass pixel size, are they handled differently, as its only the road that is returning the bad results.

I use the same min/mag filter as you. I don’t use the texture_env though but I don’t see any difference when I do and when I don’t.

The reason why they are pixly is because I use Alpha_test and they are as big as the grass tiles but part is transparent.

The reason why the grass looks better is because it doesn’t use Alpha_test and covers the whole tile.

I could use blending instead which would look nicer but then I’d have to sort everything when I draw it which isn’t something I’d like seeing as the camera can rotate and the landscape isn’t static.

Or you could use polygon offset to ensure that the roads are in front of the grass.

I already do, it is always in front, it doesn’t have to do with them sharing the same Z value.

That didn’t work, it still takes the wrong mipmap. I could make everything really blurry though, was a fun setting :slight_smile:

It didn’t take any FPS and it looks great with:

    		if (GLContext.getCapabilities().GL_EXT_texture_filter_anisotropic){
    			final FloatBuffer MaxA=FloatBuffer.allocate(16);
    			MaxA.rewind();
    			GL11.glGetFloat(EXTTextureFilterAnisotropic.GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, MaxA);
    			GL11.glTexParameterf(GL11.GL_TEXTURE_2D, EXTTextureFilterAnisotropic.GL_TEXTURE_MAX_ANISOTROPY_EXT, MaxA.get(0));
    		}

It is missing a vertical line of pixels here and there but it looks 100 times better than before without me having to use blending or making any big change :slight_smile:

Thanks guys!

And as a final post I’ve attached a picture of how it looks now instead (I also fixed the pixly roads making it look alot better imo).