Sign in to follow this  

Mapping RGB colors to values

Recommended Posts

I need to do the following: Say the maximum displacement of a node is A. I want to use this value to manipulate the colour (red for largest , blue for lowest, interpolation of colours in between)for every vertices on my surface (would like to pass by green, yellow,.. for instance.). Currently I can only use this: glColor3f(Displacement1/A,0,1 - (Displacement1/A)); glVertex3d(x1,y1,z1); This will only give me shade of red to blue. Can anyone help me to use colours so as to describe the distribution/ analysis of displacements of nodes on the surface. Someone mentioned 1D texture and map it to the values but I haven't a clue how to do it. Are there any examples I can refer to? Regards.

Share this post

Link to post
Share on other sites
Well, you could create the texture yourself (1 pixel height) and load it with glTexImage1D.
Then provide appropriate texture coords with 0 = lowest and 1 = highest.

Or just use a 2D Texture with one dimension set to 1 (I don't know if there are any restrictions on this but if so, just use a wider texture that contains your gradient.

Alternatively you might apply the color in a shader, calculating either the rgb-values (like if(rel_height >= 0 and rel_height < 0.3) {//set blue and green accordingly} etc.).

Or maybe the HSV colorspace (wiki) is an option. You could use fixed values as s(aturation) and v(alue) and encode your height as h(ue), performing the conversion to rgb in the shader. I'm no expert in this, though, and thus can't say if that would work and is what you want. But you could give it a try.

Hope that helps ;)


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