How to generate rainbow colors in OpenGl?

I am drawing a jet/plume in 3D and I want to change the jet color according to the concentration. I want use rainbow color palette, but I cannot find it in my book.

I have problem to generate rainbow colors in 3D OpenGl. Anyone who know the combination about RGB to produce rainbow, please tell me and I am very appreciate it.

Thanks
F.Chen

If I’m correct (all colors in RGB):
Magenta (1 0 1)
Blue (0 0 1)
Cyan (0 1 1)
Green (0 1 0)
Yellow (1 1 0)
Red (1 0 0)

If I remember correctly the colours in the rainbow are ROY-G-BIV, or red, orange, green, blue, indigo, violet. Try using a paint program to match those colours visually, write down the rgb values from the requester and voila, rainbow colours.

As you can see you cant perform a linear interpolation of RGB values to get an rainbow like shading (this works in HSV though).

Instead I would draw a single (rainbow like) line using a paint program and use that as a 1D texture.

To represent differend thrust concentrations you just have to adjust the texture coords accordingly.

Hope that helps,

LG

harsman, you forgot to mention yellow between orange and green

DOH!

Thanks and best regards.

The following is part of my codes:

// define a rainbow palette The total number of colors=5*256=1280

GLint index;

#define numRed 256
#define numGreen 256
#define numBlue 256

index=0;
for (int grn=0; grn<numGreen; grn++)
{
palette[index][0]=1.;
palette[index][1]=grn/255.;
palette[index][2]=0.;
index=index+1;
}
index=1256;
for (int red=0; red<numRed; red++)
{
palette[index][0]=1-red/255.;
palette[index][1]=1.;
palette[index][2]=0.;
index=index+1;
}
index=2
256;
for (int blu=0; blu<numBlue; blu++)
{
palette[index][0]=0.;
palette[index][1]=1.;
palette[index][2]=blu/255.;
index=index+1;
}
index=3256;
for (grn=0; grn<numGreen; grn++)
{
palette[index][0]=0.;
palette[index][1]=1-grn/255.;
palette[index][2]=1.;
index=index+1;
}
index=4
256;
for (red=0; red<numRed; red++)
{
palette[index][0]=red/255.;
palette[index][1]=0.;
palette[index][2]=1.;
index=index+1;
}
By using this, I have generated the color palette as shown in the attached file.

Thanks again,

Fanghui Chen