Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 8 of 8

Thread: DDS + mipmapping doesn't work

  1. #1
    Senior Member OpenGL Pro Ilian Dinev's Avatar
    Join Date
    Jan 2008
    Location
    Watford, UK
    Posts
    1,261

    DDS + mipmapping doesn't work

    Geforce 8600GT, driver 181.22 (6.14.11.8122), winxp sp2

    Texture is black, while mipmap sizes and data for each level (down to the 4x4 mip) are correct. Distance from textured object doesn't matter, all mip-levels appear black.
    If I specify GL_LINEAR instead of GL_LINEAR_MIPMAP_LINEAR, level0 is visible.
    I had this issue with previous drivers, so maybe the problem is with my code.
    glGetError reports no problems.

    Code :
    glEnable(GL_TEXTURE_2D);
    ...
    glGenTextures( 1, &me->glTexHandle);
    glBindTexture(GL_TEXTURE_2D,me->glTexHandle);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); 
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
     
     
    for(each mipmap){
    	glCompressedTexImage2D(GL_TEXTURE_2D,LOD,f->iformat,wid,hei,0,nSize,data); // LOD=0,1,2...
    }

    Everything works as expected when I change just the mipmap-uploading code with this:
    glTexParameterf( GL_TEXTURE_2D, GL_GENERATE_MIPMAP,GL_TRUE);
    glTexImage2D( GL_TEXTURE_2D, LOD, f->iformat, wid, hei, 0, f->format, f->storage,data); // LOD=0
    // uploading GL_BGRA uncompressed texture this time, not DXT

    i.e my texture-states, shaders etc are setup correctly.

    Any tutorial online on mipmapping with DDS? Or I can create a short simple test-app to demonstrate the bug.

  2. #2
    Junior Member Regular Contributor LangFox's Avatar
    Join Date
    Oct 2001
    Location
    Shen Zhen, Guangdong, China
    Posts
    103

    Re: DDS + mipmapping doesn't work

    Try this:
    Code :
    //glTexParameterf( GL_TEXTURE_2D, GL_GENERATE_MIPMAP,GL_TRUE);
    glTexImage2D( GL_TEXTURE_2D, LOD, f->iformat, wid, hei, 0, f->format, f->storage,data); // LOD=0
    // uploading GL_BGRA uncompressed texture this time, not DXT 
    glGenerateMipmapEXT(GL_TEXTURE_2D);
    Best Regards,
    LangFox


    http://hi.baidu.com/lang_fox

  3. #3
    Senior Member OpenGL Pro Ilian Dinev's Avatar
    Join Date
    Jan 2008
    Location
    Watford, UK
    Posts
    1,261

    Re: DDS + mipmapping doesn't work

    You couldn't understand me. The uncompressed automatic mipmapping works perfectly.
    Uploading S3TC mip-levels works, but if I set GL_LINEAR_MIPMAP_LINEAR the texture becomes black.

    I simply want to use the basic common functionality: upload tiny S3TC-compressed DDS mips to gpu, use automatic trilinear filtering.

  4. #4
    Senior Member OpenGL Guru
    Join Date
    Dec 2000
    Location
    Reutlingen, Germany
    Posts
    2,052

    Re: DDS + mipmapping doesn't work

    Are you uploading ALL mipmap levels? Sometimes a DDS only contains part of the mipmap chain. As long as you don't tell gl, that you only have n-k mipmaps, it will assume that the texture is not complete.

    glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, iMaxMipmapUsed);

    Jan.
    GLIM - Immediate Mode Emulation for GL3

  5. #5
    Advanced Member Frequent Contributor _NK47's Avatar
    Join Date
    Mar 2008
    Posts
    574

    Re: DDS + mipmapping doesn't work

    would it work if say upload uncompressed data to compressed format, read back the compressed data for all mipmap levels, store it and upload all levels again in compressed format? AFAIK something similar to what Jan said that not all levels are provided in DDS.

  6. #6
    Senior Member OpenGL Pro Ilian Dinev's Avatar
    Join Date
    Jan 2008
    Location
    Watford, UK
    Posts
    1,261

    Re: DDS + mipmapping doesn't work

    Jan, that TEXTURE_MAX_LEVEL was the thing I was missing! Thanks
    The mipmap chain did have all levels uploaded: 0=512x512, 1=256,128,64,32,8,6=4x4 (uploaded in that order)

    _NK47, that wouldn't have worked well in a modern game, would it :P

  7. #7
    Advanced Member Frequent Contributor _NK47's Avatar
    Join Date
    Mar 2008
    Posts
    574

    Re: DDS + mipmapping doesn't work

    well, sure not just for testing purpose.

  8. #8
    Senior Member OpenGL Pro dletozeun's Avatar
    Join Date
    Jan 2006
    Location
    FRANCE
    Posts
    1,370

    Re: DDS + mipmapping doesn't work

    Code :
    glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, iMaxMipmapUsed);

    I did not know the existance of that. Thanks Jan Once I had problems loading each mipmap level on intel hardware. Like Ilian I had a black texture as long as I did not set explicitly all mipmap levels until 1x1 dimension. The funny thing is that nvidia hardware managed to make it work, but that is not a good thing IMO.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •