Jump to content
  • Advertisement
Sign in to follow this  
AnnaG

Mixing HSV colors the good way

This topic is 3695 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!