I am trying to coloring a 3D tall cube with two different colors.
With one color starting from the top and the other starting from the bottom.
I want to do something like the original fixed pipeline does for the color interpolation.
- I don’t need color interpolation. So there are two distinct parts with different colors.
- I’d like to be able to specify where the colors intersect with each other. For example, a tall cube starting from (0,0,0) to (0, 10, 0), I want to paint it green from (0,0,0) to (0,x,0) , and red from (0, 10-x,0 ) to (0,10,0).
It hits me that I could probably do it by defining some user defined varying variable in shader. But I have no idea how to do it. Please help me. Thanks.