   Spolight and glNormal3F(..)
  Hi,I'm trying to understand the glNormal3d(...) with respects to spotlighting. I have an image that is placed a the center of a 3D environment.glBegin( GL_QUADS );  glTexCoord2f( 0, 0 ); glVertex3f( -2.0,  1.0, 0.0 );  glNormal3f( 0.00, 0.00, 1.00 );  glTexCoord2f( 0, 1 ); glVertex3f( -2.0, -1.0, 0.0 );  glNormal3f( 0.00, 0.00, 1.00 );  glTexCoord2f( 1, 1 ); glVertex3f(  2.0, -1.0, 0.0 );  glNormal3f( 0.00, 0.00, 1.00 );  glTexCoord2f( 1, 0 ); glVertex3f(  2.0,  1.0, 0.0 );  glNormal3f( 0.00, 0.00, 1.00 );glEnd();I have the spotlight moving from the left to the right pointing at the center of the picture. Once this sence is done, I move onto another scene. The efect of this technique is to give the illusion that small portions of the image (text) is being illuminated.I am unclear as to how one picks the proper values for the glNormal3f(...), (if indeed this is the problem.) I am unclear if this is a lighting problem or the way light is being 'reflected' (hense glNormal3f(..)). How do I go about picking the proper vaules to get the right effect? Thanks for the help,Sabrina   
  the proper value for glnormal3f is the vertex-normal... im not sure what the problem is ... (to find the normal, cross-product the two vectors leadin to the point..)   ;  Lighting in opengl is per vertex.  Thus if you one have a handful of polygons (or one as appears to be the case for you) you will not see the effect you expect.  Either tesselate your geometry or use some sort of per pixel lighting.  For a light accross text effect you might be best off with a very simple lightmap.;  The light is calculated per vertex and then interpolated, if you want a spotlight effect you will need to split the quad into many smaller ones(or use a shader to get per-pixel lighting).   ;  ehm??glTexCoord2f( 0, 0 ); glVertex3f( -2.0, 1.0, 0.0 ); glNormal3f( 0.00, 0.00, 1.00 );i think first use glNormal before glVertex. et.glTexCoord2f( 0, 0 ); glNormal3f( 0.00, 0.00, 1.00 );glVertex3f( -2.0, 1.0, 0.0 ); in your case normal for first vertex is undefined . nad for proper normal cross product 2 vectros of quad leading to point.   ;Quote:Original post by Anonymous Posterehm??glTexCoord2f( 0, 0 ); glVertex3f( -2.0, 1.0, 0.0 ); glNormal3f( 0.00, 0.00, 1.00 );i think first use glNormal before glVertex. et.glTexCoord2f( 0, 0 ); glNormal3f( 0.00, 0.00, 1.00 );glVertex3f( -2.0, 1.0, 0.0 ); in your case normal for first vertex is undefined . nad for proper normal cross product 2 vectros of quad leading to point.The default normal is well defined, and it is (0,0,1), so in his/her (Sabrina - I guess her) case she wouldn't notice anything wrong (unless of course she is changing it again somewhere later in the frame and rendering again).  It's true that a vertex's normal must be defined before calling glVertex however.To the OP, I recommend reading thoroughly the Lighting Chapter of the Red Book if you haven't already.  It explains exactly what normals are and how they work with the lighting equations.   ;Opps, Yes the code is glNormal3f( 0.00, 0.00, 1.00 ); glTexCoord2f( 0, 0 ); glVertex3f( -2.0, 1.0, 0.0 ); I posted via copy and past in the wrong order.As far as per-pixel lighting recommendation, I've been goggling this subject as well. I'm not finding much success on 'How to' tutorials, or even some basic introduction into the subject. To be sure I'm on the right track as far as researching the subject, does this take advantage of the extensions, i.e. "GLee" libraries?Sabrina.   ;Hi,First, sorry what I am about to do (copy and past some code).I want a light source to start from the left side of the screen and move to the right side of the screen, while the Y and Z axis remain fixed. The effect that I am looking for is to have the light illuminate the center of the picture.I have been poring over documents, tutorials, and books, but I am not seeing what I might be doing wrong.I have been tweaking material and lighting values to no end, and still I am not getting good lighting. Nate Robins has a good tutorial on this subject, but I am not seeing what I am doing wrong with respects to his settings.I'd appreciate another set of eyes and have someone look at the code below.Thank you.Sabrina.bool SomeClass::Initialize( void ){  SomePic.LoadImage(_T("Pic.tga") );  glCullFace(GL_BACK);  glEnable(GL_COLOR_MATERIAL);  glColorMaterial( GL_FRONT, GL_AMBIENT_AND_DIFFUSE );  glShadeModel(GL_SMOOTH);  glEnable( GL_BLEND );  glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );  Reset();  Light.SetCutOff(90.00f);  Light.SetSpotExponent(30.00f);  Material.SetAmbient( 0.50, 0.50, 0.50, 1.00 );  Material.SetDiffuse( 0.50, 0.50, 0.50, 1.00 );  Material.SetSpecular( 0.33, 0.33, 0.33, 1.00 );  Material.SetEmissive( 0.00, 0.00, 0.00, 0.00 );  Material.SetShininess(100.00f);  Camera.SetUp( 0.00f, 0.00f, 7.00f,    0.00f, 0.00f, 0.00f,    0.00f, 1.00f, 0.00f );  return ( true );}void SomeClass::Reset( void ){  LightMovmentX = -5.00f ;  Light.SetPosition( LightMovmentX, 0.00f, 1.00f, 1.00f );  Light.SetDirection( 0.00f, 0.06f, -1.00f );  Light.SetAmbient( 0.00f, 0.00f, 0.00f, 1.00f );  Light.SetDiffuse( 0.50f, 0.50f, 0.50f, 1.00f );  Light.SetSpecular( 0.50f, 0.50f, 0.50f, 1.00f );  Light.SetAttenuation( 1.00f, 0.00f, 0.00f );  Light.EnableLighting( true );}void SomeClass::OnRender( const float fTick ){  Camera.Update( .001f );  LightMovmentX = LightMovmentX + 0.050;  Light.SetPosition( LightMovmentX, 0.06, 4.00f, 1.00f );  Light.BindLight();  Material.BindMaterial();   DrawBackground();}   ;  Don't worry about posting some code along with your question, it makes it easier to see what might be wrong.  Just use the source tags in the future, it makes it much easier to read.  See the FAQ for the tags you can use.From what I'm assuming those functions are doing, your code looks alright.  What exactly is wrong with the lighting?  Could you post a screenshot?  What does your DrawBackground function look like?  Are you drawing just one quad?  I think that may be the problem but we can't be sure without a little more information.Drawing just one big quad is a problem because standard lighting is done per-vertex.  So if light is only hitting the center of the quad but not the corners (where the vertices are) it will appear as though no light is hitting it at all.  You will need to tesselate the quad more to fix it, assuming that is indeed your problem.   ;Thought I had the tags in after reading the FAQ for posting, I got them now.Thanks for taking a look at the code, its often heplful to have a second pair of eyes. Anyway, I have a screen shot of whats going on  here The screen shots in question are at the bottom of the page. Nate Robins has a good tutorial on the subject of lighting, I've been looking at  his example closley and I'm stumped as to why my lighting is not working the way I have hoped for. You did mention "...tesselate the quad...", this is somewhat new to me (I had to google the term). From what I am understanding is that I would need more vertices/quads, right? If indeed this is necessary after reviewing the code below, could you provide some code or link so I have a better idea of what I need to do?Thanks again,Sabrina// Just draw our picture (tga) to the background. void SomeClass::DrawBackground( void ){   glEnable(GL_DEPTH_TEST);  glEnable(GL_BLEND);  glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);  EngineLogo.Bind();  glBegin( GL_QUADS );    glNormal3f( 0.00, 0.00, 1.00 );  glTexCoord2f( 0, 0 );  glVertex3f( -1.0,  0.50, 0.0 );    glNormal3f( 0.00, 0.00, 1.00 );  glTexCoord2f( 0, 1 );  glVertex3f( -1.0, -0.50, 0.0 );    glNormal3f( 0.00, 0.00, 1.00 ); glTexCoord2f( 1, 1 );  glVertex3f(  1.0, -0.50, 0.0 );    glNormal3f( 0.00, 0.00, 1.00 );  glTexCoord2f( 1, 0 );  glVertex3f(  1.0,  0.50, 0.0 );  glEnd();  EngineLogo.UnBind();  glDisable(GL_BLEND);  glDisable(GL_DEPTH_TEST);}