Sign in to follow this  
AnnaG

Mixing HSV colors the good way

Recommended Posts

Hello all, I render tetrahedra with 300000+ colored triangles in 3D with glDrawElements() :
//at init
glVertexPointer(3, GL_FLOAT, 0, g->vertex_array);        
glColorPointer(3, GL_FLOAT, 0, g->color_array);
 ...
//rendering loop
glDrawElements(GL_TRIANGLES,12*g->Th.nt,GL_UNSIGNED_INT,g->triangle_indices);

I also use HSV colors for each of their vertices, converting HSV values to RBG before filling the color array
    |___>____|___>___|___>__|____>__|___>____|___
   red    orange  yellow  green   blue    purple
  (low values)                             (high values)

Now, if I render a triangle with vertices (RED, RED, BLUE) for instance, the color goes from red to blue by direct interpolation (passing by purple), instead of passing through all colors red -> orange->yellow->green->blue. This is particulary important for me as the color represents a 4th dimension, like a height map where each color represents a value. Is there a way to specify a palette or a color function, or even fill the triangle pixel by pixel ? Thanks a lot for your help.

Share this post


Link to post
Share on other sites
Umm.. this is the obvious and expected result, since interpolation across the surface of a polygon is always linear - and since you already converted to RGB, the interpolation will be linear *in RGB space*.

You'll have to use some kind of per-fragment functionality to get what you want. It might be possible to hack this together with texture lookups in the fixed function pipeline, but you'd probably be better off with a fragment program or fragment shader.

cu,
Prefect

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this