PDA

View Full Version : color

ilun82
11-08-2002, 12:08 AM
// set to GOLD color....

float mamb[]={0.24725f,0.1995f,0.0745f,1.0f}; //Ambient Reflection
float mdif[]={0.75164f,0.60648f,0.22648f,1.0f}; //Diffuse Reflection
float mspe[]={0.628281f,0.555802f,0.366065f,1.0f}; //Specular Reflection

glMaterialfv(GL_FRONT,GL_AMBIENT,mamb); //Set material properties
glMaterialfv(GL_FRONT,GL_DIFFUSE,mdif);
glMaterialfv(GL_FRONT,GL_SPECULAR,mspe);

how can i obtain the correct floating points as above in order to get my desired color?

how can i know that they stands for gold?

jebus
11-08-2002, 03:41 AM
the best way is to use a paint program that lets you specify colors using rgb values (ie photoshop, psp, mspaint?) the usual metric for rgb in these programs are unsigned bytes (either decimal or hex) you just have to convert it to a float.

jebus

mm_freak
11-08-2002, 05:03 AM
Gold isn't a color you can mix by RGB values. The best way should be to create a reflective or even mirroring texture and give it a dark yellow color.

ilun82
11-08-2002, 09:36 AM
how to convert to float?

yakuza
11-08-2002, 09:58 AM
RGB colors in paint programs are commonly calculated in unsigned bytes, with a range of 0-255. Therefore, you would simply divide the color value by 255 to get a float value for the color.

For example, suppose your RGB color in Photoshop is R=127 G=255 B=53
the float values would be:
R=127/255=0.498 (approx 0.5)
G=255/255=1.0
B=53/255=0.208

Hope that helps.

Edit: Stoopid typos http://www.opengl.org/discussion_boards/ubb/smile.gif

[This message has been edited by yakuza (edited 11-08-2002).]