Hi 🙂
I use multimesh to draw grass in my ,,game". The problem is that the multi-mesh grass looked awful because something wrong with depth draw.
Everything overlapping with everything and I really don't know how to fix this.
I tried to put the grass next to each other manually without multimesh and it looks fine.
It happens only when the grass is generated by multi-mesh node.

Problem:


Material settings:

I tried to use different depth draw modes and play with all values here but I didn't find a solution.
Does anyone know what to do with it?

Godot version: 3.5.1

Thanks and have a nice day 🙂

  • When you use a multi mesh (or at least multi mesh instance, I think it's the same) it batches the calls for all objects into one draw call. Transparent meshes don't read/write to the depth buffer normally, then are simply draw in back to front order. So if you are batching, they are drawn by the GPU in essentially a random order (due to multi processing on the GPU) and thus depth will not be correct. Alpha scissor does write to the depth buffer. It is the same as opaque geometry, it just uses a 1-bit alpha channel (either visible or not visible, which is why it is rough or pixelated on the edge). In this way, you can still draw in random order and have the depth be correct. I don't think it will work otherwise, at least without removing any performance benefit of batching the calls.

You have to use alpha scissor, don't use transparency option, and put the pipeline on opaque pre-pass. It will look a little more pixelated around the edges, but alpha blending with multiple layers almost never works right.

    cybereality
    Yeah.. I want to avoid doing it like this because it's really look pixelated, but if there is no other option then well. What do you mean with ,,put the pipeline on opaque pre-pass?" I don't get it 😃

    Did you try it? Select "Use Alpha Scissor" in Parameters, "Opaque Pre-Pass" in Parameters, and in Flags, make sure "Transparent" is not selected.

    Yes I tried it. Thanks. I did all of that. It fix it but it looks like antialiasing not works on it anymore.

    When you use a multi mesh (or at least multi mesh instance, I think it's the same) it batches the calls for all objects into one draw call. Transparent meshes don't read/write to the depth buffer normally, then are simply draw in back to front order. So if you are batching, they are drawn by the GPU in essentially a random order (due to multi processing on the GPU) and thus depth will not be correct. Alpha scissor does write to the depth buffer. It is the same as opaque geometry, it just uses a 1-bit alpha channel (either visible or not visible, which is why it is rough or pixelated on the edge). In this way, you can still draw in random order and have the depth be correct. I don't think it will work otherwise, at least without removing any performance benefit of batching the calls.

      cybereality
      Thanks for this great explanation! I really appreciate that! Then.. I think solved 🙂 thanks for you patience.