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:
- Add a Vector Parameter node in the material editor.
- Add a Custom HLSL code node in the material editor.
- Ensure the Custom node has an input.
- Wire the first output of the Vector Parameter node to the Custom node input.
- Add code to the Custom node that accesses the w (or a) member of the input value. (e.g. “input.w”)
- 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)); }