Everybody knows how to draw a triangle with one different color per vertex and obtain a smooth color transition between corners.
What about drawing sharp transition between color separated by isolines inside the single triangle? Take a look at the following image for example: http://www.premea.co.uk/gfx/stress_plot_tbn.jpg
1D texturing with GL_NEAREST interpolation.
Or use a fragment shader to discretize the interpolated color.
Something in the lines of result_color = (int(STEPS*in_color))/STEPS
By “perfect color transitions”, you mean sharp ? yes, with GL_NEAREST interpolation.
you can search the web for “opengl 1D texturing”.
In fact it is easy, like classic 2D texturing, with only the first texture coordinate to set for each vertex (glTexCoord1f) : http://www.opengl.org/sdk/docs/man/xhtml/glTexCoord.xml
Build your custom 1D texture with a single row of colors, with the gradient you want, ranging from texture coordinate 0.0 to 1.0.