non-square matrices not supported error

Hello all,

I’ve been trying to build my project for both Android and iOS and have hit a very funny issue with my vert/frag shader that I’ve not run into until the last update. I’m getting the errors:

  • Shader error in ‘Water/sphereProjectWater’: ‘’ : non-square matrices not supported (4x1) at line 185 (on gles)
  • Shader error in ‘Water/sphereProjectWater’: ‘’ : unsupported matrix constructor requested (4x1) at line 185 (on metal)

In relation to the code snippet that handles the lighting and object rotation within the shader. The normal is the mesh vertex normal so there’s nothing fancy there:

(68) uniform float4x4 _globeLightRotation;

(185) o.lightnormal = mul(_globeLightRotation, o.normal.xyz);

Any help would be highly appreciated! I’ve tried pretty much everything I can think of, so it’s time to ask for help!

You’re attempting to apply a float4x4 to a float3, you have to do a float3x3 with a float3 or a float4x4 with a float4.

Try:
o.lightnormal = mul(_globeLightRotation, float4(o.normal.xyz, 0.0));

Desktop drivers / compilers are smarter about this and automatically convert your line to something equivalent to the above, but stricter compilers just tell you you’re doing it wrong (with a somewhat unhelpful error it seems).

2 Likes

You nailed it in one! Thank you so much!
…Now thinking about this, it’s not what I’d call “square” lol

Hello MRKane

I have a similar issue, but I am using obi cloth.

Shader error in ‘Obi/Particles’: ‘’ : non-square matrices not supported (3x1) at line 63 (on gles)
Shader error in ‘Obi/Particles’: ‘’ : non-square matrices not supported (3x1) at line 160 (on gles)

Do oyu have any idea how to solve it? I would really appreciate your help.

Best
C.

1 Like

Yep, you solve it by contacting Virtual Method and letting them know it’s broken. You can do so on their own forums in the link above, or @arkano22 the Unity forums here:

https://forum.unity.com/threads/obi-particle-based-physics-cloth-rope-fluid-thread.337322