color index with material properties

i want the various index with ambient,diffuse,specular and shininess properties to light the materials with different colors
for example
ambient:0.0, 0.0, 0.0
diffuse:0.1, 0.35, 0.1
specular:0.45, 0.55, 0.45
i want to know other color specification.from where i can get this.

Don’t use index color, it’s old and useless now.

sir,i am not asking for the index.i am asking for the values of ambient,diffuse,specular and shininess values of different colors.

i want to know other color specification.from where i can get this.

That’s not how it works. What you call “green” would still be “green” if you changed the diffuse value to be 0.1, 0.4, 0.1. Color names do not specify a specific wavelength of light; at best, they specify a range of actual wavelengths and colors. There is no one configuration that represents “green.” There are configurations that would be seen as various shades of green, but none of them have any greater claim to that name than any others.

The color of a surface depends on its reflective properties (as specified by the material parameters) and the lighting environment. It is entirely possible for a “green” surface to appear grey if you shine a “red” light on it.

The color of a surface depends on its reflective properties

can u plz tell me the property of surface which make it red,or ble or green or any other color …i want that properties of material

diffuse:1.0, 0.0, 0.0
diffuse:0.0, 1.0, 0.0
diffuse:0.0, 0.0, 1.0
To find your exact color, you can use any 2D painting tools such as Gimp to play with settings until you find your color.

For the other parameters, it depends on the type of material.
Most material have white specular, only some metal paints are colored.

thanks for ur reply

but i m searching for material property in light ie. its diffuse,specular and ambient and shininess to make the material colorful

Check for material color database, or use a modeler like 3DSMax.


They are different colors that are used by OpenGL

