Sharp triangle color transition (FEA results)

Hi All,

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:



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

Hi ZbuffeR,

Wow, I would have never think about 1D texturing? Does it give perfect color transitions?

Can you point me to a small tutorial/example that show how to do it?

Thanks so much again,


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) :
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.

Thanks again ZbuffeR I will try and let you know.