#Voxel Rendering issue

1 messages · Page 1 of 1 (latest)

lone tapir
#

Ok so, the issue, of course, is that there appear to be strange lines appearing in between the voxels of my game. If you'd like a reference to the original code, as I'm borrowing it from a tutorial, you can view it at https://github.com/b3agz/Code-A-Game-Like-Minecraft-In-Unity/tree/master. In any case, the issue is only apparent in game view, and if you pause the game, the lines disappear. At first I suspected it was a texture issue, but as it appears normal when pausing the game, I'm moreso starting to suspect that it's a floating point error. This is backed up by the fact that padding the textures out makes the lines go away, though I can't use it since it greatly screws up repeating textures.
void AddTexture(int textureID)
{
float y = textureID / VoxelData.TextureAtlasSizeInBlocks;
float x = textureID - (y * VoxelData.TextureAtlasSizeInBlocks);

x *= VoxelData.NormalizedBlockTextureSize;
y *= VoxelData.NormalizedBlockTextureSize;

y = 1f - y - VoxelData.NormalizedBlockTextureSize;

float padding = 0.0000f;

uvs.Add(new Vector2(x + padding, y + padding));
uvs.Add(new Vector2(x + padding, y + VoxelData.NormalizedBlockTextureSize - padding));
uvs.Add(new Vector2(x + VoxelData.NormalizedBlockTextureSize - padding, y + padding));
uvs.Add(new Vector2(x + VoxelData.NormalizedBlockTextureSize - padding, y + VoxelData.NormalizedBlockTextureSize - padding));

}

#

Since it appears normally in the paused game view, I'm thinking that the textures themselves are fine and there are no issues with unclamped textures or filtering or mipmaps (all of which are disabled)

#

In terms of actual drawing, the chunk itself is a single mesh renderer and mesh filter.

#

I'm also of the belief that the UV's aren't the issue, since they're just set to all the corners, which just use 1's and 0's. I doubt there can be any imprecision there.

tidal pelican
#

A bit busy at work now. Will have a look when have time.

If you could share the project itself, I could also look at it on my PC when I get home.

lone tapir
#

When do you get off work? It's about 1 am for me, and I intend to clock out in about an hour

#

I'm wondering how I can send the ~2 gb project file to you. Oh actually, you could probably just look at this link, https://github.com/b3agz/Code-A-Game-Like-Minecraft-In-Unity/tree/master, since my chunk generation code is largely untouched. The only thing I've changed is adding a mesh collider to every chunk since I'm using a different player gameobject than this project

lone tapir
#

I see. Do you want to DM me, and I can respond when I wake up?

tidal pelican
#

No, it's fine here.

lone tapir
#

alright

lone tapir
#

Yeah, it's still there in the original version. Anyways, the specific version I've pulled from is Episode 10.

#

If you're curious, the specific version of unity I'm using is 2022.3.12f1

tidal pelican
tidal pelican
#

Yeah, to be fair, this implementation is very prone to floating point errors.

tidal pelican
#

Seems to be caused by antialiasing.
The GPU would try to sample multiple positions to smooth out edges. With a tightly packed texture atlas like the one used in the project that causes other textures to bleed into the face.
Ideally, you'd have gaps between different textures in a texture atlas.

#

With antialiasing disabled:

lone tapir
#

Oh neat, thanks

#

How do you disable the anti aliasing? Is it a texture specific thing or some sort of project wide setting?

lone tapir
lone tapir
#

oh shoot I found it and it works