GridMap3D cubic tiles have 'seams'

Godot Version

4.3.stable

Question

Hi, I’m creating a Minecraft-like game that uses a GridMap3D with several cubes to create the map. However, when I actually made the map, it seemed that if the character wasn’t up close to the tiles, they would create ‘seams’ in between. I experienced something else like this with the sides of the tiles: when rotated away from the camera, the sides of the cubes seemed to automatically compress the texture. I was fine with this, as the player won’t spend a lot of time looking at thew sides of blocks, but the other issue is still pressing. For some context, my tiles are cubic MeshInstance3Ds with CollisionShape3Ds inside of StaticBody3Ds, and my textures are 4800X6400 pixels. Has anyone experienced this before, and can anyone help?

Do you have mipmapping turned on? What’s your texture min/mag filter? Are you using atlas textures, or per-voxel textures?

My textures are per-voxel, but other than that I’m unsure.

You can get seams in the distance (and at angles, which is essentially the same thing from the hardware’s point of view) from blending between texels. For example, if you have a texture that has a black square surrounded by white, you can set your texture coords so that face-on at 1:1 scale your quad is entirely black, mapping the square perfectly to the quad.

Depending on your texturing filters, though, if you move that quad around the texture sampler might pull in some of the surrounding white; the coordinates it’s sampling from may wind up pulling in surrounding texels and blending them to get color fragments.

The same thing can happen with any color, including alpha. Even if your textures go right out to the edge of the texture page, depending on the repeat and border modes you could wind up getting texel samples either from the other side of the texture or from the border.

4800X6400 Textures?!? Gridmaps for voxels?!?!?
Use Zylann’s voxel tools. Gridmaps will slow you down.
Screenshots would be helpful.

I have a screenshot here:


As you can see, the stone pillar in the background has some seams between the blocks.
However, in this screenshot:

you can see the stone blocks are seamless.
Also in case it helps, here is my MeshLibrary scene:

Is this a problem with the textures, or compression, or is there a setting to fix this?

Are the textures built in to the models, or are they separate? If they’re separate, can you show the import tab for them? Or the inspector?

Sure thing, the textures are separate. I made the block model in Blender to create a custom UV map so that I only needed one model for all the full blocks.
Here’s the import tab:

Ok, you’ve got mipmaps on, that’s good.

What I suspect is happening is you’ve got a min/mag filter set to something other than “nearest”. Which is mostly what you want; with “nearest” you’ll get crunchy edges and aliasing. The filtering can produce edge artifacts, however, if you don’t take some precautions.

A potential easy fix for this is: Around each block texture in your image, put a four pixel border that’s a copy of the closest pixel in the block texture. That way, if texture sampling winds up blending with texels that are off the edge of the block, it will pull them from that border. I’m suggesting a four pixel border because that should cover you for three mip levels, but you can go higher if you’re seeing problems at smaller sizes.

1 Like

OK, thanks for the help :slight_smile: I’ll try that out