It is not a problem of textures but a problem of geometry precision.
His problem do not arise from texture resolution or compression or anything, but from " ground is made of several chunks".
Try to increase the size of your chunks by 0.01 units, I think it will solve your problem.
It seems to work, but not totally…
i’ve first tried by setting the scale to 2 instead of 1 but the lines were still here.
Then i scaled the planes to 1.01 and now there are much less lines appearing but there are still some.
Weird isn’t it ?
It looks better at scale 1.001 but still not perfect.
PS: i’ve also set the texture atlas to Advanced and unchek Generate MipMaps. No success.
The problem with your approach is with the camera resolution in rendering, which is not infinite.
You would probably cut off a lot of this problem by setting antialiasing on, but of course that’s not the right solution on this type of game.
Try dimensions 1.1, that would definitely fix the problem at a distance, but the risk is when zoomed in you could see some Z buffer fighting.
By the way, I think you are right in that there is also some texturing problem.
It’s not a compression or quality problem thought, but a UV mapping problem.
I think you could solve this totally by moving the vertexes of the squares in the UV mapping INSIDE the coloured squares, NOT at the tip of them.
This because the MIPMAPS lower the resolution of the texture when you zoom out, causing bleeding of adjacent colours.
You may try a very fast thing: set the texture type to ADVANCED and disable the MIPMAPS generation!
This will leave the texture without low resolution versions, and force the graphic board to render it full resolution.
It cuts off a bit of performance but it should also cut off this problem completely.
And btw you can maybe reset the tiles to size 1
It does indeed look like a texture problem, not a problem with the planes not lining up perfectly. As you can see, the lines will have the color of the, in the texture, neigbouring color. If it was a matter of aligning, all lines would be similar in colors.
So…it MUST be precision problems in the uv’s, where your individual planes will pick up color from a neighbour. Now, as far as I can see, this is always picked upwards in the texture, so, for instance, the brown square will always get a green line on top of it, a light yellow square will always get a light blue line above it. And it always happens in the y direction, not the x.
And as you use point filtering, it can’t be due to interpolation.
Anyways, the only thing I can come up with, are the fact that you are dividing by the texture width and texture height. But as you want the uv’s the be placed at the corners of each color, it may be a wrong way to do it. Try to imagine a picture only 44 pixels in size. And then count the corners of pixels. It will be a 55 texture now, in relation to corners. Just as the Terrain heightmap is 513*513 in size. And you don’t want to use the middle of the pixels. And the only reason this only shows in the y direction, could be due to the fact, that the y direction is taller, and therefore your rounding procedure will go just that one pixel wrong, where as the x direction, it doesn’t show up.
right now it seems to work better with a different uvs order:
uvs.Add(min + new Vector2(pixelDims.x * 0.0f, pixelDims.y * 0.0f));
uvs.Add(min + new Vector2(pixelDims.x * 1.0f, pixelDims.y * 0.0f));
uvs.Add(min + new Vector2(pixelDims.x * 1.0f, pixelDims.y * 1.0f));
uvs.Add(min + new Vector2(pixelDims.x * 0.0f, pixelDims.y * 1.0f));
instead of
uvs.Add(min + new Vector2(pixelDims.x * 0.0f, pixelDims.y * 1.0f));
uvs.Add(min + new Vector2(pixelDims.x * 1.0f, pixelDims.y * 1.0f));
uvs.Add(min + new Vector2(pixelDims.x * 0.0f, pixelDims.y * 0.0f));
uvs.Add(min + new Vector2(pixelDims.x * 1.0f, pixelDims.y * 0.0f));
did not solved it.
: no success
How ?
I’ve made a test with a single texture (a colored cube) ==> no lines. So i think you’re right, it must be an uv problem. But if it’s the case i don’t understand why lines appear and disappear depending on zooming.
Vector2 pixelDims = new Vector2(8f / (float)texture.width, -(8f / (float)texture.height));
Becuase the same problem would exist here, I presume. You need to look at the texture noth in terms of the number of pixels it has in width, but in the number of pixel corners it has.
So try:
Vector2 pixelDims = new Vector2(8f / (float)(texture.width+1), -(8f / (float)(texture.height+1)));
Try both with both my solutions, and with only this. I don’t have the time to really read all your code, to understand what goes on, so this is just wild shots…
PS: Note that it cannot be a chunk connection problem, i may use any number of chunks of any size, for instance 33 chunks of 4949 square, it has no impact on the lines problem.
Instead of using a texture to color each of the squares, maybe you can try using vertex colors instead, with a simple shader that just flat-shades whatever the vertex color is. Then you don’t have to use any textures at all, and you can also use any color you want without having to add it to that atlas.
That’s an interesting idea.
Actually i plan to use a bit more detailed textures for the ground but there will be one time where i will have to learn how to write shaders because the next step will be to find a way to make some squares darker than others in order to build a FOV system.
It directly leads to an important parallel question ====> is it possible, using shaders, to darken such a plane square by square, while still using textures ?
Very very very easy: make another darker texture, create another material with this texture, and assign this material to the tiles you want to make darker.