so, I am finalizing my rastering algorithm for solving this problem:
| vertex0.x vertex1.x vertex3.x 0 | | weight0 | | point.x |
| vertex0.y vertex1.y vertex3.y 0 | | weight1 | = | point.y |
| vertex0.color vertex1.color vertex3.color -1 | | weight2 | | 0 |
| 1 1 1 0 | | point.color | | 1 |
and on the 4th equation
point.color = vertex0.color * weight0 + vertex1.color * weight1 + vertex2.color * weight2
I come across a doubt: how to handle the RGB_color?
you have a color associated with each vertex of the triangle, and the algorithm does a lot of computations with them
RGB color is defined as a 32bit-size array of bits, with three fields of 8bit each
R is 8bit
G is 8bit
B is 8bit
unused R G B
______.______.______.______
---------- 32bit ----------
hence, formally it's a number with 12bit of information.
The doubt is: do I have to multiply this 12bit number by a weight factor, or do I have to multiply each component by the weight factor?
let's exemplify what I have to do in HDL by a piece of C (sort of proof of concept)
typedef union
{
struct
{
uint8_t na;
uint8_t R;
uint8_t G;
uint8_t B;
} as;
sint32_t raw;
} color_rgb_t;
CaseAcolor_rgb_t color_rgb_in0;
color_rgb_t color_rgb_in1;
color_rgb_t color_rgb_in2;
color_rgb_t color_rgb_out;
color_out.as.R = color_rgb_in0.as.R * weight + ... ;
color_out.as.G = color_rgb_in0.as.G * weight + ... ;
color_out.as.B = color_rgb_in0.as.B * weight + ... ;
or
CaseBcolor_rgb_t color_rgb_in0;
color_rgb_t color_rgb_in1;
color_rgb_t color_rgb_in2;
color_rgb_t color_rgb_out;
color_out.raw = color_rgb_in0.raw * weight + ... ;
or is there a trick, something ... because with
caseA I have to triplicate the numbers of MULs in my algorithm
just to face to the system of equations, the caseA looks this way
| vertex0.x vertex1.x vertex3.x 0 0 0 | | weight0 | | point.x |
| vertex0.y vertex1.y vertex3.y 0 0 0 | | weight1 | = | point.y |
| vertex0.color vertex1.color vertex3.color -1 0 0 | | weight2 | | 0 |
| vertex0.color vertex1.color vertex3.color 0 -1 0 | | point.color.R | | 0 |
| vertex0.color vertex1.color vertex3.color 0 0 -1 | | point.color.G | | 0 |
| 1 1 1 0 0 0 | | point.color.B | | 1 |