Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 4 of 4

Thread: illumination

  1. #1
    Junior Member Newbie
    Join Date
    Jun 2009
    Location
    Ulm, Germany || Granada, Spain
    Posts
    2

    illumination

    I've got some problems with setting the lights in my project (using Java opengl bindings).
    I'm trying to set up lights to illuminate the whole scene. is there any way to set the intensity of a light (in the infinity)
    I set up light0 but still the whole scene is pretty dark.
    My code is the following:
    Code :
    float light_pos[] = {-5, -5, -5, 0};
    float light_color_am[] = {1, 1, 1};
    float light_color_diff[] = {1, 1, 1};
    float light_color_spec[] = {1, 1, 1};
     
    gl.glLightfv(GL.GL_LIGHT1, GL.GL_POSITION, light_pos,0);
    gl.glLightfv(GL.GL_LIGHT1, GL.GL_AMBIENT, light_color_am,0);
    gl.glLightfv(GL.GL_LIGHT1, GL.GL_DIFFUSE, light_color_diff,0);
    gl.glLightfv(GL.GL_LIGHT1, GL.GL_SPECULAR, light_color_spec,0);
    gl.glLightf(GL.GL_LIGHT1, GL.GL_SHININESS, 150);
    gl.glEnable(GL.GL_LIGHTING);
    gl.glEnable(GL.GL_LIGHT0);gl.glEnable(GL.GL_LIGHT1);
    gl.glEnable(GL.GL_LIGHT2);
    gl.glEnable(GL.GL_LIGHT3);
    gl.glEnable(GL.GL_DEPTH_TEST);

    the result is the following:


    the ground is supposed to be a checkerboard using materials black plastic and white plastic from the following source:
    http://devernay.free.fr/cours/opengl/materials.html
    but the fields are displayed really weird...

    thank you for your help.

  2. #2
    Super Moderator OpenGL Lord
    Join Date
    Dec 2003
    Location
    Grenoble - France
    Posts
    5,575

    Re: illumination

    float light_pos[] = {-5, -5, -5, 0};
    this is correct for infinite distant light, when the fourth coordinate is = 0, then the 3 first define a direction, not a position.

    For the weird display, it looks like your normals are wrong.

  3. #3
    Junior Member Newbie
    Join Date
    Jun 2009
    Location
    Ulm, Germany || Granada, Spain
    Posts
    2

    Re: illumination

    normals on the ground should be just {0,1,0}... these are drawn. or am i wrong? I think on the car they're fine...

  4. #4
    Senior Member OpenGL Pro dletozeun's Avatar
    Join Date
    Jan 2006
    Location
    FRANCE
    Posts
    1,367

    Re: illumination

    You should double check your normals, even on the car the shading looks weird. You may try to draw them as lines and will see immediately if they are correct.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •