The technique I'm using is the following (more info in this post (http://www.m3xbox.com/GPU_blog/?p=20) from my blog):
dump the texture data into a fp array using glGetTexImage look for min and max values in the array normalize the texture values using a fragment shader based on the formula norm_value = (value - min) / (max - min);
Does it exist a better way to do this (maybe without dumping the texture data, so using just shaders)???

Humus

12-22-2007, 07:51 AM

Well you can do it on the GPU. I'd suggest you "downsample" your texture in a "mipmap" fashion, so for the top level you find the max and min in each 2x2 texel block and a texture of half the dimensions. The repeat until you're down to 1x1, which then contains the min and max of the entire texture. Then you can sample this texture in your shader and normalize the texture on the GPU.

m3xican

12-24-2007, 05:41 AM

That looks a very good idea!

Do you have any example code/reference about MipMap textures, GLSL shaders and FBO?

I have some doubts about using MipMap textures and FBO with a fragment shader...