-1

I have a sequence of points in my implementation, for example 1.000.000 points which are placed according to a defined sequence that I developed. I want to color all of them in such a way that I cover all the colors ranges. I explain better: I have the first point which has to be, for example, white and the last one which has to be (again for example) black. All the points in the middle have to be coloured accordingly following the "rainbow" style (I don't know the technical terminology to call it). May you kindly help solving this problem?

genpfault
  • 47,669
  • 9
  • 68
  • 119
Tarta
  • 1,357
  • 1
  • 21
  • 35
  • You can't really interpolate "rainbow style" from white to black; the only difference is the value. The closest thing would be to convert the colors to HSV and interpolate those values, but it would still only create a greyscale gradient for black+white inputs. – Colonel Thirty Two Dec 12 '14 at 15:13

1 Answers1

0

There is a built-in variable that will come in handy: gl_VertexID. You can use that plus the amount of points passed in a uniform to interpolate the hue of the resulting color.

Then you can convert the HSL to RGB with a ported conversion function like found here (GLSL expect color values to be between 0 and 1 so remove the *255 in the result)

Community
  • 1
  • 1
ratchet freak
  • 44,814
  • 5
  • 55
  • 99