Search Unity

Question Ambiguous Call to Unity_Multiply_Float

Discussion in 'Shader Graph' started by Key_25, Mar 23, 2022.

  1. Key_25

    Key_25

    Joined:
    Feb 22, 2022
    Posts:
    5
    I'm using Shader Graph with PS4 (I already posted on PS4 forums and they sent me here claiming it wasn't a PS4 issue despite this only being present on PS4 and not when I build for other platforms), and I continuously get the error "ambiguous call to 'Unity_Multiply_float'. Found 3 possible candidates."
    I'm using LWRP (tried URP too, didn't change anything), Shader Graph 7.5.3 (yes I know there are updated versions, updating did nothing so I reverted to the last version that I know works on other platforms), and I have the PS4 Render Pipelines Package for the Unity version I'm using (Unity 2019.4.32). I believe those are all the relevant packages for this problem.

    I'm not entirely sure what is causing this issue or how to fix it, but here's what I suspect:
    - I assume it is because there are multiple versions of the function that all take different parameters (float, float3, and float4). This doesn't make a lot of sense to me to be the issue since it's basic overloading, so unless shaders don't like overloading for some reason or PS4 doesn't handle them properly, I don't know why this would be an issue. But, this does seem like the most likely cause.
    - I've also heard PS4 doesn't handle multiplying two vectors of different dimensions well at all, so it might just get confused as to which function to call.

    Here are things I've tried:
    -- Tried going into the shader graphs and manually changing each multiply node to make sure the dimensions lined up properly so PS4 didn't freak out. This didn't change anything.
    ---- Tried going into subgraphs and did this as well.
    -- Tried upgrading the materials to make sure they were compatible with the render pipeline.
    -- Tried reimporting all the materials just in case.
    -- Tried switching between float and half, but both precisions give the same error.
    -- Made sure the render pipeline was set in graphics and quality in the project settings.
    -- Made sure there weren't any compatibility issues with the packages and Unity version etc.

    At this point, I'm not sure what to do. I can't just go into the code and change what I might need to change since it's all generated by Shader Graph, but changing the node structure in the graph netted no meaningful result. If anyone else has had a similar issue and/or knows how to fix it, please let me know.
    Again, this only seems to happen when I build for PS4, building for PC for example doesn't have these errors at all. I know this isn't a PS4 specific forum, but PS4 forums were no help and just sent me here.
     
  2. Key_25

    Key_25

    Joined:
    Feb 22, 2022
    Posts:
    5
    Update: Nevermind about the overload point I made. I looked into it some more, and when I look at the generated code, on top of the three versions of Unity_Multiply_Half that are just overloads, there are three identical functions called void Unity_Multiply_half(half A, half B, out half Out). This is 100% what's causing the issue, but I have no clue why Shader Graph creates three functions with the same name and parameters, nor do I know how to stop this from happening.
     
  3. Key_25

    Key_25

    Joined:
    Feb 22, 2022
    Posts:
    5
    Okay so I finally figured it out on a whim. I figured Unity handled multiplication weird with multiplying a 1D vector, so I just did a work around to avoid that scenario entirely. (Also I figured it had to do with the 1D vector multiplication since there were 3 instances of different multiplication types, 1D*1D, 1D*3D, and 1D*4D. It seemed too suspicious to just be coincidence.) So, here's what I did to fix this:

    When multiplying a 1D and 3D vector:
    - Split the 3D vector
    - Multiply the first component by the 1D vector
    - Combine that output with the second and third component of the original 3D vector
    - Use the output from the combine node in place of the old Multiply node
    You could do this for a 1D * 4D vector too, but I didn't have to.