Material Function stop working when turning Constant 4 vector into vector parameter?

So, I made a material function to select which RGB and A channel to sample from using a Constant 4 vector as a mean to choose channel. This works great but as soon as I turn the constant 4 vector into a vector parameter so i can instance the material I get the following errors: [SM5 Function MF_RGBorA: Cannot cast from float3 to float4.
And [SM5 Function MF_RGBorA: (node If) If input A must be of type float.

It works great when I’m not using a vector parameter. According to UDK | MaterialsCompendium there shoulnd’t be any difference between a constant 4 and a vector parameter.

Why is this?

1 Like

I also had some issues with VectorParameters, where it should work, but won’t. Here are a couple things to try:

Use the Main output pin and plug it into an Append node, and add the alpha output to the 2nd slot of the append, then try using the output of that to the node you are trying to connect.

You could also choose to use a collection parameter (and a MaterialParameterCollection) which is useful when you have many parameters to set inside a material. The default output from a Collection Vector parameter is always 4-channel, but then you will need to us a RGB ComponentMask for any 3 channel inputs.

Here is some more info on all of this:

Hope that helps Sitrec! :slight_smile:

Hey Sitrec -

Are you, and if so how are you, using a LERP or IF node in your material function? Both of these errors may be a result of not being able to compare vectors and floats in a 1 to 1 fashion?

Let me know -

Eric Ketchum

Hi Eric,
Yes, I’m using tons of IF nodes in the material function.

After reworking it I got it to work using your suggestion so I’m all good now.

Adding the append node helped my situation as well. Thanks!