Do you know why is this happening?
(I’m on 5.3.2 )
The power function is notoriously slow to emulate in software, and it might be that they’re using an approximation to run it faster.
This used to be more important back when CPUs were slower, but it’s still important on targets like GPUs.
Seems kinda dumb for a modern engine if you ask me, but this is why I would think it would happen.
Custom material expression:
Code:
float3 result = 1;
for (int i = 0; i < Exp; i++)
{
result *= Base;
}
return result;
Inputs:
Base
Exp
output type CMOT float 1
copy of code from material editor through Ctrl+C
Begin Object Class=/Script/UnrealEd.MaterialGraphNode Name="MaterialGraphNode_0" ExportPath=/Script/UnrealEd.MaterialGraphNode'"/Engine/Transient.NewMaterial:MaterialGraph_0.MaterialGraphNode_0"'
Begin Object Class=/Script/Engine.MaterialExpressionCustom Name="MaterialExpressionCustom_0" ExportPath=/Script/Engine.MaterialExpressionCustom'"/Engine/Transient.NewMaterial:MaterialGraph_0.MaterialGraphNode_0.MaterialExpressionCustom_0"'
End Object
Begin Object Name="MaterialExpressionCustom_0" ExportPath=/Script/Engine.MaterialExpressionCustom'"/Engine/Transient.NewMaterial:MaterialGraph_0.MaterialGraphNode_0.MaterialExpressionCustom_0"'
Code="float3 result = 1;\r\n\r\nfor (int i = 0; i < Exp; i++)\r\n{\r\n result *= Base;\r\n}\r\nreturn result;"
OutputType=CMOT_Float1
Description="Pow(X,Exp)"
Inputs(0)=(InputName="Base",Input=(Expression=/Script/Engine.MaterialExpressionConstant'"MaterialExpressionConstant_0"'))
Inputs(1)=(InputName="Exp",Input=(Expression=/Script/Engine.MaterialExpressionConstant'"MaterialExpressionConstant_1"'))
MaterialExpressionEditorX=-488
MaterialExpressionEditorY=442
MaterialExpressionGuid=FF6399644BAE362A24AD798F5ED1C01E
Material=/Script/UnrealEd.PreviewMaterial'"/Engine/Transient.NewMaterial"'
End Object
MaterialExpression=/Script/Engine.MaterialExpressionCustom'"MaterialExpressionCustom_0"'
NodePosX=-488
NodePosY=442
NodeGuid=■■■10E754C7FFB06CE62F298F669C41C
CustomProperties Pin (PinId=4533B40B4CEF2B707D3B339C602681BE,PinName="Base",PinType.PinCategory="required",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,LinkedTo=(MaterialGraphNode_1 A9A1AB3D429ADB3542A07E946A4F5809,),PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
CustomProperties Pin (PinId=DBA190B74240C0E94DEBC8B60BD37EA5,PinName="Exp",PinType.PinCategory="required",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,LinkedTo=(MaterialGraphNode_2 2BF093B3424649E47546408542B1B247,),PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
CustomProperties Pin (PinId=14582AC94F5EA217E428EDA56A5CFED7,PinName="Output",PinFriendlyName=NSLOCTEXT("MaterialGraphNode", "Space", " "),Direction="EGPD_Output",PinType.PinCategory="",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,LinkedTo=(MaterialGraphNode_5 855FCEC94F897782D8C4519B48206C24,),PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
End Object
You can select and copy the following code and then press Ctrl + V to paste it into the material editor.
Seems the default node just returns pow(10,3); which gives the same approx.
If it is crucial then it has to be manually calculated through the custom expression.
thank you very much for the workaround !
Please mark the thread as solved once you get it working, so others can find it in the future if they need it.
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.