Uploaded image for project: 'Minecraft: Java Edition'
  1. Minecraft: Java Edition
  2. MC-262933

Enchanted objects with coinciding planes exhibit Z-fighting

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • None
    • 1.19.4, 1.20 Pre-release 5, 1.20 Release Candidate 1, 1.20, 1.20.1, 1.20.3 Release Candidate 1
    • Community Consensus
    • Rendering, Textures and models

      The bug

      If a model which contains faces which are coplanar and intersect each other is enchanted, Z-fighting can be seen where they intersect, even if the textures the model uses are otherwise mapped identically such that no Z-fighting would occur between the textures themselves.

      How to reproduce

      1. Give yourself an enchanted wall by using the command provided below.
        /give @s minecraft:cobblestone_wall{Enchantments:[{}]}
      2. Look at it as an item from below.

      Expected results

      The enchantment glint would look normal on the bottom, like all other faces.

      Actual results

      Flickering is evident where the two constituent cuboids coincide.

      How to fix

      It appears that the enchantment glint will always appear the same at a given position in the texture, regardless of where the texture is used. The Z-fighting appears to occur due to the glint being applied twice at the provided position. I'm not sure how feasible it would be to compute an outer shape for each model and have the glint applied to that, as opposed to applying it directly to texture planes.

      While this issue could probably be "resolved" by making the wall item model use three non-intersecting elements instead of two intersecting elements, I'd recommend against this since rendering more triangles than are needed carries with it a rendering debt. This would also not resolve the issue at all - it'd just mask it for enchanted walls and would not stop it from affecting countless custom models.

        1. 2023-05-24_18.30.24.png
          2023-05-24_18.30.24.png
          174 kB
        2. 2023-05-24_18.30.44.png
          2023-05-24_18.30.44.png
          236 kB
        3. 2023-05-24_18.30.47.png
          2023-05-24_18.30.47.png
          244 kB
        4. 2023-05-24_18.30.48.png
          2023-05-24_18.30.48.png
          241 kB
        5. 2023-05-24_18.30.55.png
          2023-05-24_18.30.55.png
          167 kB
        6. 2023-05-24_18.30.58.png
          2023-05-24_18.30.58.png
          168 kB
        7. 2023-05-24_18.31.12.png
          2023-05-24_18.31.12.png
          210 kB

            Unassigned Unassigned
            Awesoman3000 Connor Steppie
            Votes:
            4 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              CHK: