Simple Multitexturing Question

Okay, I store 2 textures, 512*512 containing pixel values ranging from -1.0 to 1.0. I am using GL_ADD.
The results are not as expected. Multitexturing code is fine.

I was under the impression that the pixel values were not capped to [0,1] until they were interpolated.

Could you be a little more specific?

for example: how are they not as expected?

Okay,
I am rendering the representation of two cosine functions, in each texture. Simplest version, 2nd tecture contains Cos + phase angle => Pi.
Basically generating strips of black and white with transitions. If I combine(add these two textures), I do not get all black. As I should.

Now I know the values get clamped to 0,1, which means this might not work, but I assume values were clamped after texture operations, so my textures could contain negative values, and adding them would produce the right result.

Colors values are indeed clamped to [0,1] when stored to textures.
ex, typical RGBA texture : each component is an unsigned byte going through 0 to 255, for intensities in the |0.0, 1.0] range.

The common trick is shifting values from [-1,1] to [0,1] before creating texture.
Then to add 2 textures :
res = tex1 /2 + tex2 /2
and res will be in the [0,1] range, for your case always 0.5, as expected.

EDIT : with textures in floating point, you are only clamped to classic fp representations. If your card is listed here it support the GL_ATI_texture_float extension .

But, I used GL_ADD_SIGNED_EXT(spelling), and shifted by bias

(X1+1.0)/2.0
(X2+1.0)/2.0

If I assigned, simple example, cos(t) for x1, and cos(t+Pi) to x2, do the above, combine using add signed, it will not work. In fact, the math does not work, unless the negative values are retained. I need to work with wave interference and construction.

Thanks for the help.

Math should work, providing you shift/scale properly (but I am not very good with multitexturing) :

done on CPU :
original range [-1,1]-> scaled/shifted to texture allowed range [O,1]-> scaled to avoid sum overflow [0,0.5] ->
done on GPU :
sum 2 tex [0,1] ->
done on CPU : read result and scale back to [-1,1]