texture compression

On nvidia 8800 gt card, I have a question about texture compression.

I do something like:

gluBuild2DMipmaps(
(mTextureRect) ? GL_TEXTURE_RECTANGLE_ARB : GL_TEXTURE_2D,
(mTextureRect) ? GL_RGBA : GL_COMPRESSED_RGBA ,
width, height,
GL_RGBA,
GL_UNSIGNED_BYTE,
data
);

And this works on the ati 9800 and nvidia 7300 gt. Yet, on the 8800 I get all these lines in my textures. It only happens on textures with transparency. Anyhow, I take out the texture compression and it looks normal. That is, if I use just plain old GL_RGBA .

In the red book, p.392, the book indicates that I just add a GL_COMPRESSED_* before the internal format and gluBuild2DMipmaps would just take care of it. Yet, it looks like its uncompressing and somehow the alpha is not set right and I get stripes. I guess thats called “lossy”. :wink:

Other things I’ve read indicate people compress on disk and then load it in. But since I’m not sure what the video card supports in regards to compression, I just let the glu stuff handle it. (?)

I suppose I should not use texture compression for transparent textures ( using the alpha )?


I got a nifty new nvidia 8800 gt. Anyhow, I ran the

/System/Library/CoreServices/Expansion Slot Utility.app

I put the new card into slot 1. With slot 4 set to 8x speed. No other cards. Hardware appears to work fine. Runs the glsl fragments shaders really fast. :slight_smile:

I suggest:

  1. don’t use gluBuild2DMipmaps, as it runs on the CPU. Use TexParameter(… GENERATE_MIPMAP) (on all hardware), or GenerateMipmapEXT(…) (on hardware that supports FBO) which can be accelerated by the GPU.
  2. don’t try to build mipmaps for RECTANGLE textures. That’s meaningless.
  3. use a specific compressed internal format, like DXT1, 3, or 5.
  4. if you see a problem with generic compressed formats, file a bug. It’s probably broken.
  5. in general people prefer to compress textures offline, as it allows more control (== higher quality) than trusting OpenGL to do it for you. It is also faster to upload.

I looked at the Apple extensions chart. And the sgis mip map stuff is supported virtual everywhere. I like to avoid extensions but it appears safe enough. I figure glu code can be different too. So, call glTexParameteri and then call glTexImage2D :

bool sgis_mip = strstr((char*)glGetString(GL_EXTENSIONS), “SGIS_generate_mipmap”);
if( sgis_mip ) {
glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS, GL_TRUE);
}

I’d just like to compress internally only and feed it uncompressed data. I assume a check like this is appropriate:

bool test1 = strstr((char*)glGetString(GL_EXTENSIONS), "GL_ARB_texture_compression");
bool test2 = strstr((char*)glGetString(GL_EXTENSIONS), "GL_EXT_texture_compression_dxt1");
bool test3 = strstr((char*)glGetString(GL_EXTENSIONS), "GL_EXT_texture_compression_s3tc");	
bool compression_check = test1 && test2 && test3;

Then for internal format for glTexImage2D pass GL_COMPRESSED_RGBA_S3TC_DXT5_EXT. Though, I notice there appears not be a check for DXT5. I can only check for DXT1.(?) If I pass plain old GL_COMPRESSED_RGBA then I get chunky looking transparent textures. If I pass in GL_COMPRESSED_RGBA_S3TC_DXT5_EXT then things look ok. I’m assuming the data I pass into glTexImage2D is uncompressed.

  1. if you have if (sgis_mip) {}, then you should probably have else { gluBuildMipmaps }.

  2. Feeding uncompressed data is fine, OpenGL will do all the mipmap generation and format conversion, including compression, for you. But, as a future-proof note, OpenGL ES will not do format conversion or runtime compression. So keep that in mind if you plan to develop on the iPhone.

  3. For extensions, you only need to look for ARB_texture_compression and EXT_texture_compression_s3tc. s3tc defines the DXT1, DXT3, and DXT5 formats, so you can use all of them if that extension is present. The EXT_texture_compression_dxt1 extension is a strict subset of the sct3 extension-- it is exported only for compatibility with some portable devices which only support dxt1.

  4. If you are seeing garbage with the generic COMPRESSED_RGBA, that is a bug in the driver.

My guess is that it actually is a driver bug as I have seen this on several other platforms when it ocmes to nvidia latest drivers…

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.