Hi guys. I'm working on a 2.5D project I think is called. Basically I'm amazed with MultiMeshInstance3D performance and I just need it for my project to handle hundrerds of tiles and animations. So I ended up making my 2D game in 2.5D so I'm able to use them.

So I'm using shaders to order my sprites in the Z axis. The thing is that godot is pretty picky with this. See my examples:

So in this example I have divided my map in chunks and if I just load one chunk things seem pretty ok. I decided just to order my tiles in the position in Z axis I need them so I gave them Z values like 0, 1, 2, 3, 4, 5, 6 and so on. So each sprite is little up in relation to each other so everything works fine.

The problem starts when I render more than one chunk. See red zones.

This error makes sense because the left part of the chunk have lower values than the right part so the right part of the first chunk has Z values higher than the left part of the second chunk.

So I thought hey lets give them a value based on their real X , Y, Z coord because it will alwais give me numbers in ascending order like 0,1,2,3 but in a higher range and It does!!! So what is the problem ?

Z Fighting.

Even with one chunk and values in ascending order but no 0,1,2,3 etc but:

z_pos_i: 1355700 tile_coord: (1250, 1050, 7, 0)
z_pos_i: 1365700 tile_coord: (1251, 1050, 7, 0)
z_pos_i: 1375700 tile_coord: (1252, 1050, 7, 0)
z_pos_i: 1375710 tile_coord: (1252, 1050, 7, 1)
z_pos_i: 1385700 tile_coord: (1253, 1050, 7, 0)
z_pos_i: 1385710 tile_coord: (1253, 1050, 7, 1)
z_pos_i: 1395700 tile_coord: (1254, 1050, 7, 0)
z_pos_i: 1395710 tile_coord: (1254, 1050, 7, 1)
z_pos_i: 1405700 tile_coord: (1255, 1050, 7, 0)
z_pos_i: 1405710 tile_coord: (1255, 1050, 7, 1)
z_pos_i: 1415700 tile_coord: (1256, 1050, 7, 0)
z_pos_i: 1415710 tile_coord: (1256, 1050, 7, 1)
z_pos_i: 1425700 tile_coord: (1257, 1050, 7, 0)
z_pos_i: 1425710 tile_coord: (1257, 1050, 7, 1)
z_pos_i: 1435700 tile_coord: (1258, 1050, 7, 0)

The engine says, Hey those are pretty big numbers and I don't knwo what to do .

And here I am I have no clue on what to do. I thought on just to make a list of all the things I have to render and give them values like 0,1,2,3 etc and every time I load or unload a chunk re order everything but in my mind it is not performant enough. So I'm here asking for help if someone have faced a similar thing.

I have read that I should play with near and far of the 3D camera but I had no luck with it.

This is a very big map like 100k tile x 100k tiles x 15 floors.

  • xyz replied to this.

    Nuelma Use smaller increments and/or keep z values near zero by sliding all the values when chunks are swapped.