Strange 3d rendering issue

Like in topic. Look at this screenshots:

I am rendering 5X5 collection of 16X256X16 chunks here. I can’t get rid of this rendering artifacts and even don’t know what is causing them - any ideas why this happens and how can I fix this?

Edit: Source code of this prototype: https://dl.dropboxusercontent.com/u/67758055/src.zip

Try some mipmapping

I am already using mipmapping, but it doesn’t help:

int texId = GL11.glGenTextures();
        GL11.glBindTexture(GL11.GL_TEXTURE_2D, texId);

        GL11.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, 1);
        
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_CLAMP);
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_CLAMP);

        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST_MIPMAP_NEAREST);
        
        GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, dec.getWidth(), dec.getHeight(), 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, buf);
        GL30.glGenerateMipmap(GL11.GL_TEXTURE_2D);

The same problem with any other mipmap mode (even worse with GL_LINEAR_MIPMAP_LINEAR - black lines at the edges of each distant cube).

Maybe try anisotropic filtering, see GL_TEXTURE_MAX_ANISOTROPY_EXT and glTexParameterf.

Now it looks like this (anisotopic 16x in both cases):

NEAREST_MIPMAP_NEAREST:

LINEAR_MIPMAP_LINEAR:

Edit: if anyone would like to see code and play around with this prototype, here it is: https://dl.dropboxusercontent.com/u/67758055/src.zip. :slight_smile:

Runtime generation of mipmaps varies according to the driver, but usually will just use a simple box filter which results in poor quality mipmaps (particularly with high frequency textures like this). Consider generating the mipmaps offline or manually when you load your texture.

For what you’ve got, you might want to consider fading your mipmaps to a single solid colour when they get small. Also you’ve got quite a contrived test case here - I assume in your actual game you’re not going to have such big expanses of the same high frequency texture viewed from such a large distance.

I think this is the reason why this problem exists, thank you. :wink: