I’m making a Minecraft-type voxel engine (ok no surprises here, I guess), and have textures packed in an atlas. I’ve made a shader which then chooces the right tile according color alpha channel. When there are no mip maps it works all too well, but with mip maps there’s strange bleeding at the edges of blocks. For test purposes I’ve colored each mip map level differently. At the image, the lines you see are from level 5. Any ideas what would cause this?
Here’s the same view with actual textures (problem isn’t as striking, but still persists). For testing, textures are from Minecraft texture pack “Faithful” by Vattic.
Thanks for reply. Having read that, and just about every other article about voxel engines I’ve found I am already using greedy meshing, figured per tile mip mapping all right and tried to add the huge bleeding area (quadrupling texture size) - it kind of solves the problem, as no other tile shows up, but strange seams of higher mip map persist and they’re pretty ugly. Here’s a zoomed up image with the seam highlighted.
Ah I know what that is!!
I think atleast…, since the uvs are “jumping” from one part of the texture to another place (instead of normal wraping) it thinks it needs to use a lower mip-mapping level…, got the same problem myself in a custom shader…,
you can use your own values for the uv-delta (I think it’s called)
Thank you, that seems to be the solution. I gave the article a quick read, but so far I didn’t find the equivalent function for texture2DGrad in cg. I’ll look more to it after work.
EDIT: Ah, it is simply tex2Dgrad, but editor just didn’t highlight it properly. Still gotta figure those delta values somehow
I think you can just use tex2D or Texture2D directly without the grad…, I’m not sure what the differnce is exactly…
I definitely used tex2D in my shaders…
How exactly did you solve the problem in your shader? Tex2Dgrad lets you use your own delta values, which ensures correct mip level is chosen. Normal tex2D makes this calculation for you, but in this case, chooses the wrong mip map at the seams.
There’s still some seams between chunks (altough these chunks consist one mesh)… I’ll see if I can work it out myself. Other problem, which is still harder to fix is when mip maps get too small to contain tiles
Here’s solution, but it’s been there since 2013: http://feedback.unity3d.com/suggestions/maximum-mipmap-level
regarding tex2D vs tex2Dgrad…, For me it seems tex2D can take two more values and thus behaving exactly like tex2Dgrad…, I’m not sure if there’s any difference then…, maybe it’s good to use tex2Dgrad for claritys sake