Problem with mipmaps in OpenGL/Windows

Problems building or running the engine, queries about how to use features etc.
User avatar
fractile
Gremlin
Posts: 199
Joined: Thu Jan 13, 2005 2:35 pm
Location: Tampere, Finland
x 15

Problem with mipmaps in OpenGL/Windows

Post by fractile »

Most of my textures with mipmaps are invisible on windows using OpenGL renderer. No errors in Ogre log. Same code works fine in Linux and with Direct3D9 renderer. Materials seem to effect z-buffer, but do not render any color. Same thing happens with different types of textures, some use shaders and others are simple fixed function materials like this one:

Code: Select all

material loadscreenbackground
{
    technique
    {
        pass
        {
            lighting off
            depth_check off

            texture_unit
            {
                texture loadscreenbackground.png 1
            }
        }
    }
}
If I set numMipMaps to zero (the "1" in above example), the material becomes visible! I assume there's something wrong with the generated mipmaps. I'm seeing this on Windows 7 laptop with Intel HD4000.

How can I fix this without disabling mipmaps completely?
You do not have the required permissions to view the files attached to this post.
User avatar
fractile
Gremlin
Posts: 199
Joined: Thu Jan 13, 2005 2:35 pm
Location: Tampere, Finland
x 15

Re: Problem with mipmaps in OpenGL/Windows

Post by fractile »

Intel drivers were quite old so I updated them just to be sure, but that didn't change anything. It's worth noting that Other OpenGL games (at least Xonotic) work fine on the same PC. My game works fine on AMD GPU with OpenGL renderer. I also tried it on yet another Windows PC with Intel HD4000 and saw this exact same problem:

Image
Some of the textures do show up even with mipmaps enabled, most don't. All the missing textures become visible if I disable their mipmaps (by setting mipmap count to zero).

So, this seems to be specific to Intel Driver/GPU.
scrawl
OGRE Expert User
OGRE Expert User
Posts: 1119
Joined: Sat Jan 01, 2011 7:57 pm
x 217

Re: Problem with mipmaps in OpenGL/Windows

Post by scrawl »

What kind of textures are you using? Compressed textures, .dds? And what version of Ogre? There was a related bug fixed for v1.9: https://ogre3d.atlassian.net/browse/OGRE-259
User avatar
fractile
Gremlin
Posts: 199
Joined: Thu Jan 13, 2005 2:35 pm
Location: Tampere, Finland
x 15

Re: Problem with mipmaps in OpenGL/Windows

Post by fractile »

Simple uncompressed RGBA textures from png -files. Here are log messages for two (of many) textures that are invisible:
I 2014-12-07 12:45:16.472 Texture: loadscreenbackground.png: Loading 1 faces(PF_R8G8B8A8,1x768x1) with 1 generated mipmaps from Image. Internal format is PF_A8R8G8B8,1x768x1.
I 2014-12-07 12:45:16.976 Texture: technical.png: Loading 1 faces(PF_R8G8B8A8,1024x1024x1) with 10 generated mipmaps from Image. Internal format is PF_A8R8G8B8,1024x1024x1.

I'm using Ogre 1.9 branch. Not quite sure which revision (I can check that later), but I'm pretty sure the fix to that issue is there.
User avatar
Darthigor
Gnoblar
Posts: 22
Joined: Wed Dec 25, 2013 4:06 am
x 1

Re: Problem with mipmaps in OpenGL/Windows

Post by Darthigor »

I have similar problem on Windows Phone/DirectX11. Textures with mipmaps are invisible, but when no mipmaps are generated they are rendered correctly (though grainy). Textures are just plain pngs and jpgs. Is it the same/similar issue? I'm using latest 1.9. Almost the same program (+ same shaders and textures) renders correctly on Windows (OpenGL and DX9) and Android. Odd.
Check out my Ogre based mobile games: Pig Shooter 3D, Bubble Shooter 3D, Space Rush 3D
Github: https://github.com/RMDarth
User avatar
fractile
Gremlin
Posts: 199
Joined: Thu Jan 13, 2005 2:35 pm
Location: Tampere, Finland
x 15

