[gameprogrammer] OpenGL Lighting and Materials

  • From: Richard Sabbarton <richard.sabbarton@xxxxxxxxx>
  • To: gameprogrammer@xxxxxxxxxxxxx
  • Date: Thu, 6 Aug 2009 21:47:22 +0100

Hi Guys,

I have been googling this for a while and I can't seem to find the
answer I am looking for.  I am rendering in OpenGL and trying to
assign glMaterial attributes for use when rendering.  The problem I
have is that changing these attributes does not have any effect on the
faces I am rendering.  For example, I can adjust the specular and
shininess attributes in real time but there is no change in my scene.
I have been over my code many times and I cannot find the source of
the problem.

In psuedocode this is my process...

During scene setup (for each frame):
 - Set the glLightModel GL_LIGHT_MODEL_AMBIENT to my Ambient Light for my scene
 - Set the Ambient and Diffuse attributes of GL_LIGHT1
 - Enable GL_LIGHT1
 - Set GL_LIGHT1 position

Then during rendering for the parts of my scene I set the following
for each mesh/element:
 - Use glMaterialfv() to set the Ambient, Diffuse, Specular and
Emission parameters
 - Then I set the Shininess using glMaterialf()
 - Enable GL_LIGHTING (I am only using GL_LIGHT1)
 - Then I start my glBegin(GL_TRIANGLE_STRIP) and render what I need to
    - For each Vertex I set the glNormal3f() before calling glVertex3f()

I am able to adjust any of the RGBA glMaterial values in real time but
I do not see any change in the way the model is rendered.  I have
checked that the values being passed are correct through debug but
changes I make do not seem to have any effect on the end result and it
is starting to "bake my noodle!"

I also tried enabling GL_COLOR_MATERIAL, taking out the settings for
Ambient and Diffuse, and using glColor4f() for each vertex.  This
produces the same results.

The scene does respond to light.  The model does have darker and
lighter areas according to the normals I am passing and the rotation
of the faces etc.  It is just not responding to the specular and
shininess values I am passing.

Do you have any thoughts on this?  Do you think the process above seems OK?

My Normals are calculated and seem to be correct.
Orientation is correct i.e. there is no confusion between front and back faces.

Regards


Richard

---------------------
To unsubscribe go to http://gameprogrammer.com/mailinglist.html


Other related posts:

  • » [gameprogrammer] OpenGL Lighting and Materials - Richard Sabbarton