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

Using a Matrix3x3 or Matrix2x2 as a Shader Uniform fails to parse

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • None
    • 1.17.1
    • Community Consensus
    • (Unassigned)

      adding this line to the uniforms section of the shader json causes my custom shader to fail to parse:

      { "name": "NormalMat", "type": "matrix3x3", "count": 9, "values": [ 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0 ]}

      This is caused because the size of the array used to set the uniform has a minimum size of 16:

      This float array is then passed into Uniform#set(float[] values), which assumes that the array is the right size for the FloatBuffer used to store the values.

      This can be fixed by either changing the default size of the array, or limiting the number of copied values into the buffer. The simplest change is to change line 255 in the image above to the following:

      floatBuffer.put(src, 0, count);
      

            Unassigned Unassigned
            OroArmor Eli Orona
            Votes:
            7 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              CHK: