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 6 of 6

Thread: Problem with glCompressedTexImage3D....

  1. #1
    Junior Member Newbie
    Join Date
    Mar 2009
    Posts
    27

    Problem with glCompressedTexImage3D....

    hello everyone,

    im having a problem with a compressed 3D texture in the format DXT5... the data uploaded to the graphics card seems to be ok but the final result is a bit "mad", let em show you a render of whats happening...

    [img]http://img690.imageshack.us/i/3dproblem.png/[/img]

    now lets look at the code...im doing this for loading...

    Code :
     
    glGenTextures(1, &TextureID);
    glEnable( GL_TEXTURE_3D );
    glBindTexture( GL_TEXTURE_3D , TextureID);
     
    glTexParameteri( GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER,GL_LINEAR );
     
    glTexParameteri( GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER,GL_LINEAR );
     
    glTexParameterf( GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, GL_CLAMP);
     
    glTexParameterf( GL_TEXTURE_3D, GL_TEXTURE_WRAP_T, GL_CLAMP);
     
    glTexParameterf( GL_TEXTURE_3D, GL_TEXTURE_WRAP_R, GL_CLAMP);
     
    glCompressedTexImage3DARB(GL_TEXTURE_3D, 0, format,  width, 
                height, depth, 0, size, data);

    the image is 256*256*256 , it doesnt have any mipmaps, just the textures, decompressing the image using a software it all seems good...but here is terrible...

    any way the debug values are all good, but i canīt see whats wrong... am i missing something here? for sure.. but i donīt know what... help me... :\

    one of the problems is that the texcoords are in 0-1 so i should see only a slice at the time, and im seeing 4*4 of each slice, and thatīs not good at all....

  2. #2
    Senior Member OpenGL Guru
    Join Date
    May 2009
    Posts
    4,726

    Re: Problem with glCompressedTexImage3D....

    im having a problem with a compressed 3D texture in the format DXT5
    I'm not sure such a thing (DXT5 on 3D textures) exists. Or that it is allowed by OpenGL.

    The standard S3TC extension does not allow for compression on 3D textures. Only the NV_texture_compression_vtc does, which is an NVIDIA-only extension.

  3. #3
    Junior Member Newbie
    Join Date
    Mar 2009
    Posts
    27

    Re: Problem with glCompressedTexImage3D....

    hello,

    thanks for the answer... so taken from the spec... im pretty sure it works and is avaliable....and i have that extension as well, so quoting from the spec...


    GL_NV_texture_compression_vtc

    Overview

    This extension adds support for the VTC 3D texture compression
    formats, which are analogous to the S3TC texture compression formats,
    with the addition of some retiling in the Z direction. VTC has the
    same compression ratio as S3TC and uses 4x4x1, 4x4x2, or 4x4x4
    blocks.
    a bit more....
    New Tokens

    Accepted by the <internalformat> parameter of TexImage3D and
    CompressedTexImage3DARB and the <format> parameter of
    CompressedTexSubImage2DARB:

    COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0
    COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1
    COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2
    COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3
    and the blocks


    VTC Compressed Texture Image Formats

    Each VTC compression format is similar to a corresponding S3TC
    compression format, but where an S3TC block encodes a 4x4 block of
    texels, a VTC block encodes a 4x4x1, 4x4x2, or 4x4x4 block of texels.
    If the depth of the image is four or greater, 4x4x4 blocks are used,
    and if the depth is 1 or 2, 4x4x1 or 4x4x2 blocks are used.

    like they say its pretty equal to the standard S3TC compression, so it should be pretty straight forward, to use it...but some how, it gets a bit messes up...
    the 2d cases work fine....so the 3D was just suposed to be a simple step...and it seems that it isnīt... :\

  4. #4
    Intern Contributor
    Join Date
    Nov 2009
    Location
    Ukraine
    Posts
    79

    Re: Problem with glCompressedTexImage3D....

    Unfortunately NV_texture_compression_vtc is can be turned off,
    so you must shuffle blocks of image.

  5. #5
    Junior Member Newbie
    Join Date
    Mar 2009
    Posts
    27

    Re: Problem with glCompressedTexImage3D....

    hello YarUnderoaker,

    thanks for your answer, i think i know what you mean... iīll see if i can make it work.

    Best Regards

  6. #6
    Intern Contributor
    Join Date
    Nov 2009
    Location
    Ukraine
    Posts
    79

    Re: Problem with glCompressedTexImage3D....

    My algo to do this

    Code :
      function blockOffset(x, y, z: Integer): Integer;
      begin
        if z >= (d and -4) then
          Result := fElementSize * (cw * ch * (d and -4) + x + cw * (y + ch * (z - 4 * ch)))
        else
          Result := fElementSize * (4 * (x + cw * (y + ch * floor(z / 4))) + (z and 3));
        if Result < 0 then
          Result := 0;
      end;
    -----------------------------------------------------------------------
              if NV_texture_compression_vtc then
              begin
                // Shufle blocks for Volume Texture Compression
                if Assigned(p) then
                begin
                  cw := (w + 3) div 4;
                  ch := (h + 3) div 4;
                  if Level = 0 then
                    GetMem(vtcBuffer, GetLevelSizeInByte(0));
                  top := p;
                  for k := 0 to d - 1 do
                    for i := 0 to ch - 1 do
                      for j := 0 to cw - 1 do
                      begin
                        bottom := vtcBuffer;
                        Inc(bottom, blockOffset(j, i, k));
                        Move(top^, bottom^, fElementSize);
                        Inc(top, fElementSize);
                      end;
                end;
                if EXT_direct_state_access then
                  CompressedTextureImage3D(glHandle, glTarget, Level, aTexFormat, w, h, d, 0, GetLevelSizeInByte(Level), vtcBuffer)
                else
                  CompressedTexImage3D(glTarget, Level, aTexFormat, w, h, d, 0, GetLevelSizeInByte(Level), vtcBuffer);

    Where
    w, h, d - sizes of image
    p - image address
    fElementSize - 2D block size in byte

Posting Permissions

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