Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm making a voxel game in XNA, and have filthy visual artifacts on long distances.

I use 2048*2048 atlases.

I'm already using mipmaps and 16x anisotropic filtering.

I've read this blog post, but I'm not quite sure that this is the problem.

This is how it looks like: Angle enter image description here

UPD:

The atlas I'm using looks like this:

Atlas

The topmost left square is used on the screenshots. I'm using XNA Content Processor mipmap compiler to generate mipmaps.

Every cube on the screen is separate, there is no gigantic cubes.

Does anybody have a clue what might it be?

share|improve this question
1  
i dont know how you have made your grid, but in the distance it will create thees artifacts. due to the same reason for why you use mipmaps. –  Tordin Jul 17 '13 at 8:11
2  
Yes, can you tell us about the geometry. It is 1 or a few big squares with repeating textures, or is each square we see a separate square? Can you show us the exact texture you use. At first glance it looks like your mipmap generation might be screwed. But it's hard to tell. –  DaleyPaley Jul 17 '13 at 8:57
1  
The standard way of generating mipmaps is to average 4 texels for each subsequent layer. The problem with atlases is that the tiles begin to bleed into each other at lower levels. That might be what's causing it. You may have to pad your tiles, modify the UVs like I suggested, or write your own mipmap generation routine to take the atlas into account. –  DaleyPaley Jul 17 '13 at 9:24
1  
@DanielExcinsky No, what you are doing is shifting the whole tile by half a texel to the right and down, which will make things worse as the lower right edge with intrude more into adjacent tile. It really should be done in the generation of the UVs: minuv += halftexel; maxuv -= halftexel (for each quad). But anyway, you still might get problems with mipmapping (see my comment above) –  DaleyPaley Jul 17 '13 at 9:27
1  
@DanielExcinsky If you look here: opengl.org/sdk/docs/man/xhtml/glTexParameter.xml you can find some mipmap level controls: GL_TEXTURE_MIN_LOD, GL_TEXTURE_MAX_LOD, GL_TEXTURE_MAX_LEVEL, GL_TEXTURE_LOD_BIAS, etc. Maybe playing around with those could help too –  DaleyPaley Jul 17 '13 at 9:30
show 4 more comments

1 Answer 1

up vote 3 down vote accepted

This problem happens because you're mixing atlasing with mipmapping. Don't (naively) do this.

I've previously explained it in here, and with more detail in here.

In most cases, you either mipmap, or you atlas. For your case, you most likely want to mipmap instead of atlasing (which is most useful in 2D, not 3D)

If you must atlas, then be prepared to build your mipmaps manually, and do filtering and wrapping manually like it's explained on the article you showed.

share|improve this answer
    
Thank you! Actually, DaleyPaleys suggestions in comments and your answer here already have lessened the problem, but it still exists. I absolutely have to use atlases, so I will continue trying. I haven't yet tried wrapping each texture in atlas in 1px border, and the solution in the 0fps blog post. –  Daniel Excinsky Jul 17 '13 at 13:29
    
And, one more problem I have, is that in Direct3d 9 Sampler type there is no such thing as MinLOD, which could've helped a lot, I think. –  Daniel Excinsky Jul 17 '13 at 13:36
    
@DanielExcinsky: Why do you absolutely have to use atlases? Is this some kind of homework assignment? –  Panda Pajama Jul 17 '13 at 14:34
    
No, I have an option for players to draw texture for cube side, texture size is 32x32. So if they drew, say, 2000 textures, I think it would be incovenient to send to GPU 2000 textures 60 times per second, so I pack textures into the bunch of atlases and send them to GPU instead. But maybe I am wrong, actually I haven't tried it in practice. –  Daniel Excinsky Jul 17 '13 at 17:10
1  
You don't send all the textures to the gpu each frame.And even if you did, there's hardly a difference between sending one large one and many small ones, as the amount of information you're sending is quite the same. What you will be saving is in render state changes, but even if you're drawing all 2000 textures every frame, I think modern gpus can handle it without a sweat. Do not "optimize" before even knowing if it is actually going to be an improvement, and that means profiling. The world well be a better place once everybody understands that most "optimizations" are actually unnecessary. –  Panda Pajama Jul 18 '13 at 2:05
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.