View Full Version : Sharp triangle color transition (FEA results)
09-14-2008, 02:38 PM
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
09-14-2008, 03:25 PM
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
09-16-2008, 01:58 AM
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,
09-16-2008, 06:31 AM
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.
09-16-2008, 06:57 AM
Thanks again ZbuffeR I will try and let you know.
Powered by vBulletin® Version 4.2.3 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.