Download

Reconstructing Normals from Depth Buffer for Dbuffer Deferred Decal Masking

Hello, currently I’m trying to mask out dbuffer deferred decals from “bleeding” onto perpendicular surfaces. I found out pretty quickly that you can’t directly access normals from the dbuffer decal, but with some digging I found out that normals could be reconstructed from the depth buffer, as seen here: Accurate Normal Reconstruction from Depth Buffer. This seems to do exactly what I want. I’ve been trying to recreate the pseudo code the author provided in their blog post using material nodes, but I have no experience with HLSL given that Unreal Engine is so heavily focused on material nodes. This is what I currently have set up so far:

A lot is wrong with this, I’m sure. Anyone more experienced with HLSL willing to help me out here? Thanks!

Hi, looks like this will work for you.
But i’m not a pro, so it could be more proper way…



float4 SvPosition = Parameters.SvPosition;
float DeviceZ = LookupDeviceZ(SvPositionToBufferUV(SvPosition + float4(0, 0, 0, 0)));
if(DeviceZ<0.0001) return float3(0.0,0.0,0.0);
float DeviceZRight = LookupDeviceZ(SvPositionToBufferUV(SvPosition + float4(1, 0, 0, 0)));
float DeviceZBottom = LookupDeviceZ(SvPositionToBufferUV(SvPosition + float4(0, 1, 0, 0)));
float3 Mid =    SvPositionToTranslatedWorld(float4(SvPosition.xy + float2(0, 0), DeviceZ, 1));
float3 Right =    SvPositionToTranslatedWorld(float4(SvPosition.xy + float2(1, 0), DeviceZRight, 1)) - Mid;
float3 Down =    SvPositionToTranslatedWorld(float4(SvPosition.xy + float2(0, 1), DeviceZBottom, 1)) - Mid;

return 0.5*normalize(cross(Right, Down));

Material:
[SPOILER]


Begin Object Class=/Script/UnrealEd.MaterialGraphNode Name="MaterialGraphNode_23"
   Begin Object Class=/Script/Engine.MaterialExpressionCustom Name="MaterialExpressionCustom_2"
   End Object
   Begin Object Name="MaterialExpressionCustom_2"
      Code="float4 SvPosition = Parameters.SvPosition;
float DeviceZ = LookupDeviceZ(SvPositionToBufferUV(SvPosition + float4(0, 0, 0, 0)));
if(DeviceZ<0.0001) return float3(0.0,0.0,0.0);
float DeviceZRight = LookupDeviceZ(SvPositionToBufferUV(SvPosition + float4(1, 0, 0, 0)));
float DeviceZBottom = LookupDeviceZ(SvPositionToBufferUV(SvPosition + float4(0, 1, 0, 0)));
float3 Mid =	SvPositionToTranslatedWorld(float4(SvPosition.xy + float2(0, 0), DeviceZ, 1));
float3 Right =	SvPositionToTranslatedWorld(float4(SvPosition.xy + float2(1, 0), DeviceZRight, 1)) - Mid;
float3 Down =	SvPositionToTranslatedWorld(float4(SvPosition.xy + float2(0, 1), DeviceZBottom, 1)) - Mid;

