Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Problem with the depth buffer and lighting

  1. #1

    Problem with the depth buffer and lighting

    I am programming a space shooter and I am having a probleme with my planets and lighting.

    When I am close to them, they appear correctly see image 1.

    Image 1

    But when I move far away from the planets the surface loses its lighting. See image 2

    Image 2

    http://www-edu.gel.usherb.ca/coua01/Image1.jpg

    http://www-edu.gel.usherb.ca/coua01/Image2.jpg

    I uspect settings of the depth buffer is to blame.

    Thanks for any answers.



    [This message has been edited by Handkor (edited 03-22-2001).]

  2. #2

    Re: Problem with the depth buffer and lighting

    For those who want to try my program here is a link.

    http://www-edu.gel.usherb.ca/coua01/space.zip

    The arrow keys turns the ship, + and - changes the speed and F1-F6 keys changes the camera position.

    The models are .ASE files and you can edit demo.sol in the data subdirectory to change the environment.

    [This message has been edited by Handkor (edited 03-22-2001).]

  3. #3
    Senior Member Regular Contributor
    Join Date
    May 2001
    Location
    London UK
    Posts
    195

    Re: Problem with the depth buffer and lighting

    Yes, perhaps is it because of the far setting of the depth buffer this happens. Just setting a bigger value should fix it but probably leads to new problems since the precision gets worse. You see far object suddenly disappering in many games.

  4. #4
    Senior Member OpenGL Guru
    Join Date
    Feb 2000
    Location
    Sweden
    Posts
    2,978

    Re: Problem with the depth buffer and lighting

    It's Z-buffer artifacts that appear when the near to far ratio is too big. Move the near clipping plane as far away as possible. Because the bigger the near to far ratio (value of far divided by the value of near) is, the more precision you loose in your depthbuffer.

  5. #5
    Senior Member OpenGL Guru Relic's Avatar
    Join Date
    Apr 2000
    Posts
    2,450

    Re: Problem with the depth buffer and lighting

    If you have z-buffer problems on spheres, than enable back face culling.
    Another reason could be wrong mipmaps. Far away objects use minification with lower levels of detail textures. Maybe some are broken.

  6. #6

    Re: Problem with the depth buffer and lighting

    Thank you all ,ajusting my near far ratio of the depth buffer seems to have worked and I will try backface culling.

    By the way I did not use MipMaps.

    [This message has been edited by Handkor (edited 03-23-2001).]

  7. #7
    Member Contributor
    Join Date
    Jan 2001
    Location
    Toulouse
    Posts
    81

    Re: Problem with the depth buffer and lighting

    Originally posted by Relic:
    ...Far away objects use minification with lower levels of detail textures. Maybe some are broken.
    Is the use of mipmaps determinated by the mag filtering mode (Only when the value is GL_LINEAR_MIPMAP_LINEAR, GL_*_MIPMAP_*,...) ?

  8. #8

    Re: Problem with the depth buffer and lighting

    Enabling Backface Culling was the answer, I increased my far/near ratio and no artifacts appear.

  9. #9
    Senior Member Regular Contributor
    Join Date
    Nov 2000
    Location
    Dunblane, Scotland
    Posts
    333

    Re: Problem with the depth buffer and lighting

    This isn't an image of the day forum but I felt like commenting. The first pic looks good but you have stars appearing infront of the planet which is wrong.
    Reality is for idiots only the best over come it!

  10. #10

    Re: Problem with the depth buffer and lighting

    Actually Tim, it's not a star, if you download the program and move around, you will notice that those are little dust particles that fade in and out around the ship. In a still picture it looks like a star since the dust particles are simply points but it's not an error. To remove the dust particles simply set the dustfield to 0 in the demo.sol file.

Page 1 of 2 12 LastLast

Similar Threads

  1. depth buffer and lighting
    By ale211734 in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 02-04-2015, 02:53 AM
  2. Depth and Lighting problem
    By openglbeginner123 in forum OpenGL: Basic Coding
    Replies: 7
    Last Post: 07-28-2014, 08:20 PM
  3. Depth buffer problem
    By egydev in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 05-19-2010, 06:26 AM
  4. Depth buffer problem ?
    By Vlasko in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 03-08-2003, 07:17 AM
  5. Problem of depth buffer
    By pongkm in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 07-30-2001, 08:44 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