Help with weird artifacting (GL_QUADS and glDrawElements)

Started by joeywatts, June 28, 2012, 19:59:49

Previous topic - Next topic

joeywatts

Hi everyone,

I am having a weird issues with GL_QUADS and glDrawElements. This code works fine on my other linux machine, but has crap performance due to an intel graphics card. I tried running the same code on my hackintosh, and it performs great. There is a problem though. It has these weird artifacts. The farther away you are, the worse it looks:


I tried changing to GL_TRIANGLES (changing the indices also) and that didn't work (it showed no difference).

The code is up here:
https://github.com/joeywatts/WattsWorld

The code for rendering and mesh generating for the chunk is in the com.wattsworld.world.Chunk class.

Does anyone have any ideas?

Fool Running

It looks to me like z-fighting (the accuracy of the z-buffer is too low when further away from the camera). This is usually caused by setting your z-near value too close or by using a 16-bit z-buffer instead of a 24-bit z-buffer.
Try changing the z-near in your code:
GLU.gluPerspective(45f, ((float)width/(float)height), 0.001f, 1000f);

to something more like 0.5f or maybe even 1.0f if you can get away with it. Just beware that you, then, need to keep the camera from getting too close to objects.
Programmers will, one day, rule the world... and the world won't notice until its too late.Just testing the marquee option ;D

joeywatts

Quote from: Fool Running on June 29, 2012, 13:20:36
It looks to me like z-fighting (the accuracy of the z-buffer is too low when further away from the camera). This is usually caused by setting your z-near value too close or by using a 16-bit z-buffer instead of a 24-bit z-buffer.
Try changing the z-near in your code:
GLU.gluPerspective(45f, ((float)width/(float)height), 0.001f, 1000f);

to something more like 0.5f or maybe even 1.0f if you can get away with it. Just beware that you, then, need to keep the camera from getting too close to objects.


Thank you! fixed.