PDA

View Full Version : Increasing MIPMAP colour depth



Ross Oliver
02-20-2010, 04:31 AM
Hello,

I'm trying to figure out of I can increase the colour depth for the auto-generated MIPMAPS. I have a black and white image, for which the MIPMAPS are generated, so I can then look at the highest layer (1 pixel) MIPMAP to give a value of how much white/black there is in the image as a shade of grey. The problem I have is that there are only 255 possible shades and I require more precision - to differentiate between images with only a few extra pixels of white in them. My code for this is below:



glBindTexture( GL_TEXTURE_2D, black_white_tex );
glGenerateMipmapEXT( GL_TEXTURE_2D );

GLbyte pixel;

glGetTexImage( GL_TEXTURE_2D, CM_NUM_LAYERS( CM_WIDTH ),
GL_RGBA, GL_UNSIGNED_BYTE, &pixel );

glBindTexture( GL_TEXTURE_2D, 0 );


The grey value is then normalised as 1 - ( pixel / 255.0 ); giving the amount of black in the image. What I want is to be able to normalise to a higher precision, for instance 1 - ( pixel / 1020 ), but to do this I need to increase colour depth from 0-255 to 0-1020 (for example). If anyone can point me in the right direction, or perhaps another way to go about evaluating the amount of white/black in an image I would really appreciate it (I would like to avoid writing a custom shader if possible).

Thanks for your time,

-Ross