Re: Problem with mipmaps in OpenGL/Windows

Post by fractile »

I does sound very similar. You're facing the problem on a completely different platform and different renderer. However, since I haven't solved my issue or even found out the reason to it, we might as well be dealing with same problem here..
User avatar
fractile
Gremlin
Posts: 199
Joined: Thu Jan 13, 2005 2:35 pm
Location: Tampere, Finland
x 15

Re: Problem with mipmaps in OpenGL/Windows

Post by fractile »

Since my last post I have updated Ogre to latest version from 1.9 branch and updated Intel drivers once more. No change. I'm running out of ideas. Does anyone have an idea on how to debug this further? What else could I try?

This is a big problem for me. My game would run well on Intel integrated GPUs performance-wise, but this issue is ruling out a lot of potential players with non-gaming laptops.
User avatar
c6burns
Beholder
Posts: 1512
Joined: Fri Feb 22, 2013 4:44 am
Location: Deep behind enemy lines
x 139

Re: Problem with mipmaps in OpenGL/Windows

Post by c6burns »

My understanding is that not all hardware fully supports mipmapping npot textures (could be outdated info, but used to be true). Make the textures power of two and see if that's the case?
User avatar
fractile
Gremlin
Posts: 199
Joined: Thu Jan 13, 2005 2:35 pm
Location: Tampere, Finland
x 15

Re: Problem with mipmaps in OpenGL/Windows

Post by fractile »

c6burns wrote:My understanding is that not all hardware fully supports mipmapping npot textures (could be outdated info, but used to be true). Make the textures power of two and see if that's the case?
Thanks for the suggestion, but I don't think this is it. Nearly all my textures are already power-of-two sized and square. For example the missing wall/floor textures are all 512x512 or 1024x1024 RGBA textures.
User avatar
fractile
Gremlin
Posts: 199
Joined: Thu Jan 13, 2005 2:35 pm
Location: Tampere, Finland
x 15

Re: Problem with mipmaps in OpenGL/Windows

Post by fractile »

Just a small update: I tried running the game with GLIntercept. Unfortunately, it did not reveal any meaningful errors, just a few performance warnings and potential memory leaks on shutdown.
User avatar
fractile
Gremlin
Posts: 199
Joined: Thu Jan 13, 2005 2:35 pm
Location: Tampere, Finland
x 15

Re: Problem with mipmaps in OpenGL/Windows

Post by fractile »

Still struggling with this. Tested on a new laptop with newer generation Intel HD4600, Windows 8.1 and new drivers, but textures are missing here too.

I tried comparing two materials, one that shows up and one that does not. Both use identical shaders and material setup:

Code: Select all

I 2015-09-05 13:59:55.940 Texture: technical.png: Loading 1 faces(PF_R8G8B8A8,1024x1024x1) with 10 generated mipmaps from Image. Internal format is PF_A8R8G8B8,1024x1024x1.
I 2015-09-05 13:59:55.943 Texture: crate.png: Loading 1 faces(PF_R8G8B8,256x256x1) with 8 generated mipmaps from Image. Internal format is PF_X8R8G8B8,256x256x1.
Only meaningful difference I can find is that all visible textures have no alpha channel and load as PF_X8R8G8B8 format while non-visible textures use PF_A8R8G8B8 format.

If I force all textures to use PF_X8R8G8B8 format, the invisible materials become visible, but their color is all black. It looks like the generated mipmaps are all empty (0, 0, 0, 0). If the alpha is ignored, it become 1 and the material shows up, but RGB is still zero.
User avatar
fractile
Gremlin
Posts: 199
Joined: Thu Jan 13, 2005 2:35 pm
Location: Tampere, Finland
x 15

Re: Problem with mipmaps in OpenGL/Windows

Post by fractile »

I added a hack to my game that detects Intel GPU on Windows and disables mipmaps. I can live with this workaround for now..