PDA

View Full Version : mipmapping 3-D textures



zroobavela
03-08-2002, 05:33 AM
Hello,

I'm having trouble mipmapping a 3-D texture.
I am under Windows 2000 so I have OpenGL version 1.1 and the various extensions. Have a GeForce 3.

I can create the images at the various mipmap levels, but as soon as I want the program to recognize more than 1 mipmap level, texture mapping is disabled altogether.

Has anybody else managed to successfully mipmap a 3D texture under Windows? Any ideas?

Thanks

zroobi

Rob The Bloke
03-08-2002, 06:22 AM
You do realise that mipmapping a 3d texture is going to pretty much kill your texture memory? It may be that the card can't handle doing it, or it produces an error when you try.

zeckensack
03-08-2002, 06:29 AM
You do realise that mipmapping a 3d texture is going to pretty much kill your texture memory?
Not true. 2D mipmap sets are always smaller than double the size of the level 0 texture. For 3D mipmaps, this ratio is even friendlier. However, read the texture_3d extension spec again. It lists all possible reasons for failing.

LordKronos
03-08-2002, 07:42 AM
More specifically, each mipmap level consumes 1/8 the memory of the previous mipmap level.

Thus if you are using a 256^3 32-bit 3d texture, your top level consumes 64MB, second level only 8M, third level only 1MB. Beyond the first level, all additional mipmap levels only consume an additional 9.14 MB. Pretty insignificant compared to 64MB.

If you start with a 128^3 32bit 3D texture (probably a more likely scenario), first level is 8MB, second is 1MB, and third is 1/8MB. Beyond the first 8MB level, all additional mipmap levels in the chain total only 1.14MB.

Care to withdraw your statement?

zroobavela
03-08-2002, 07:52 AM
here is my initialization code. Assume the actual image data is fine:
GLuint texName;
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glGenTextures(1, &texName);
glBindTexture(GL_TEXTURE_3D_EXT, texName);
glTexParameteri(GL_TEXTURE_3D_EXT, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_3D_EXT, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_3D_EXT, GL_TEXTURE_WRAP_R, GL_REPEAT);

// glTexParameteri(GL_TEXTURE_3D_EXT
//,GL_TEXTURE_MAX_LEVEL,1);
// glTexParameteri( GL_TEXTURE_3D_EXT,
//GL_TEXTURE_BASE_LEVEL,0);

glTexParameterf( GL_TEXTURE_3D_EXT, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexImage3DEXT(GL_TEXTURE_3D_EXT, 0, GL_RGB, 2,2,4, 0, GL_RGB, GL_UNSIGNED_BYTE, image2);
glTexImage3DEXT(GL_TEXTURE_3D_EXT, 1, GL_RGB, 1, 1, 4, 0, GL_RGB, GL_UNSIGNED_BYTE, image1);
glEnable(GL_TEXTURE_3D_EXT);

Where image2 and image1 are defined as:
GLubyte image2[4][2][2][3];
GLubyte image1[4][1][1][3];

(that is , image*[depth][height][width][numChannels])

thx

mcraighead
03-08-2002, 07:58 AM
Looks like an inconsistent mipmap chain. 2x2x4 must be followed by 1x1x2 and 1x1x1.

- Matt

cass
03-08-2002, 08:07 AM
If you're going to do simple box filtering, you might use SGIS_generate_mipmap. That way you'll know you're getting a consistent mipmap pyramid.

Cass

zroobavela
03-08-2002, 08:42 AM
yeah,

I wasn't thinking about mipmapping in the 'depth' direction.

working now.

thanks

Diapolo
03-08-2002, 04:26 PM
And if you really get a memory problem, have a look at NV_texture_compression_vtc (only NV cards though).
That should save a lot of Video RAM (but lower the quality a bit).

Diapolo