#### Archived

This topic is now archived and is closed to further replies.

# 3D colour graph?

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

## Recommended Posts

Hello, I''m making a 3D graph, in OpenGL. I got the data ploted. But couldn''t get the colour right. You know, a curve in a 3D graph. They have white/light colour for the peak, and some dark colour for the valley. How do i do that? Thanks for any help

##### Share on other sites
The graph is something like z = x*x/9+y*y/8 or something right? So the graph changes along the z axis. Just find the max z value you ever plot, and the min z value you ever plot and change the color accordingly.
Like is max is the max z value and min is the min z value and z is the current z value,
c = (z-min)/(max-min)
Then, assuming you use floats for colors, set the color to c,c,c. Then graph will be brighter closer to the max values and darker towards the min values.
Changing to 0-255 is easy, if you need that.

--------------------------------------------------------
Life would be so much easier if we could just get the source code.

##### Share on other sites
Use a 1d texture for rendering in the z axis. There is a demo in the redbook.

lighting...

##### Share on other sites
Yes, that''s exactly what i''m trying to do. I got this bit right [ c = (z-min)/(max-min) ]. But then the colour thing came...
Oh, is there any way to add more colour to the graph?
Thanks

Thanks quorn

1. 1
2. 2
Rutin
19
3. 3
4. 4
5. 5

• 14
• 13
• 9
• 12
• 9
• ### Forum Statistics

• Total Topics
631438
• Total Posts
3000073
×