I have an oldass game that I want to remaster, I have used 3D custom tiles to build up rooms dynamically from the data that is sent from the server, these tile pieces share same material and texture, also whole map is combined into a single mesh too, so far I’ve tried dynamic verticle welding but that didn’t do anything good plus ruined UV mapping, or it was just my dumbieness to not be able to make it work.
Until recently, almost everything was turned off, light, shadows, antialiasing, texture filtering etc. for a retro feeling. Then I decided to fix things up by starting from the mesh error and post proccessing. On the editor and new phones, tearing seems to appear only when camera is set to 0, 90, 180 and 270, but on some old or non-popular devices, they can be seen from every angle. I have checked 3D models themselves if I accidentally make their size, they seem to be correct, uv mapping is correct with its verticle position values too. Is there a way to correct this?
There is but first you have to find out what’s happening.
Is the geometry absolutely touching together? If not, make sure it touches or overlaps.
Is the texture truly clean at the edges? If not, check your UV coords and check your texture filtering. Remember if you zoom out, lower mipmap levels will require more “fudge room” at the edges, if you have put your UVs far to the outside of edge texels.
I have checked coords of every single vertex on both 3D model and the UV map, they are perfectly aligned. Texture is loaded from server in runtime and 3D model has no compression on import phase.
As @Kurt-Dekker said, you need to have bleed padding around your UV maps. The edges are caused by rounding errors causing an adjacent tile’s texture data to show up on your tile. Notice how the color of the seams matches your green “grassy” tile texture. Add an extra pixel of padding around each of your tile textures so that when the bleed happens (it will happen) the colors match perfectly and don’t show it.
Ah, got it… Thats unfortunate for me because of the thousands of uv mappings. I guess thats kind of what you don’t do with your next game, rather than current one… like I can auto-pad textures in the atlas with a few lines of code but no clue for remapping the uv for each model.
There still might be some cleverness you can do procedurally… are these organized using “trim sheet” style texture maps, eg., like specific square areas for each texture?
If so you could recognize UVs at are near an edge and belonging to triangles over DIRT versus over GRASS, and then know to move the UVs a little bit closer to the dirt side of those tile divisions.
Funny, this topic was just covered by Grant Abbitt here, but his assumption is of no more than 4 levels of mipmapping… not sure how realistic that is with games where the floor tile might get quite far from the camera… but at least it’s a thing to think about:
Each tile piece is a seperate custom 3D model, some of the models use completely random mapping, such as a sapling pot sharing same texture for the leaves with the bushes pot, but with different kind of mapping. I am aware of that compression issue Grant mentions and I used that in my previous game while uv mapping models with some margin before painting them in substance painter. I thought no compression method, point filtering, mipmap 0, clamp textures would fix it but nope, this somewhat felt different than it.
The strange thing that I don’t understand is these seams seem to be happen completely randomly and only has 1 pixel wideness regardless of the texture you use and their distance to the camera, sometimes seams can be seen tiles nearby, sometimes far away… Here is another full resolution screenshot that I replaced whole atlas with an image that has a single pixel with a random color for each corresponding tile texture.
as you see, whole tile piece is a single color and the red seam that is pointed with the white arrow only appears when camera has a deterministic position and angle, so this line only appears for a millisecond while you are moving and %90 of the time you dont see any seams, I spent a few minutes to get the camera to the right angle to have a seam on my screen.
I wonder if shader has something nasty behind causing this, because whole atlas is 16x16 image and bleeding only happens on my screen with the wideness of a single pixel.
It’s “random” because it’s floating point inaccuracy, and it’s always one pixel wide because the issue stems from the fragment shader in texel space, not world space.
You don’t necessarily need to add padding to every single one of your textures, just the ones that are clipping poorly. Basically, if you don’t see an issue, you don’t need to change anything. I’m surprised that your UVs and tile meshes are manually laid out for an entire world, but learn a bit of blender scripting and scrunch them down. Shouldn’t be too difficult!
Or, post process the mesh inside Unity and remap the UVs to a different texture atlas that has padding.
Actually that’s probably the most straightforward way.
Your drawcalls may (will?) go up however.
It’s probably the simplest and easiest to test as you go too.
I guess it kinda depends on how clean your mapping is. The only thing that would put a total kibosh on that plan would be if you had degenerate coordinates, little “twisted” piece of geometry that might be insignificant in size but either prevent pulling apart of other geometry, or back-cross it in weird ways leading to more texture glitches.