Results 1 to 6 of 6

Thread: How to get DXT1, DXT3 by glGetCompressedTexImage?

  1. #1
    Member Contributor
    Join Date
    Nov 2009
    Location
    Ukraine
    Posts
    80

    How to get DXT1, DXT3 by glGetCompressedTexImage?

    Hi.
    I'm develope some texture tool like DirectX Texture Tool,
    but for openGL. I can change texture internal format to any other 90 formats, except GL_COMPRESSED_RGBA_S3TC_DXT5 to DXT1 or DTX2.
    Here's my algorithm:
    get uncompressed RGBA data by glGetTexImage
    glHint( GL_TEXTURE_COMPRESSION_HINT, GL_NICEST )
    set glTexImage with GL_COMPRESSED_RGBA
    get glGetCompressedTexImage, but always get DXT5.

    How to get DXT1, DXT2 by glGetCompressedTexImage?
    I don't want to do it manually, becouse same thin with SRGBA
    and have to write addition conversion code

  2. #2
    Super Moderator Frequent Contributor imported_Groovounet's Avatar
    Join Date
    Jul 2004
    Posts
    937

    Re: How to get DXT1, DXT3 by glGetCompressedTexImage?

    Whouuu!

    First, DXT2 doesn't exist with OpenGL.
    Second, if you plan to generate compressed texture using glGetCompressedTexImage ... well you are just using the OpenGL drivers to generate compressed texture. Drivers are are not meant to generate compressed texture but to run real time graphics.

    This imply that the OpenGL drivers DXTC compression is fast but low quality. in real case, the during the last year the nVidia compression became quiet good quality but still not that great.

    I tried ATI The Compressonator, nVidia Texture tool, DirectX Texture Tool, PowerVR Texture Tools study the results and it appears that ATI The Compressonator give the best quality DXTC compression. The nVidia tool is fastest in low quality but less quality and similar speed in high quality. The DXTC compression is low quality and slow and the PowerVR Texture Tool is ok quality but reridiculously slow.

    Well, to sum up: use ATI The Compressonator for DXTC compression, it's super great! Production pipeline integration is awesome as there is a GUI but is can also be used in command line.

    Yes, ATI have nice tools too!
    [URL="http://www.g-truc.net"]G-Truc Creation[/URL] - [URL="http://glm.g-truc.net"]GLM[/URL] - [URL="http://samples.g-truc.net/"]OpenGL Samples Pack[/URL] - [URL="http://www.openglinsights.com"]OpenGL Insights[/URL]

  3. #3
    Super Moderator Frequent Contributor imported_Groovounet's Avatar
    Join Date
    Jul 2004
    Posts
    937

    Re: How to get DXT1, DXT3 by glGetCompressedTexImage?

    When compressing a texture that way:
    glTexImages(GL_COMPRESS_RGB, ..., GL_RGB, ...)

    You have not control on the compression format, so you can expect choosing the format.

    And by the way, glTexImages(GL_COMPRESS_RGB, ..., GL_RGB, ...) is really not a good think to do for the quality reasons I was saying but also because it going to make texture load slower. Build offline the compression texture using ATI The Compressonator and you are going to be sooooooo happy!
    [URL="http://www.g-truc.net"]G-Truc Creation[/URL] - [URL="http://glm.g-truc.net"]GLM[/URL] - [URL="http://samples.g-truc.net/"]OpenGL Samples Pack[/URL] - [URL="http://www.openglinsights.com"]OpenGL Insights[/URL]

  4. #4
    Member Contributor
    Join Date
    Nov 2009
    Location
    Ukraine
    Posts
    80

    Re: How to get DXT1, DXT3 by glGetCompressedTexImage?

    Thank Groovounet.
    I think I agree with you. Since DXT1, DXT3 format is not native to openGL, then there is no need to save it. I wanted to do as much as possible is universal, but it turned out as always
    ATI The Compressonator is good, but I want to do it in my program.

  5. #5
    Senior Member OpenGL Guru
    Join Date
    Oct 2004
    Posts
    4,650

    Re: How to get DXT1, DXT3 by glGetCompressedTexImage?

    Quote Originally Posted by YarUnderoaker
    Since DXT1, DXT3 format is not native to openGL...
    I think you mis-spoke. DXT1 and DXT3 are native to OpenGL (as is DXT5). Well native in that everyone supports them. They have to or they'd be laughed out of town. They'd likely be core were it not for a silly patent issue.

    And re DXT2: IIRC DXT2 == DXT3 and DXT4 == DXT5. Same formats!

    The distinction was an implicit interpretation on whether the texture contained pre-multiplied alpha texels or non-premultiplied alpha (kinda like a shader TexEnv, but stored in the format type -- odd), where DXT2/DXT4 supposedly represented pre-multiplied alpha texels, and DXT3/5 non-premultiplied-alpha.

    In practice, nobody used it, and Microsoft figured out it was a dumb idea and got rid of it in DX10, where DXT2/DXT3 became BC2, and DXT4/DXT5 became BC3.

    Note that DXT1 (became BC1) implicitly requires pre-multiplied alpha texel data.

    So it's not like you're missing anything with OpenGL.

    ATI The Compressonator is good, but I want to do it in my program.
    Also check out Simon Brown's free and open-source squish. Also, see Jan Paul van Waveren's Real-time DXT Compression and Real-Time YCoCg-DXT Compression Whitepaper, if you really do want to code it up yourself -- lots of provided sample code.

  6. #6
    Member Contributor
    Join Date
    Nov 2009
    Location
    Ukraine
    Posts
    80

    Re: How to get DXT1, DXT3 by glGetCompressedTexImage?

    Quote Originally Posted by Dark Photon
    Also check out Simon Brown's free and open-source. Also, see Jan Paul van Waveren's Real-time DXT Compression, if you really do want to code it up yourself -- lots of provided sample code.
    The NVidia OpenGL SDK 10 and CUDA SDK has real-time DXT compression, so implement it for me have not problem (even on Delhi ). But it will be only an additional feature.
    I saw that after seting texture with DXT3 data like DXT5 internal format some artifacs and decide to study the structure of formats more details(thanks for link), to make an additional image processing for fix it. Guess, same can be done to for DXT1.
    If I'm right, it will be cheap but good.

Similar Threads

  1. glCompressedTexSubImage2D and DXT1
    By mirv the Silly Fish in forum OpenGL: Advanced Coding
    Replies: 2
    Last Post: 09-15-2008, 01:39 PM
  2. NPOT DXT1 textures with borders?
    By andras in forum OpenGL: Advanced Coding
    Replies: 2
    Last Post: 03-12-2006, 11:28 AM
  3. dxt3 or dxt5?
    By zed in forum OpenGL: Advanced Coding
    Replies: 5
    Last Post: 05-08-2005, 11:01 AM
  4. Algorithem for DXT3 or DXT5 texture compression.
    By duckman in forum OpenGL: General
    Replies: 0
    Last Post: 01-08-2005, 07:43 AM
  5. dxt3 / s3tc compression usage
    By JernejL in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 12-18-2003, 04:39 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean