Archived

This topic is now archived and is closed to further replies.

themule

lighting makes scene black n white

Recommended Posts

i make a green grid, and a purple nurbs surface, but when i introduce light (diffuse light), i can see the lighting effect but the whole scene turns black n white and shades of gray.... can''t figure out how. before drawing my grid and surface i am choosing the color explicitly and yet... could anyone point out where am i going wrong? thanks a bunch.

Share this post


Link to post
Share on other sites
could u be more specific? i didn''t get wht the normals have to do with the colors disappearing.. and moreso.. wht should i do with the normals anyways?
please help, i have no clue abt how the normals intervene with this matter.

thanks again.

Share this post


Link to post
Share on other sites
Or you can play with material colorings:

glMaterialXX() for each of:
GL_AMBIENT
GL_DIFFUSE
GL_SPECULAR
GL_EMISSION
GL_SHININESS

For Example:
float rAmbient[4];
float rDiffuse[4];
float rSpecular[4];
float rEmissive[4];
float rShininess;

// Set your values for the above.

glMaterialfv(GL_FRONT, GL_AMBIENT, rAmbient);
glMaterialfv(GL_FRONT, GL_DIFFUSE, rDiffuse);
glMaterialfv(GL_FRONT, GL_SPECULAR, rSpecular);
glMaterialfv(GL_FRONT, GL_EMISSION, rEmissive);
glMaterialf (GL_FRONT, GL_SHININESS, rShininess);

This will probably take a bit more reading and experimenting, but you can make some pretty neat looking stuff with it.

- sighuh?

Share this post


Link to post
Share on other sites
Do as RedDragon said...but don''t forget about the normals...

Why it is important to lighting? It is used by lighting to calculate it''s reflecction, shininess, etc... It should be pointing out from your polygon face. For example, in a ccube the normals should be pointing out from each of the cube''s face.

For more complex models you should consider doing vertex normals, it will look more smooth...but it''s another story...

Share this post


Link to post
Share on other sites
About normals: they mathematically determine which way the light reflects off a model. You will have to do run time generated normals - basically cross the two vectors that make up the triangle and apply that normal to each vertex - you can use GL_NORMALIZE to make them unit vectors. If you want to smothe out your nurb surface you are going to have to run a smothing algorithm. Basically for each vertex, you average the normals for each triangle that the vertex belongs to; hopes this makes sence

On a side note; normals are also important for sphere mapping - if you dont include vertex normals you wont get the desired effect.

Share this post


Link to post
Share on other sites
ok thanks everyone, the colors came by enabling GL_COLOR_MATERIAL
ya i think my normals are ok. and abt the few things related to glMaterial that redragon has suggested to experiment with and read about, i have been trying to figure them out myself, but msdn doesn''t seem to help much, i don''t know y these msdn ppl have made msdn so counter intuitive... it just fails to tell in a straightforward manner what a particular function or capability is supposed to do and what is it used for. The Java API documentation is soooo much better than msdn.
now i am looking for some other resources to read up on my opengl queries, i am hoping to find something on the net, as i dont even have the red or blue book of opengl, can''t afford to buy any and the only copy in my library is issued for a good long time by some faculty
all the opengl that i know is from tutorials/articles etc from the net.

anyways, thanks everyone.

Share this post


Link to post
Share on other sites