2022.3.12 breaks matrix4x4 override

First reported this for 2023.3.0a8: ShaderGraph Matrix4 Hybrid Per Instance Error

But this bug has now been backported to 2022.3.12 (worked in 2022.3.10 and I haven’t tested .11)

IN-59424

Unfortunately there is a bug in a recent performance optimization that seems to cause this.

As a local workaround, if you are willing to use a modified package, you should be able to edit the UnityDOTSInstancing.hlsl file in the com.unity.render-pipelines.core package, and add the following function around line 517:

float4x4 LoadDOTSInstancedDataOverridden_float4x4(uint metadata)
{
    uint address = ComputeDOTSInstanceDataAddressOverridden(metadata, 4 * 16);
    float4 p1 = asfloat(DOTSInstanceData_Load4(address + 0 * 16));
    float4 p2 = asfloat(DOTSInstanceData_Load4(address + 1 * 16));
    float4 p3 = asfloat(DOTSInstanceData_Load4(address + 2 * 16));
    float4 p4 = asfloat(DOTSInstanceData_Load4(address + 3 * 16));
    return float4x4(
        p1.x, p2.x, p3.x, p4.x,
        p1.y, p2.y, p3.y, p4.y,
        p1.z, p2.z, p3.z, p4.z,
        p1.w, p2.w, p3.w, p4.w);
}
1 Like