Here's the problem:
You have a triangle with points A, B and C (known). Each point has a shading value s: As, Bs, and Cs that are also known.
You want to shade the triangle with a single linear gradient so that each point has the right shading value.
So what is the starting and ending point of the gradient?
If As = Bs = Cs, the triangle is all the same color, so any points will do.
If Bs = Cs but not As, then the gradient should go from As to the closest point on the line BC to A.