View Full Version : How to render each pixel of a surface with a diffrent color?

01-31-2002, 05:26 AM
Let's consider a surface ( could be a 3D representation of a function z=f(x,y) )
The thing is that i want to color each of that surface pixels with a diffrent color corseponding to the height from the XOY plane for example.

How can I do that in RealTime?

( I don't want to use a color texture , the example was fictive. I want something like the 3DSmax4 affect region thing )

01-31-2002, 06:10 AM
I think you sould use 1d textures.
if you have a grid of points with scalar values.
it will use linear interpolation between points.
with enough points a linear function can represent any function.

does this help?

01-31-2002, 07:27 AM
Use 1-D texture, and set the UV coordinates to the height of the point, divided by some parameter (that will denote the maximal height). The linear interpolation will do the rest.

01-31-2002, 10:26 AM
What about glColor3f(height / max_height, height / max_height, height / max_height); and gouraud shading?
This sounds stupidly simple but you would get the same result as with a 1D texture and it is even easier to use.

PS: you could use another color scheme than the grey one I proposed.

01-31-2002, 10:55 AM
If you want your height map to match your gradient exactly, use a 1D texture. Setting the colors of each individual vertex will cause OpenGL to do its own color interpolation which will not match your gradient. You notice this effect more on a rough map as opposed to a smooth map.