Material Expression Vector Parameter node main output is float3 not float4

Build Type: Binary build from normal download (via new FPS template project).

Build version: 4.15, patch version 1, changelist 3348071

Issue: You can’t access w/alpha channel of a material expression vector parameter node wired to a custom HLSL code node. The output is claimed to be a float4 vector value (like a Constant4Vector), but appears to the code as a float3.

Repro Steps:

  1. Add a Vector Parameter node in the material editor.
  2. Add a Custom HLSL code node in the material editor.
  3. Ensure the Custom node has an input.
  4. Wire the first output of the Vector Parameter node to the Custom node input.
  5. Add code to the Custom node that accesses the w (or a) member of the input value. (e.g. “input.w”)
  6. Compile shader, note error.

See images:

Workaround: The float4 nature can be restored by using ‘Vector Append’ node to combine the primary output (float3) with the alpha channel (float1) output explicitly. See image:

Additional:
Documentation claims parity with Constant4Vector ([here][4]).

Debugging the shader expression processing shows the output being classified as a float3 instead of a float4. Source code for set-up of parameter object outputs appears to have alpha channel masked out:

UMaterialExpressionVectorParameter::UMaterialExpressionVectorParameter(const FObjectInitializer& ObjectInitializer)
    	: Super(ObjectInitializer)
    {
    	Outputs.Reset();
    	Outputs.Add(FExpressionOutput(TEXT(""), 1, 1, 1, 1, 0));   **<<<< should be 1, not 0.**
    	Outputs.Add(FExpressionOutput(TEXT(""), 1, 1, 0, 0, 0));
    	Outputs.Add(FExpressionOutput(TEXT(""), 1, 0, 1, 0, 0));
    	Outputs.Add(FExpressionOutput(TEXT(""), 1, 0, 0, 1, 0));
    	Outputs.Add(FExpressionOutput(TEXT(""), 1, 0, 0, 0, 1));
    }

Pretty sure it is intended and has been like that since first version. Top pin on texture samplers and vector parameters represents RGB, not RGBA. I guess this is done for convenience, as XYZ is used more often than XYZW.

I guess this means it’s just the documentation that needs fixing. It is a bit misleading to say “The VectorParameter expression is identical to the Constant4Vector” as it can’t be used in place without a Vector Append node.

Shame, it means I need an extra node in all my materials since they all need a f4 input parameter. Nevermind, back to frying bigger fish :slight_smile: