glu's generate mip map not good enough...

I’m looking for links to information, sample implementations or what have you for something like the mip map generator in glu. I have the following situation that I’m trying to solve:

I have a two 24 bit diffuse textures, sized in a power of two in both the x & y dimensions. I have an alpha map, also sized in a power of two, but is not necessarially the same size as the two diffuse maps.

I need to generate mip maps for the first 24 bit diffuse map, but as the mip maps reduce in resolution I want the mip maps to grow progressively darker, with some mip map level that I specify to be completely black.

Then I need to generate mip maps for the 2nd diffuse texture, but I want to make the (possibly different sized) alpha map the alpha channel for this texture- converting the 24 bit map to a 32 bit map. Then I want to do the same thing with the mip maps as the 1st diffuse texture, ramp the lower level mips to black at some specified level.

Now I thought, at first, that I could use the OpenGL hardware to do all this mip map generation and alpha channel addition- but the maps could be larger than the resolution of the screen. So that won’t work. So now I’m looking around for sample implementations of logic, or whatever aid that would allow me to perform this as a software process upon texture load. (I’ll finally place the logic into a preprocess, off line step- so it won’t affect the final run time.)

Okay, I know that what I’m asking about is elementary level math. I could just do it myself. But I’m sure that someone here knows of a simple software image compositor in library or source form that I would be able to use. It would save me the time to implement and debug, plus if someone has taken the time to do this well, it will be faster and probably use SMID and 3DNOW, which is better than what I would write.

Thanks for ANY suggestion.
-Blake

I’m guessing I’d do it procedurally. I’d probably have a function like this:

//Pseudocode.
void Generate24BitTexture(GLsizei x, GLsizei y, GLsizei current_level, GLsizei max_level)
{
// darken just does a right shift on each element by the correct percentage.
// e.g. if current_level is 2 and max_level is 5, right shift
// by 40% of the difference between maximum brightness and black.
for_each(24BitTexture.begin(), 24BitTexture.end(), darken(i));
glTexImage2D(parameters_for_current_level);
x >>= 2; y >>= 2;
if (!(x && y)) return;
Resample24BitTexture(x, y); // get lower resolution.
Generate24BitTexture(x, y, ++current_level, max_level);
}

// and something similar for your alpha
// texture.

I hope this is going down the right track.

You could maybe also, for each mipmap or level of detail, use the imaging subset’s glBlendColor(r, g, b, a). It’s probably too slow for your implementation though.

[This message has been edited by ffish (edited 05-10-2001).]

[This message has been edited by ffish (edited 05-10-2001).]

The FreeImage library, has some image composition stuff, but I’m not sure if it does rescaling. I thought it was at: http://home.wxs.nl/~flvdberg

But that link doesn’t seem to work. Maybe someone else knows if ti has moved or something? Anyway, OpenIL also does some of that stuff, so that would probably also work.

Originally posted by harsman:
But that link doesn’t seem to work. Maybe someone else knows if ti has moved or something?

http://www.6ixsoft.com

[This message has been edited by richardve (edited 05-11-2001).]

For NVIDIA hardware, I would use pbuffers and the SGIS_generate_mipmap extension. This would give you hardware acceleration of the mipmap generation and pbuffers would free you from window size restrictions.

Cass

Originally posted by bsenftner:
But I’m sure that someone here knows of a simple software image compositor in library or source form that I would be able to use.

I suggest you have a look at PBM Plus. You’ll find code for reading and writing different gfx formats as well as performing common image-operations.
http://www.acme.com/software/pbmplus/