return 0.5*normalize(cross(Right, Down));"
      Inputs=
      MaterialExpressionEditorX=-1040
      MaterialExpressionEditorY=416
      MaterialExpressionGuid=ADEA48E54B2D6DBA8B1B51BE79DA85D3
      Material=PreviewMaterial'"/Engine/Transient.ReconstructNormalsDecal"'
   End Object
   MaterialExpression=MaterialExpressionCustom'"MaterialExpressionCustom_2"'
   NodePosX=-1040
   NodePosY=416
   NodeGuid=1674A40E46D4BA1DFF2A3E9C31192F04
   CustomProperties Pin (PinId=32CE5411453BB5048D3CF2A245F1089C,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,LinkedTo=(MaterialGraphNode_40 399104CE49B9AE947D5CB098F032F575,),PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
End Object
Begin Object Class=/Script/UnrealEd.MaterialGraphNode Name="MaterialGraphNode_26"
   Begin Object Class=/Script/Engine.MaterialExpressionComponentMask Name="MaterialExpressionComponentMask_0"
   End Object
   Begin Object Name="MaterialExpressionComponentMask_0"
      Input=(Expression=MaterialExpressionMaterialFunctionCall'"MaterialGraphNode_40.MaterialExpressionMaterialFunctionCall_7"')
      B=True
      MaterialExpressionEditorX=-512
      MaterialExpressionEditorY=416
      MaterialExpressionGuid=55BEC1FA46A3456944E8BDBB38FF3997
      Material=PreviewMaterial'"/Engine/Transient.ReconstructNormalsDecal"'
   End Object
   MaterialExpression=MaterialExpressionComponentMask'"MaterialExpressionComponentMask_0"'
   NodePosX=-512
   NodePosY=416
   NodeGuid=3C82200F4A16FE1056332B98A23BF88F
   CustomProperties Pin (PinId=A2EC8A164E994024C6A4E883A10D2B4D,PinName="Input",PinFriendlyName=NSLOCTEXT("MaterialGraphNode", "Space", " "),PinType.PinCategory="required",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,LinkedTo=(MaterialGraphNode_40 6C73F810438222F36F828E93DED0CC27,),PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
   CustomProperties Pin (PinId=9D743DD84553DB315D796A90FB359D97,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,LinkedTo=(MaterialGraphNode_33 632564B346F8E19DEEDA0C83B342EBCD,),PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
End Object
Begin Object Class=/Script/UnrealEd.MaterialGraphNode Name="MaterialGraphNode_33"
   Begin Object Class=/Script/Engine.MaterialExpressionSaturate Name="MaterialExpressionSaturate_0"
   End Object
   Begin Object Name="MaterialExpressionSaturate_0"
      Input=(Expression=MaterialExpressionComponentMask'"MaterialGraphNode_26.MaterialExpressionComponentMask_0"')
      MaterialExpressionEditorX=-400
      MaterialExpressionEditorY=416
      MaterialExpressionGuid=0B4B40D044D780156B13B68CD703F309
      Material=PreviewMaterial'"/Engine/Transient.ReconstructNormalsDecal"'
   End Object
   MaterialExpression=MaterialExpressionSaturate'"MaterialExpressionSaturate_0"'
   NodePosX=-400
   NodePosY=416
   NodeGuid=FFF027C341DC04990D44BD8B2F4E8AE8
   CustomProperties Pin (PinId=632564B346F8E19DEEDA0C83B342EBCD,PinName="Input",PinFriendlyName=NSLOCTEXT("MaterialGraphNode", "Space", " "),PinType.PinCategory="required",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,LinkedTo=(MaterialGraphNode_26 9D743DD84553DB315D796A90FB359D97,),PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
   CustomProperties Pin (PinId=244E2F334666F76AF89DDDAA5701CD31,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,LinkedTo=(MaterialGraphNode_34 05CE241D437FC5BC434A0C8103DDE31E,),PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
End Object
Begin Object Class=/Script/UnrealEd.MaterialGraphNode Name="MaterialGraphNode_34"
   Begin Object Class=/Script/Engine.MaterialExpressionMultiply Name="MaterialExpressionMultiply_1"
   End Object
   Begin Object Name="MaterialExpressionMultiply_1"
      A=(Expression=MaterialExpressionSaturate'"MaterialGraphNode_33.MaterialExpressionSaturate_0"')
      B=(Expression=MaterialExpressionConstant'"MaterialGraphNode_50.MaterialExpressionConstant_7"')
      MaterialExpressionEditorX=-128
      MaterialExpressionEditorY=416
      MaterialExpressionGuid=AC2FFCCC4BEA6A485165A5B4F8354D20
      Material=PreviewMaterial'"/Engine/Transient.ReconstructNormalsDecal"'
   End Object
   MaterialExpression=MaterialExpressionMultiply'"MaterialExpressionMultiply_1"'
   NodePosX=-128
   NodePosY=416
   NodeGuid=430C874041D78387D870EBBA4E520ADD
   CustomProperties Pin (PinId=05CE241D437FC5BC434A0C8103DDE31E,PinName="A",PinType.PinCategory="optional",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,LinkedTo=(MaterialGraphNode_33 244E2F334666F76AF89DDDAA5701CD31,),PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
   CustomProperties Pin (PinId=BA8DB3D4402A558BAD1FE6A6D4D7FD21,PinName="B",PinType.PinCategory="optional",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,LinkedTo=(MaterialGraphNode_50 C87CE6084BFDD8D72ED6C8A74B70963D,),PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
   CustomProperties Pin (PinId=8E50BC804B4E2C7C5F7BC0821B45B143,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,LinkedTo=(MaterialGraphNode_48 721148F041DC9D00295AF5877767D9F8,),PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
End Object
Begin Object Class=/Script/UnrealEd.MaterialGraphNode Name="MaterialGraphNode_36"
   Begin Object Class=/Script/Engine.MaterialExpressionObjectOrientation Name="MaterialExpressionObjectOrientation_0"
   End Object
   Begin Object Name="MaterialExpressionObjectOrientation_0"
      MaterialExpressionEditorX=-1061
      MaterialExpressionEditorY=686
      MaterialExpressionGuid=9A0057114E60F6EE4D152AB77FF099A5
      Material=PreviewMaterial'"/Engine/Transient.ReconstructNormalsDecal"'
   End Object
   MaterialExpression=MaterialExpressionObjectOrientation'"MaterialExpressionObjectOrientation_0"'
   NodePosX=-1061
   NodePosY=686
   NodeGuid=4C9816B14FE0718308FC96AAC574E1B1
   CustomProperties Pin (PinId=295B06CD4692F209D9F46BA391FAAAC3,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,LinkedTo=(MaterialGraphNode_41 CA272D64467D30843FC781850DF03463,),PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
End Object
Begin Object Class=/Script/UnrealEd.MaterialGraphNode Name="MaterialGraphNode_40"
   Begin Object Class=/Script/Engine.MaterialExpressionMaterialFunctionCall Name="MaterialExpressionMaterialFunctionCall_7"
   End Object
   Begin Object Name="MaterialExpressionMaterialFunctionCall_7"
      MaterialFunction=MaterialFunction'"/Engine/Functions/Engine_MaterialFunctions01/Vectors/RotateVector.RotateVector"'
      FunctionInputs(0)=(ExpressionInputId=98B42CF248CA8DC84844E7BE92F622F0,Input=(Expression=MaterialExpressionCustom'"MaterialGraphNode_23.MaterialExpressionCustom_2"',InputName="VectorToRotate"))
      FunctionInputs(1)=(ExpressionInputId=A9C0AC0244B9D2393F2433A68EC1C76B,Input=(Expression=MaterialExpressionMaterialFunctionCall'"MaterialGraphNode_41.MaterialExpressionMaterialFunctionCall_8"',InputName="LookAtVector"))
      FunctionInputs(2)=(ExpressionInputId=B2EE43334B4CFF407B97718C7D2BE6EB,Input=(OutputIndex=-1,InputName="RestingVector"))
      FunctionOutputs(0)=(ExpressionOutputId=21394CDC48CCAD903CB7088969E1494E,Output=(OutputName="Result"))
      MaterialExpressionEditorX=-768
      MaterialExpressionEditorY=416
      MaterialExpressionGuid=DE07D51845AB24A744B1D6BB41E87FF7
      Material=PreviewMaterial'"/Engine/Transient.ReconstructNormalsDecal"'
      Outputs(0)=(OutputName="Result")
   End Object
   MaterialExpression=MaterialExpressionMaterialFunctionCall'"MaterialExpressionMaterialFunctionCall_7"'
   NodePosX=-768
   NodePosY=416
   ErrorType=1
   ErrorMsg="Missing function input \'LookAtVector\'"
   NodeGuid=E944A347495052CAEC1FF39D7C645E69
   CustomProperties Pin (PinId=399104CE49B9AE947D5CB098F032F575,PinName="VectorToRotate (V3)",PinType.PinCategory="required",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,LinkedTo=(MaterialGraphNode_23 32CE5411453BB5048D3CF2A245F1089C,),PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
   CustomProperties Pin (PinId=C93944F0428FEC5209CE94819544D332,PinName="LookAtVector (V3)",PinType.PinCategory="required",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,LinkedTo=(MaterialGraphNode_41 DCE11C1B414BE89C5CC54F9FE76EE948,),PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
   CustomProperties Pin (PinId=BB88261B4E6B181624E063BA365E2ED1,PinName="RestingVector (V3)",PinType.PinCategory="optional",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
   CustomProperties Pin (PinId=6C73F810438222F36F828E93DED0CC27,PinName="Result",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,LinkedTo=(MaterialGraphNode_26 A2EC8A164E994024C6A4E883A10D2B4D,),PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
End Object
Begin Object Class=/Script/UnrealEd.MaterialGraphNode Name="MaterialGraphNode_41"
   Begin Object Class=/Script/Engine.MaterialExpressionMaterialFunctionCall Name="MaterialExpressionMaterialFunctionCall_8"
   End Object
   Begin Object Name="MaterialExpressionMaterialFunctionCall_8"
      MaterialFunction=MaterialFunction'"/Engine/Functions/Engine_MaterialFunctions02/Math/InverseTransformMatrix.InverseTransformMatrix"'
      FunctionInputs(0)=(ExpressionInputId=B21689654B1661D5CE3D5F837F05B6A6,Input=(Expression=MaterialExpressionObjectOrientation'"MaterialGraphNode_36.MaterialExpressionObjectOrientation_0"',InputName="VectorToTransform"))
      FunctionInputs(1)=(ExpressionInputId=EE624CCE4DD4240A7159318333DBDA08,Input=(InputName="BasisX",Mask=1,MaskR=1,MaskG=1,MaskB=1))
      FunctionInputs(2)=(ExpressionInputId=F0BB91384877FA3699C7E28F88A7D519,Input=(InputName="BasisY",Mask=1,MaskR=1,MaskG=1,MaskB=1))
      FunctionInputs(3)=(ExpressionInputId=144CAA8F437EBDBD84551E9F1DA0F579,Input=(Expression=MaterialExpressionConstant3Vector'"MaterialGraphNode_47.MaterialExpressionConstant3Vector_0"',InputName="BasisZ"))
      FunctionOutputs(0)=(ExpressionOutputId=BB720F6C40263651E0C307B7D447486D,Output=(OutputName="Transformed Vector 3"))
      MaterialExpressionEditorX=-832
      MaterialExpressionEditorY=704
      MaterialExpressionGuid=1E6DD28347E4B076262253915340B416
      Material=PreviewMaterial'"/Engine/Transient.ReconstructNormalsDecal"'
      Outputs(0)=(OutputName="Transformed Vector 3")
   End Object
   MaterialExpression=MaterialExpressionMaterialFunctionCall'"MaterialExpressionMaterialFunctionCall_8"'
   NodePosX=-832
   NodePosY=704
   NodeGuid=3264225B4E0D47F48578BCAED3AC3AF6
   CustomProperties Pin (PinId=CA272D64467D30843FC781850DF03463,PinName="VectorToTransform (V3)",PinType.PinCategory="optional",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,LinkedTo=(MaterialGraphNode_36 295B06CD4692F209D9F46BA391FAAAC3,),PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
   CustomProperties Pin (PinId=0FFAB9CC4E2919675E3184A327D64860,PinName="BasisX (V3)",PinType.PinCategory="optional",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
   CustomProperties Pin (PinId=C359524B4FD79A0DC1EDCCAF60B505BB,PinName="BasisY (V3)",PinType.PinCategory="optional",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
   CustomProperties Pin (PinId=5FDFD7B24E3B5AE496D9E6B7BB979558,PinName="BasisZ (V3)",PinType.PinCategory="optional",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,LinkedTo=(MaterialGraphNode_47 5D3143C74C38244013B4DA81CD87D73B,),PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
   CustomProperties Pin (PinId=DCE11C1B414BE89C5CC54F9FE76EE948,PinName="Transformed Vector 3",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,LinkedTo=(MaterialGraphNode_40 C93944F0428FEC5209CE94819544D332,),PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
End Object
Begin Object Class=/Script/UnrealEd.MaterialGraphNode Name="MaterialGraphNode_45"
   Begin Object Class=/Script/Engine.MaterialExpressionConstant Name="MaterialExpressionConstant_6"
   End Object
   Begin Object Name="MaterialExpressionConstant_6"
      R=1.000000
      MaterialExpressionEditorX=32
      MaterialExpressionEditorY=464
      MaterialExpressionGuid=F54B79F54C3898042B845E80E140DF5F
      Material=PreviewMaterial'"/Engine/Transient.ReconstructNormalsDecal"'
   End Object
   MaterialExpression=MaterialExpressionConstant'"MaterialExpressionConstant_6"'
   NodePosX=32
   NodePosY=464
   NodeGuid=CA11A40F49DE116E1414699552271A38
   CustomProperties Pin (PinId=D7A9B39D4A1D164C9EA22AB8B53FFF8F,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,LinkedTo=(MaterialGraphNode_48 66D114184DDFEC197A9EBCB571D67CDD,),PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
End Object
Begin Object Class=/Script/UnrealEd.MaterialGraphNode Name="MaterialGraphNode_47"
   Begin Object Class=/Script/Engine.MaterialExpressionConstant3Vector Name="MaterialExpressionConstant3Vector_0"
   End Object
   Begin Object Name="MaterialExpressionConstant3Vector_0"
      Constant=(R=0.000000,G=0.000000,B=-1.000000,A=0.000000)
      MaterialExpressionEditorX=-1056
      MaterialExpressionEditorY=784
      MaterialExpressionGuid=888AB20A4B5BA9B8F2303B8122BDBB90
      Material=PreviewMaterial'"/Engine/Transient.ReconstructNormalsDecal"'
   End Object
   MaterialExpression=MaterialExpressionConstant3Vector'"MaterialExpressionConstant3Vector_0"'
   NodePosX=-1056
   NodePosY=784
   NodeGuid=8BB7E71A492AA59B03A8C3A992E30D79
   CustomProperties Pin (PinId=5D3143C74C38244013B4DA81CD87D73B,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,LinkedTo=(MaterialGraphNode_41 5FDFD7B24E3B5AE496D9E6B7BB979558,),PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
End Object
Begin Object Class=/Script/UnrealEd.MaterialGraphNode Name="MaterialGraphNode_48"
   Begin Object Class=/Script/Engine.MaterialExpressionLinearInterpolate Name="MaterialExpressionLinearInterpolate_1"
   End Object
   Begin Object Name="MaterialExpressionLinearInterpolate_1"
      A=(Expression=MaterialExpressionMultiply'"MaterialGraphNode_34.MaterialExpressionMultiply_1"')
      B=(Expression=MaterialExpressionConstant'"MaterialGraphNode_45.MaterialExpressionConstant_6"')
      Alpha=(Expression=MaterialExpressionScalarParameter'"MaterialGraphNode_49.MaterialExpressionScalarParameter_3"')
      MaterialExpressionEditorX=144
      MaterialExpressionEditorY=416
      MaterialExpressionGuid=C577D2F747D2472D51DCE184B790FC5A
      Material=PreviewMaterial'"/Engine/Transient.ReconstructNormalsDecal"'
   End Object
   MaterialExpression=MaterialExpressionLinearInterpolate'"MaterialExpressionLinearInterpolate_1"'
   NodePosX=144
   NodePosY=416
   NodeGuid=6699BCDB4DBF1EBB815A8D8EBA46054C
   CustomProperties Pin (PinId=721148F041DC9D00295AF5877767D9F8,PinName="A",PinType.PinCategory="optional",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,LinkedTo=(MaterialGraphNode_34 8E50BC804B4E2C7C5F7BC0821B45B143,),PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
   CustomProperties Pin (PinId=66D114184DDFEC197A9EBCB571D67CDD,PinName="B",PinType.PinCategory="optional",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,LinkedTo=(MaterialGraphNode_45 D7A9B39D4A1D164C9EA22AB8B53FFF8F,),PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
   CustomProperties Pin (PinId=A303C2A6433B72FCF0D74B8D7EC91D78,PinName="Alpha",PinType.PinCategory="optional",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,LinkedTo=(MaterialGraphNode_49 E6DA3BEC4EEA8265FDD65BB50BBDA3E4,),PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
   CustomProperties Pin (PinId=65B4312045130F2A2E35B1B723E732D0,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,LinkedTo=(MaterialGraphNode_Knot_3 4B0D61124456E063FD887B8A2208C251,),PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
End Object
Begin Object Class=/Script/UnrealEd.MaterialGraphNode Name="MaterialGraphNode_49"
   Begin Object Class=/Script/Engine.MaterialExpressionScalarParameter Name="MaterialExpressionScalarParameter_3"
   End Object
   Begin Object Name="MaterialExpressionScalarParameter_3"
      SliderMax=1.000000
      ParameterName="On/Off"
      ExpressionGUID=0634F3BA45A33336E5C7529A7A2A7EF0
      MaterialExpressionEditorX=144
      MaterialExpressionEditorY=560
      MaterialExpressionGuid=E31EAD7E4EE342B266E73E90BE9C1371
      Material=PreviewMaterial'"/Engine/Transient.ReconstructNormalsDecal"'
   End Object
   MaterialExpression=MaterialExpressionScalarParameter'"MaterialExpressionScalarParameter_3"'
   NodePosX=144
   NodePosY=560
   bCanRenameNode=True
   NodeGuid=01591FCA495ABA7F4212F8B32F3DD3C1
   CustomProperties Pin (PinId=E6DA3BEC4EEA8265FDD65BB50BBDA3E4,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,LinkedTo=(MaterialGraphNode_48 A303C2A6433B72FCF0D74B8D7EC91D78,),PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
End Object
Begin Object Class=/Script/UnrealEd.MaterialGraphNode Name="MaterialGraphNode_50"
   Begin Object Class=/Script/Engine.MaterialExpressionConstant Name="MaterialExpressionConstant_7"
   End Object
   Begin Object Name="MaterialExpressionConstant_7"
      R=10.000000
      MaterialExpressionEditorX=-208
      MaterialExpressionEditorY=464
      MaterialExpressionGuid=76E2114A4C8DC9FB451EF6869428347B
      Material=PreviewMaterial'"/Engine/Transient.ReconstructNormalsDecal"'
   End Object
   MaterialExpression=MaterialExpressionConstant'"MaterialExpressionConstant_7"'
   NodePosX=-208
   NodePosY=464
   NodeGuid=813CEC474CBD007FE0E719A363073141
   CustomProperties Pin (PinId=C87CE6084BFDD8D72ED6C8A74B70963D,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,LinkedTo=(MaterialGraphNode_34 BA8DB3D4402A558BAD1FE6A6D4D7FD21,),PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
End Object
Begin Object Class=/Script/UnrealEd.MaterialGraphNode_Knot Name="MaterialGraphNode_Knot_3"
   Begin Object Class=/Script/Engine.MaterialExpressionReroute Name="MaterialExpressionReroute_3"
   End Object
   Begin Object Name="MaterialExpressionReroute_3"
      Input=(Expression=MaterialExpressionLinearInterpolate'"MaterialGraphNode_48.MaterialExpressionLinearInterpolate_1"')
      MaterialExpressionEditorX=329
      MaterialExpressionEditorY=366
      MaterialExpressionGuid=55ACA1DB411BF319E72435B6BB406754
      Material=PreviewMaterial'"/Engine/Transient.ReconstructNormalsDecal"'
   End Object
   MaterialExpression=MaterialExpressionReroute'"MaterialExpressionReroute_3"'
   NodePosX=329
   NodePosY=366
   bCanRenameNode=False
   NodeGuid=A6ED0A914A2955549C8CCC9851A0CA66
   CustomProperties Pin (PinId=4B0D61124456E063FD887B8A2208C251,PinName="InputPin",PinType.PinCategory="wildcard",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,LinkedTo=(MaterialGraphNode_48 65B4312045130F2A2E35B1B723E732D0,),PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=True,bAdvancedView=False,bOrphanedPin=False,)
   CustomProperties Pin (PinId=244B409448CCB9786C28E693A9E9D508,PinName="OutputPin",Direction="EGPD_Output",PinType.PinCategory="wildcard",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,LinkedTo=(MaterialGraphNode_Root_1 8B6B45C149097272405EECB7EC7A5340,),PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
End Object


[/SPOILER]

I’ve copied in your nodes into the deferred decal material, but the masking here doesn’t seem to be working. Do you have any kinds of settings for the material modified besides changing the material to a decal?

Ok, so I’ve played around for a while with the material’s parameters but the masking still isn’t showing up here. I’ve tried your solution on both 4.22 and 4.24 to make sure it’s not a bug related to the engine, so I don’t think it’s an issue that’s engine related. Could you perhaps double check the code/material you’ve provided here to make sure it’s the exact same thing that produced your output in the screenshot, and if it is the same then maybe show your project’s rendering settings? I’ve tried playing around with my project’s rendering settings and I’m not finding any of them to be the culprit here, so I’m thinking the problem might not be on my end.

All right, I figured out what I got wrong, totally my fault. I was just using the linear interpolation node wrong. I can’t believe I overlooked that… I naively assumed it was there to determine whether or not the entire decal was meant to be visible, not to directly control the visibility of the masked part. whoopsies!

I was hoping to get the masking to cover 90 degrees of area (hence I mentioned perpendicular in the original post), but this covers 180 degrees. Any idea how that might be accomplished?

i’m sorry for long responding. You can insert Lerp node to control angle. But since it is reconstructed from depth you may have a strong “steps” on low poly geometry

[SPOILER]


Screenshot_322.jpg
[/SPOILER]

there is a better solution:

Thanks @inedible.red !! Just what I was looking for