The idea is to use the a register combiner ‘constant’ that holds (1, 1, 0).
I’m going to use to fact that you feed glColor with (col.r, col.g, col.r) and glSecondaryColor with (col.r, col.g, col.g).
Note that you can commutate them and it will give the same results (I mean, feed glColor with (col.r, col.g, col.g) and so on with glSecondaryColor).
So here it is. I’m assuming it is working with RGB portions only. Just discard all outputs for Alpha portions.
In the register initial state, set :
constant0 = (1, 1, 0)
texture0 = tex0
texture1 = tex1
texture2 = rgb
Also glColor and glSecondaryColor (that automatically interpolates colors) feed those registers :
primary = (col.r, col.g, col.r)
secondary = (col.r, col.g, col.g)
Require 3 general combiner stages.
In the general combiner stage 0, do the following :
- load primary into variable A
- load constant0 into variable B
- load zero into variable C with the input map UNSIGNED_INVERT
- load constant0 into variable D with the input map UNSIGNED_INVERT
So that the variables contain :
A = primary = (col.r, col.g, col.r)
B = constant0 = (1, 1, 0)
C = 1-zero = (1, 1, 1)
D = 1-constant0 = (0, 0, 1)
And then, output AB+CD into spare 0, and discard the other two outputs.
Detailed formulas :
spare0 = AB+CD
spare0 = (col.r, col.g, col.r)(1, 1, 0) + (1, 1, 1)(0, 0, 1)
spare0 = (col.r, col.g, 0) + (0, 0, 1)
spare0 = (col.r, col.g, 1)
In the general combiner stage 1, do the following :
- load texture1 into variable A
- load spare0 into variable B
- load primary into variable C
- load secondary into variable D
So that the variables contain :
A = texture1 = (tex1.r, tex1.g, tex1.b)
B = spare0 = (col.r, col.g, 1)
C = primary = (col.r, col.g, col.r)
D = secondary = (col.r, col.g, col.g)
Output A.B into spare 0, output CD into spare 1, and discard the other output.
Detailed formulas :
spare0 = A.B
spare0 = (tex1.r, tex1.g, tex1.b).(col.r, col.g, 1)
spare0 = (tex1.rcol.r) + (tex1.gcol.g) + (tex1.b1)
spare0 = (tex1.rcol.r) + (tex1.g*col.g) + tex1.b
spare1 = CD
spare1 = (col.r, col.g, col.r)(col.r, col.g, col.g)
spare1 = (col.rcol.r, col.gcol.g, col.rcol.g)
In the general combiner stage 2, do the following :
- load texture0 into variable A
- load spare1 into variable B
- load texture2 into variable C
- load spare0 into variable D
So that the variables contain :
A = texture0 = (tex0.r, tex0.g, tex0.b)
B = spare1 = (col.rcol.r, col.gcol.g, col.rcol.g)
C = texture2 = rgb
D = spare0 = (tex1.rcol.r) + (tex1.g*col.g) + tex1.b
Output A.B into spare 0, output CD into spare 1, and discard the other output.
Detailed formulas :
spare0 = A.B
spare0 = (tex0.r, tex0.g, tex0.b).(col.rcol.r, col.gcol.g, col.rcol.g)
spare0 = (tex0.rcol.rcol.r) + (tex0.gcol.gcol.g) + (tex0.bcol.r*col.g)
spare1 = CD
spare1 = rgb * ((tex1.rcol.r) + (tex1.gcol.g) + tex1.b)
In the Final combiner stage, do the following :
- load texture2 into variable A
- load spare0 into variable B
- load zero into variable C
- load spare1 into variable D
So that the variables contain :
A = texture2 = rgb
B = spare0 = (tex0.rcol.rcol.r) + (tex0.gcol.gcol.g) + (tex0.bcol.rcol.g)
C = texture2 = (0, 0, 0)
D = spare0 = rgb * ((tex1.rcol.r) + (tex1.gcol.g) + tex1.b)
And so that the output is :
RGBout = AB+(1-A)C+D
RGBout = rgb*((tex0.rcol.rcol.r) + (tex0.gcol.gcol.g) + (tex0.bcol.rcol.g)) + (1-A)(0,0,0) + rgb * ((tex1.rcol.r) + (tex1.gcol.g) + tex1.b)
RGBout = rgb((tex0.rcol.rcol.r) + (tex0.gcol.gcol.g) + (tex0.bcol.rcol.g) + (tex1.rcol.r) + (tex1.gcol.g) + tex1.b)
That’s it, hopefully.
I think it’s possible to use only 2 general combiner stages thanks to Alpha registers, but I’m not going to try it today
Hope this helps !