Apparently UE4’s material translator does not fold uniform expressions within material parameter collections in them. It had been true for at least 4.19-4.22 span. Since new bug reporting form greatly improved quality of bug reports, I’ll leave this here too, just in case it might be useful to someone.
/// HLSL code with material parameter collection in the network. Whole network should be folded, but it is not. MaterialFloat4 Local0 = MaterialCollection0.Vectors; MaterialFloat Local1 = (Local0.b / 360.00000000); MaterialFloat Local2 = (Local1 * 6.28318548); MaterialFloat Local3 = sin(Local2); MaterialFloat Local4 = (Local1 * 6.28318548); MaterialFloat Local5 = cos(Local4); MaterialFloat Local6 = dot(MaterialFloat3(MaterialFloat2(Local3,Local5),0.00000000), MaterialFloat3(MaterialFloat2(Local3,Local5),0.00000000)); MaterialFloat Local7 = sqrt(Local6); MaterialFloat3 Local8 = (MaterialFloat3(MaterialFloat2(Local3,Local5),0.00000000) / Local7); MaterialFloat3 Local9 = (Local8 + Material.VectorExpressions.rgb);
/// HLSL code of the same network with scalar parameter instead of material parameter collection. Notice unnecessary addition operator. MaterialFloat3 Local0 = (Material.VectorExpressions.rgb + Material.VectorExpressions.rgb); PixelMaterialInputs.EmissiveColor = Local0;
Then there is this extra addition, that makes no sense and should not be there.