Results 1 to 4 of 4

Thread: More sun light

  1. #1

    More sun light

    Like Javac I too am have some lighting problems on my planet. I've created a segment of a sphere using triangle strips with heights applied to vertices. For the time being I have set all the normals to be opposite and parallel to gravity, ie. pointing away from the centre of the sphere. I have set:
    glEnable( GL_COLOR_MATERIAL );
    and then defined the colour of each vertex according to it's height.

    For lighting I have set:
    GLfloat ambientLight[] = { 0.f, 0.f, 0.f, 1.f };
    GLfloat diffuseLight[] = { 1.f, 1.f, 1.f, 1.f };
    glLightfv( GL_LIGHT0, GL_AMBIENT, ambientLight );
    glLightfv( GL_LIGHT0, GL_DIFFUSE, diffuseLight );
    // position sun at local noon northern summer
    GLfloat sun_x, sun_y, sun_z;
    theEarth.LLA2ECR( sun_x, sun_y, sun_z, 23.*DR, (west+east)/2., 0. );
    GLfloat lightPosition[] = {sun_x, sun_y, sun_z, 0.f};
    glLightfv( GL_LIGHT0, GL_POSITION, lightPosition );

    All is fine when looking at the horizon, but looking straight down at the planet everything goes very dark. What am I missing?



  2. #2

    Re: More sun light

    I have now set the normals to be the average of the normals to the four faces meeting at a vertex. But still, when I point the camera in the same direction as the light source, the image becomes very dim.

    Any thoughts?

  3. #3

    Re: More sun light

    Are you calling the glLightfv calls just once, or per frame? Your problem appears to be because you aren't positioning the light at each frame (which I believe needs to be done).

  4. #4
    Senior Member Regular Contributor
    Join Date
    Feb 2002

    Re: More sun light

    macfiend sounds right. Remember that lights get transformed by the modelview matrix as well. So if you set your light only once you should change this and set it every frame after your camera transformation.

Similar Threads

  1. What's different between ambient light and diffuse light,?
    By reader1 in forum OpenGL: Basic Coding
    Replies: 11
    Last Post: 06-12-2015, 08:41 AM
  2. How to add a light if white ambient light is active?
    By FedorSymkin in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 11-21-2014, 03:40 PM
  3. Positioned spot light - white light appearing from nowhere behind
    By windchine in forum OpenGL: Basic Coding
    Replies: 9
    Last Post: 08-03-2012, 02:30 AM
  4. Fixed light and moving spot light with the mouse
    By Jorcelangelo in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 04-18-2012, 09:56 PM
  5. Point light VP -> Spot light VP: ?
    By Freelancer in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 01-27-2004, 11:43 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