A color plot of 2d field of scalar values

Hello

I am new to OpenGL. I managed to work with Texture. What I am trying is to make a texture representing the magnitude of pressure over a domain and then apply it on to the domain when rendering. I have the normalized pressure values[0,1] all over my 2d domain which essentially is a rectangular Cartesian grid.

I am doing some thing like take the value(normalized) and multiply it to (0.3, 0.58, 0.68) [a random vector] to generate RGB values for that point in the texture. But the result I see is very bad. Also it does not actually represent the pressure intensities on the domain but produces some random colors. Is there a better or simple way to do this? I see this nice red to blue color plots in softwares like paraview. How to generate such color plots in opengl.

Regards
Aditya

Make a 1D texture that contains the color map (i.e. for every normalized pressure value it contains the color you want to assign to it). Then use a fragment shader program to look into you pressure texture and then do a lookup into you color map texture (using the pressure value as texture coordinate) to find the color for that fragment.

The color map texture can be any size, pressure values that do not have an exact entry will use linear interpolation (provided you enable linear filtering for the texture) between adjacent entries.

Thank you for the reply casten neumann.

I will try this approach. I have a question. you suggested making 2 textures one 1D and second the one with pressure values. who can I apply 2 textures. It would be great if you can give me some example code.

Regards and Thanks … !!