the ambient color (when the surface isn't lighted)

the diffuse color (when the suface is lighted with a "big" angle)

the specular color (when the normal and the vector defined by (light-position) have a little angle the surface is hightlighted)     

We can add

the refracted color (when the normal is "negative", it's an index into a "translucent mocaic")

It’s seem that colors materials properties can be shared with different ambiants, diffuses, speculars and refractives colors in each entry

They can be “unified” into a palette with the more 16 ambients colors first, diffuses materials after, speculars materials after and specials refractives colors at the end of the palette

Ambient colors are the more near the “black material”
(cf. index is near 0)

Diffuse colors around “grey values”
(cf. index is between say 16 and 128)

Speculars colors near “white values”
(cf. hightlighed, when indice is > 128 but < 240 for example)

The finals entries on the colormap store the refractives colors (colors 240…256) for handle refractive parts of this “mosaic picture”

Each facet on the mosaic is identified with a specific fragment ID shared in a 256 LUT

The palette store 256 differents (ambiant/diffuse/reflect/refract) colors/pixel shaders IDs, where each entry select a “specific/programmable” fragment shader ID to use.

Arts, why the material/color index method is useless ???

Ok, it’s effectively very old :slight_smile:

But not as useless as this …
(this can be used for simple toon shading too for example)

And with a palette, we have the possibility to select the good “color/material” into a palette => this can to be an advantage for to select the four colors/materials to be interpolated into a futur extented DXT compression that handle directely the ambiant, diffuse and specular term (in this case each palette entry isn’t only a RGBA color, but a “colored material properties” that have a RGBA ambiant term, a RGBA diffuse term and a RGBA specular term).

Using only one indexed texture that can work with an ambiant/diffuse/specular palette (cf. a texture with widthheight 8 bits index values + a palette of 256 entries with distincts ambiant/diffuse/specular RGBA terms) seem me very more economic is size (in fact something like 12x) that to use 3 widthheight textures filled by 32 bits rgba8888 values …

This can certainly to be make with a fragment shader ?

from where i can get the material color database–plz give any link

A 256 LUT colormap and a good big “pixel shader” that make a massive switch statement between the 256 possibles fragment shader codes (the rgba color LUT entry represent the ID of the fragment shader to use) ?

Something that can select differents fragment shaders from a shader table of 256 entries for each pixel fragment.

Like glColorMaterial but instancied for each fragment shader invocation and “extented” for to work with a new GL_REFRACTION token coupled to the already existents GL_EMISSION, GL_AMBIENT, GL_DIFFUSE, GL_SPECULAR, and GL_AMBIENT_AND_DIFFUSE OpenGL flags/tokens

=> why not an GL_INDEXED_[FRAGMENT/PIXEL]_SHADER_EXT texture format ?

This seem too like cell-shading and/or toon-shading (in french worlds “ombrage de celluloïd”)

This seem effectively share multiples vertex/fragment[/geometry] shaders pass into an “unified cell/toon pixel shader” :slight_smile:

But this seem limited to something like a cartoon or unrealistics shaders :frowning:

The interpolation of colors materials properties can perhaps to be extended from 8 bit to 16 bit indices for a better approximation than cell/toon shading for realistic rendering (where the RGB colorspace can be replaced by an YCbCr colorspace for too handle “more naturally” the “seuillage des ombres” ) ?

Something like at
(On Fedora 14, I have downloaded the Linux / GLut Code version, deleted the -lxmu linkage in the makefile, then make)

The 1D black/greys/white ramp texture Fichier:Shadow map.png — Wikipédia can to be transformed to a 2D texture filled with materials and/or shaders IDs

I have too changed the rotation speed

modelAngle += 2.0f;

to a smaller value such as 0.1f

because this is too fast on my computer with 2.0f :slight_smile:

I can make a psychedelic effect with only replace this line

  shaderData[i][0] = shaderData[i][1] = shaderData[i][2] = float(atof(Line)); // Copy Over The Value ( NEW )


      sscanf(Line, "%f %f %f
", &shaderData[i][0], &shaderData[i][1], &shaderData[i][2]); // the 32 grey shades shaderData[] are extented into independants RGB colors into Data/Shader.txt

Into lesson37.cpp at the line 164

And modify the Data/Shader.txt file

This is the default 32 grey ramp here for example :

0.2 0.2 0.2
0.2 0.2 0.2
0.2 0.2 0.2
0.2 0.2 0.2
0.5 0.5 0.5
0.5 0.5 0.5
0.5 0.5 0.5
0.5 0.5 0.5
0.5 0.5 0.5
0.5 0.5 0.5
0.5 0.5 0.5
0.5 0.5 0.5
0.5 0.5 0.5
0.5 0.5 0.5
1.0 1.0 1.0
1.0 1.0 1.0
1.0 1.0 1.0
1.0 1.0 1.0
1.0 1.0 1.0
1.0 1.0 1.0
1.0 1.0 1.0
1.0 1.0 1.0
1.0 1.0 1.0
1.0 1.0 1.0
1.0 1.0 1.0
1.0 1.0 1.0
1.0 1.0 1.0
1.0 1.0 1.0
1.0 1.0 1.0
1.0 1.0 1.0
1.0 1.0 1.0
1.0 1.0 1.0

With differents values on the Data/Shader.txt this can make a great and/or psychedelic cell/toon shading style :slight_smile:

thanks for reply

i have used color picker to find the color in RGB formate but it is always in 0-255 range but in openGL our range is 0-1…i want to know how to convert 0-255 range to 0-1 range

or any other way to find in 0-1 formate

Really ? Did you try dividing by 255.0 ?
I have the impression all this is way over your head.

Use one of the glColor calls such as glColor3ub or glColor3ubv or glColor4ub or glColor4ubv.

It’s all in the documentation

or convert to float and use glColor4fv, etc.

Also, The Little, can you not post one after the other. He isn’t doing cell shading it seems. He is asking about color.


The last post was for add a color extension to the “only grey ramp” originaly proposed at

Note that this support already colors on a float format :slight_smile:

And that the sscanf function and the data/shader.txt file format can easily to be extended for to handle very more materials properties that only a the rgb color.

The texture position (the texture contain colors/ material properties) is computed by the dot product of the polygon’s normal and the light vector, but this can be extended (or simplified) for to “only” handle constants materials properties over each polygon.

Another method, material properties can certainly to be pop/push and/or stored into a list (cf. glGenList/NewList/Endlist) ?


I have found a little surface material database at