I’ve done a fake gaussian blur effect using opengl. The core of the algorithm simply draws the texture to be blurred multiple times in additive mode with some weight and texture coordinates shift applied to it.
To optimize it I tried to pack passes using multitexturing. The texture equation should be :
C® = w(0) * C(0) + w(1) * C(1) + … + w * C(n)
Where C® is the resulting color, w(n) are the kernel weights and C(n) are the colors from the different texture units.
Currently I render my textures two by two, pairing by weight (the kernel is symetric around its center), did not found a texture_env setup to specify the texture equation above using more texture units, so I’m asking to you
Your basic problem is after texture zero you need to modulate each texture sample by a unique color and then add the results to the previous texture unit. Fundamentally unextended texture operations must operate on the input from the previous operation and only apply a limited set of operations.
The modulate addition is one of the basic features combiner texture operations bring to the party.
With combiners you should be able to apply the combiner operation to any number of texture units provided that you can supply kernel values for in colors (which of course you can).
There are naturally limitations w.r.t. clamping & signed kernel values, none are insurmountable but a more sophisticated approach would be required with these simple extensions.
I found a way to render that effect using all available texture units (big speedup ) with hardware that support texture_env_combine by modifying the weights :
w(0) = w(0) / ((1 - w(1)) * (1 - w(2)) * … * (1 - w(n)))
w(1) = w(1) / ((1 - w(2)) * (1 - w(3)) * … * (1 - w(n)))
…
w(n) = w(n)
with TU0 set as TU0 above and [TU1 ; TUn] set as TU1 above.
It was a pretty simple math question, I just post the solution here in case someone was trying to optimize his opengl-based blur effect like me
[This message has been edited by flupke (edited 07-14-2003).]