PDA

View Full Version : color index with material properties



rajesh_jagmohan
04-21-2011, 01:56 AM
i want the various index with ambient,diffuse,specular and shininess properties to light the materials with different colors
for example
GREEN
ambient:0.0, 0.0, 0.0
diffuse:0.1, 0.35, 0.1
specular:0.45, 0.55, 0.45
shininess:.25
i want to know other color specification.from where i can get this.

_arts_
04-21-2011, 03:17 AM
Don't use index color, it's old and useless now.

rajesh_jagmohan
04-22-2011, 11:33 PM
sir,i am not asking for the index.i am asking for the values of ambient,diffuse,specular and shininess values of different colors.

Alfonse Reinheart
04-23-2011, 12:04 AM
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.

rajesh_jagmohan
04-23-2011, 09:45 PM
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
thanks

ZbuffeR
04-25-2011, 12:46 AM
RED:
diffuse:1.0, 0.0, 0.0
BLUE:
diffuse:0.0, 1.0, 0.0
GREEN:
diffuse:0.0, 0.0, 1.0
etc...
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.

rajesh_jagmohan
04-25-2011, 01:42 AM
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

_arts_
04-25-2011, 03:09 AM
Check for material color database, or use a modeler like 3DSMax.

The Little Body
04-25-2011, 03:16 AM
Hi,

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.

The Little Body
04-25-2011, 03:41 AM
Arts, why the material/color index method is useless ???

Ok, it's effectively very old :)

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 width*height 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 width*height textures filled by 32 bits rgba8888 values ...

This can certainly to be make with a fragment shader ?

somnath
04-25-2011, 07:18 AM
Check for material color database, or use a modeler like 3DSMax.

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

The Little Body
04-25-2011, 10:15 AM
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 ?

The Little Body
04-25-2011, 12:26 PM
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" :)

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

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" http://fr.wikipedia.org/wiki/Cell-shading#Seuillage_des_ombres ) ?

The Little Body
04-25-2011, 04:11 PM
Something like at http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=37
(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 http://fr.wikipedia.org/wiki/Fichier:Shadow_map.png 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 :)

The Little Body
04-25-2011, 05:24 PM
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 )


by



sscanf(Line, "%f %f %f\n", &amp;shaderData[i][0], &amp;shaderData[i][1], &amp;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 :)

somnath
04-27-2011, 06:52 AM
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
thanks

ZbuffeR
04-27-2011, 08:33 AM
i want to know how to convert 0-255 range to 0-1 range
Really ? Did you try dividing by 255.0 ?
I have the impression all this is way over your head.

V-man
04-27-2011, 09:25 AM
Use one of the glColor calls such as glColor3ub or glColor3ubv or glColor4ub or glColor4ubv.

It's all in the documentation
http://www.opengl.org/sdk/docs/man/

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 Little Body
04-27-2011, 01:53 PM
Hi,

The last post was for add a color extension to the "only grey ramp" originaly proposed at http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=37

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

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) ?

The Little Body
04-27-2011, 02:33 PM
rajesh

I have found a little surface material database at http://acc6.its.brooklyn.cuny.edu/~lscarlat/graphics/SurfMats.html

somnath
05-03-2011, 06:42 AM
thanks .. dividing by 255.0 is right way

rajesh_jagmohan
06-08-2011, 10:38 AM
sir,i want to know that how can we use text box,menubar,scroll bar,and button in opengl.please help me ,as a i make a project on which we require to take input from the user.

StefanG
06-09-2011, 01:19 AM
> ,i want to know that how can we use text box,menubar,scroll bar

Then please post that question in a separate thread.
Also, consider posting it in the "OpenGL toolkits" section, as it is not direcltly related to OpenGL.

Generally speaking, I would choose a GUI toolkit like Qt for the buttons and other stuff, and add an OpenGL panel to the GUI layout to show the 3D rendering. If you want very simple input you might prefer to use some widget tookit based on OpenGL and render the buttons and other user interface elements in the 3D view, but I do not recommend it for general purpose GUI programming.