There are white little dots between blocks at random places, mainly at very near blocks. They disappear when I move the mouse and change the view direction.
I use Vertex Arrays with glVertexAttributePointer to send the data directly to the shader. The shader only adds some fake light based on the face direction and draws the pixels.
What could be the reason for the small white artifacts?
Chunk render code:
public void renderChunk() {
glPushMatrix();
glTranslatef(pos.x*world.chunkSize.x, 0.0f, pos.z*world.chunkSize.z);
glBindBuffer(GL_ARRAY_BUFFER, vao_id);
glVertexAttribPointer(world.game.positionAtt, 3, GL_FLOAT, false, 32, 0);
glVertexAttribPointer(world.game.normalAtt, 3, GL_FLOAT, false, 32, 12);
glVertexAttribPointer(world.game.texCoordAtt, 2, GL_FLOAT, false, 32, 24);
glDrawArrays(GL_TRIANGLES, 0, arraySize / 8);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glPopMatrix();
}
Vertex Shader:
attribute vec3 in_position;
attribute vec3 in_normal;
attribute vec3 in_texcoord;
varying vec2 texture_coordinate;
varying vec3 normal;
void main()
{
gl_Position = gl_ModelViewProjectionMatrix * vec4(in_position, 1.0);
normal = in_normal;
texture_coordinate = in_texcoord;
}
Fragment Shader:
varying vec2 texture_coordinate;
varying vec3 normal;
uniform sampler2D texture;
void main()
{
float add;
if (normal.x == 1.0 || normal.z == 1.0) {
add = 0.65;
} else if (normal.y != 1.0) {
add = 0.8;
} else {
add = 1.0;
}
gl_FragColor = texture2D(texture, texture_coordinate) * add;
}
Enlarge the image by click it to notice the artifacts.
