No, I think the closest blending mode available is GL_EXT_blend_subtract. But that simply subtracts and then clamps the output. And there aren’t many consumer cards available that support that extension. And I don’t know of any cards that support abs or sqrt in hardware. Then again, OpenGL really wasn’t designed to do DSP.
[This message has been edited by DFrey (edited 01-08-2001).]
I just came to the realization that you can produce the abs of the difference in just a few passes on a Geforce, or any card that supports both GL_EXT_blend_minmax and GL_EXT_blend_subtract.
First render Iout1 = I1-I2
then render Iout2 = I2-I1,
then blend Iout1 and Iout2 using blending function blend_max
The only problem with this method is how to store the intermediate result Iout1. I really don’t want to use glRead/Write pixel for bandwidth reasons. If multi-texture supports substraction, this seems to be a doable solution.
hi, cass,
Thank you for your help.
I look through the NV_register_combiner spec.
I am not sure how to do the sum for the alpha value in the final combiner stage.
It seemed to me the G register is just a map from combiner register to the output.
Can I map a input register to more than one variables (say spare0 --> A and B) during the combiner stage?
I think I could compute (a-b)^2 this way.
in combiner 0 alpha, calculate tex0 + (1-tex1). Since tex0 & tex1 are in the 0 to 1 range, output is in the 0 to 2 range. Scale output by 1/2, and we now have it back into the 0 to 1 range. Store this in spare 0 alpha.
in combiner 1 alpha:
A = 1
B = spare 0 alpha - 0.5
C = -1
D = spare 0 alpha - 0.5
use the mux function and scale the output by 2. Store the result in spare 0 alpha
in the final combiner, select spare 0 alpha into G
If I figured everything correctly, this should get you the absolute value of tex0-tex1. The one thing to note here is that since we scale by 1/2 before storing to spare 0, you will lose some precision in the calculation (unless the register combiners’ registers have at least 9 bits of preceission, and I cant remember if they do or not).