AABB derived render glitches

Godot Version

4.5.1

Question

I have got a rendering bug. In my original code, all of chunk multimeshes have had an equal AABB.

part of the code:

void RenderBlocks::set_position_mesh(const godot::Vector3 &pos) {
  opaque.mm_instance->set_position(pos);
  const auto size = Vector3{Chunk::CHUNK_SIZE, Chunk::CHUNK_SIZE, Chunk::CHUNK_SIZE};
  
  // AA BB AABB
  opaque.multimesh->set_custom_aabb({Vector3{0, 0, 0}, size});

  liquid.mm_instance->set_position(pos);

  liquid_surface.mm_instance->set_position(pos);

  liquid.multimesh->set_custom_aabb({Vector3{0, 0, 0}, size});
  liquid_surface.multimesh->set_custom_aabb({Vector3{0, 0, 0}, size});

  furnitureMmesh.mm_instance->set_position(pos);
  furnitureMmesh.multimesh->set_custom_aabb({Vector3{0, 0, 0}, size});

  wildPlatntsMesh.mm_instance->set_position(pos);
  wildPlatntsMesh.multimesh->set_custom_aabb({Vector3{0, 0, 0}, size});

  grassBordersMesh.mm_instance->set_position(pos);
  grassBordersMesh.mm_instance->set_custom_aabb({Vector3{0, 0, 0}, size});

  nightMesh.mm_instance->set_position(pos);
  nightMesh.mm_instance->set_custom_aabb({Vector3{0, 0, 0}, size + Vector3{0, 0, 0}});
}

As you can see, all stuff with transparent shader has glithed after some chunk border

subtracting one does 100% glitch

nightMesh.mm_instance->set_custom_aabb({Vector3{0, 0, 0}, size + Vector3{0, -1, 0}});

adding +1 does fix it for me.

nightMesh.mm_instance->set_custom_aabb({Vector3{0, 0, 0}, size + Vector3{0, +1, 0}});

so, my questions are: “Does anybody know what is happening? Why does this happen? Where can I read stuff?“ I only intended using AABB for culling chunks outside of the view

You might want to elaborate on what exactly you consider a rendering bug as none of us here knows which parts of the screenshots do match your expectations and which do not.

Otherwise, I imagine that if changing the box size fixes it, the size must have been wrong initially.

2 Likes

Oh sorry, I shall clarify then: on the first screenshot there are color difference between up and down parts. Down part is glitched. All second picture is glitched.

I tried to set approximate BBOX (equal for every chunk mmesh).

I find it weird, that BBOX influences not only frustrum culling, but also rendering order (I guess?) which is glitching for transparent stuff with equal bboxes?

Explain please, how can I tell wrong size vs right

Well, it’s still hard to tell what is what in the screenshots. It looks like you have sort of a transparent tilemap, but I have no idea what the areas of different color are, that have the lines between them. It looks like they overlap where they shouldn’t, but since I know nothing of how the cells are positioned or sized or blended or anything it is hard to begin guessing what might be wrong and how bounding box is affecting it.