Results 1 to 3 of 3

Thread: GL_SHININESS does not work. Can't find a mistake..

  1. #1
    Junior Member Newbie
    Join Date
    Apr 2009
    Posts
    7

    GL_SHININESS does not work. Can't find a mistake..

    Dear All,
    I'm trying to make shiny highlights on my objects. After reading tutorials I do the following:
    Code :
    -- Initialiation --
    glShadeModel(GL_SMOOTH);
    glClearDepth(1.0);
    glClearColor(bg_color[0], bg_color[1], bg_color[2], 0.0);
    glEnable(GL_DEPTH_TEST);
    glDepthMask(GL_TRUE);
    glDepthFunc(GL_LEQUAL);
     
    // Light
    GLfloat LightAmbient[]= { 0.2f, 0.2f, 0.2f, 1.0f }; //Ambient light
    GLfloat LightDiffuse[]= { 1.0f, 1.0f, 1.0f, 1.0f };	// Diffuse Light Values
    GLfloat LightSpecular[]= { 1.0f, 1.0f, 1.0f, 1.0f };	// Diffuse Light Values
    GLfloat LightPosition[]= { 100.0f, 100.0f, 130.0f, 1.0f }; // Light Position
     
    glEnable( GL_LIGHT0 );
    glEnable( GL_LIGHTING ) ;
    glLightfv(GL_LIGHT0, GL_AMBIENT, LightAmbient);	// Setup The Ambient Light
    glLightfv(GL_LIGHT0, GL_DIFFUSE, LightDiffuse);	// Setup The Diffuse Light
    glLightfv(GL_LIGHT0, GL_SPECULAR, LightSpecular); // Specular light
     
    glLightfv(GL_LIGHT0, GL_POSITION, LightPosition); // Position The Light
     
    glEnable ( GL_COLOR_MATERIAL ) ;
    glColorMaterial ( GL_FRONT, GL_AMBIENT_AND_DIFFUSE ) ;
     
    -- Rendering code ---
    glPushMatrix();
    glColor4f(R,G,B,1.0);
    glMaterialf(GL_FRONT, GL_SHININESS, 128);
    gluSphere(quadric,sz,16,16);
    glPopMatrix();

    I can't see any shiny spots. Changing the shininess value makes no effect. I can't find an error
    Any help is very appreciated!

  2. #2
    Super Moderator OpenGL Guru imported_dorbie's Avatar
    Join Date
    Jul 2000
    Location
    Bay Area, CA, USA
    Posts
    3,966

    Re: GL_SHININESS does not work. Can't find a mistake..

    It expects a float but I think the compiler should handle that.

    When you say it doesn't work, what are you expecting?

    Shininess is the specular exponent, so it controls the size of the specular highlight. For high exponents the highlight is very small and crisp. For something lower it is spread out and gradually attenuated.

    With per vertex lighting you will only see a specular highlight with a large exponent if there are sufficient vertices to represent it. It is likely that you just don't have enough vertices to represent the small specular region.

  3. #3
    Junior Member Newbie
    Join Date
    Apr 2009
    Posts
    7

    Re: GL_SHININESS does not work. Can't find a mistake..

    Ok, I understand what's wrong after your phrase about specularity! I forgot to set the specular component of the material. Stupid. Thanks a lot!

Similar Threads

  1. Mistake in COLLADA 1.5 specification?
    By hpesoj in forum COLLADA
    Replies: 2
    Last Post: 09-28-2012, 04:09 AM
  2. [GLSPEC4.1] - Mistake
    By skypers in forum OpenGL: Drivers
    Replies: 1
    Last Post: 01-06-2011, 02:07 AM
  3. Post Mistake
    By Jassel41 in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 08-03-2010, 07:41 PM
  4. Max script = BIG mistake?
    By jonaz.dk in forum COLLADA
    Replies: 2
    Last Post: 09-15-2004, 02:09 AM
  5. ZBuffer: Mistake or Problem
    By Powerino in forum OpenGL: Advanced Coding
    Replies: 3
    Last Post: 09-18-2003, 07:25 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean