PDA

View Full Version : Problem with the depth buffer and lighting



Handkor
03-22-2001, 12:34 PM
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.
http://www-edu.gel.usherb.ca/coua01/Image1.jpg
Image 1

But when I move far away from the planets the surface loses its lighting. See image 2
http://www-edu.gel.usherb.ca/coua01/Image2.jpg
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).]

Handkor
03-22-2001, 12:56 PM
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).]

mango
03-22-2001, 07:49 PM
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.

Bob
03-23-2001, 02:36 AM
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.

Relic
03-23-2001, 08:45 AM
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.

Handkor
03-23-2001, 08:58 AM
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).]

Sancho
03-23-2001, 09:04 AM
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_*,...) ?

Handkor
03-23-2001, 09:25 AM
Enabling Backface Culling was the answer, I increased my far/near ratio and no artifacts appear.

Tim Stirling
03-23-2001, 09:36 AM
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.

Handkor
03-23-2001, 04:03 PM
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.

Tim Stirling
03-24-2001, 12:34 AM
Sorry, I have downloaded it and it looks good.