- Home /
White lines between blocks in voxel terrain
Hello. I am having a problem. I am beginner with unity3d and I am trying to create voxel terrain generator.
When I render some chunks there are white lines between cubes.
I have set filter mode to POINT.
This lines are only visible in game, not in unity editor.
What is the cause?
Here is screnshoot how it looks in game:
and here how it looks in unity editor:
Thanks for any help!
To rule out any graphics settings have you tried changing from fantastic to fastest? Its in Edit -> Project Settings... -> Quality
Thanks for reply. When I switched from "ultra" to "medium" then lines disappeared. How to avoid this texture glitch on quality better than medium?
I have noticed that it is caused by anti aliasing but.. why?
I have changed renderer path to "deferred" but now anti aliasing is completly not working. :(
Answer by Ymrasu · Feb 15, 2019 at 02:05 PM
Anti aliasing blends the edges of textures together to attempt to smooth out harsh lines. That is why the edges of your voxels have the white lines, they were blended with a white or transparent color.
I think the way to fix it while keeping anti aliasing on was to adjust your UV mapping. Instead of say going from 0f to 1f of the texture you start at 0.01f to 0.99f so it blends with the remaining pixels of your texture, or something along those lines. Though I could be remembering wrong.
I have texture atlas that holds 8x8 (pixels) block faces textures. I am mapping all uvs using this simple method: https://pastebin.com/WPST7bbF So, for example, if atlas has size 16x16, then it will grab 4 textures 8x8. Is there any mistake in this code? Thank you for helping.
float offset = 0.01;
Vector2[] uvs = {
new Vector2(uv1x - offset, uv1z - offset), // top-right
new Vector2(uv2x - offset, uv2z + offset), // bot-right
new Vector2(uv3x + offset, uv3z + offset), // bot-left
new Vector2(uv4x + offset, uv4z - offset), // top-left
};
You can adjust the offset to see how it affects the texture on the blocks. It moves the vertices a little closer to the center of the texture your grabbing. If you don't see any improvement, then this wasn't really an issue.
Thank you! Offset completly fixed this problem. You were 100% right, it was uvs problem. Your code that you pasted had mistake with correct uvs order (it should go antyclockwise). I have also modified offset to 0.0001 because 0.01 was far too big.
new Vector2(uv1x - offset, uv1z - offset), // Top right
new Vector2(uv2x + offset, uv2z - offset), // Top left
new Vector2(uv3x + offset, uv3z + offset), // Bot left
new Vector2(uv4x - offset, uv4z + offset), // Bot right