Skip to main content
gamedev.net
🔒 Locked

Texture 'Corruption'

Started by Daaark 3 replies 1.6k views
Original Post
Daaark
Daaark
When I load my textures for my GUI in my game, there are not drawing perfectly like they should. They are being rendered almost as if they are being dithered, or in a lower colour depth. In this pic, I pasted the original texture above, and below you can see it as it's being rendered in game. The quads is the same pixel size as the image in Ortho mode. You may have to look very close to the screen to see it. The glow around the letters isn't as smooth. Here is the relevant code that I'm using in my texture loader. The GUI elements are loaded with FILTER_SHARP and bMipMaps = false. But They were doing it before when I was giving everything mipmaps and using filtering.

    
    if (nFilter == FILTER_SMOOTH)
    {
        glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST_MIPMAP_LINEAR);
        glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);   
    }

    else if (nFilter == FILTER_SHARP)
    {
        glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST);
        glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);   
    }

    int nMode = GL_RGBA;
    if (m_Format == TEX_FORMAT_RGB) nMode = GL_RGB;    
    
    if (bMipMaps)
    {
        gluBuild2DMipmaps(GL_TEXTURE_2D,nMode,m_Width,m_Height,
        nMode,GL_UNSIGNED_BYTE,m_ImgData);    
    }
    else
    {
        glTexImage2D(GL_TEXTURE_2D,0,nMode,m_Width,m_Height,
        0,nMode,GL_UNSIGNED_BYTE,m_ImgData);
    }



[Edited by - Vampyre_Dark on October 19, 2005 5:47:27 PM]
Yann L
Yann L
Your filter modes are messed up. You aren't filtering the texels at all, you're only interpolating between mipmaps themselves. This will obviously lead to bad artifacts. On top of that, your MAG_FILTER mode is invalid, you cannot use mipmaps on magnifying filters.

Try these modes instead:
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_LINEAR);       glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);   
Daaark
Daaark
I meant to say my gui elements were loaded with FILTER_SHARP. I knew about the mag filter thing, I just copied it into the post window wrong [sad]. Damn did I really mess that post up.
noisecrime
noisecrime
Although its very hard to see in the picture you uploaded, an image being dithered would suggest you're not getting 8 bits per channel. Perhaps try changing the internalformat to GL_RGBA8, instead of GL_RGBA would help.

It shouldn't as although the symbol GL_RGBA doesn't explicity contain bitdepth (like GL_RGBA8 does) I have always assumed it would be 8 bits per channel. Then again maybe the card is 'trying' to be helpful and using less bits for rgba or something equally weird.

Btw, I assume you've comfirmed that the image bitmap loader you use isn't responsable for the dithering?
Daaark
Daaark
Damn, I just thought of something. I set my GeforceFX Driver Image quality to the lowest. 'High Performace'. I'm going to toggle it and check now. If my tga loader had problems I doubt it would only have small artifacts and not distort the whole texture.

It's based off the one in Beginning OpenGL Game programming with some changes to drop support for compressed images, and it adds my FILTER_ contants and Mipmap toggle.

-edit- That didn't take long I moved it one notch up to 'performance' and suddenly I have smooth textures. [sad] What kind of optimization was that.

BTW, which min filter does Biliniar filtering again, and not triliniar?

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.