Announcement

Collapse
No announcement yet.

Custom specular calculation

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

    Custom specular calculation

    Hi All,

    I've noticed that I wanted to have specular reflections in my scenes, but found the "realistic" rendering of Unreal Engine 4 insufficient. Therefore I made a trick to emulate specular highlights. It is a trick, because the coordinate of the light source Is hardcoded in the shader. This means also that you can only emulate 1 light source. My example also does not take into account fall-off, so regardless of the distance of the lightsource, the phong is always at the same brightness and size. Distance dependent specular light can however easily be added by a multiply operation. You can do some cool tricks once you can control specular light as you can see in the screenshots below:

    The base material code is calculated here:
    Click image for larger version

Name:	Specular01-BaseConfiguration.png
Views:	1
Size:	685.7 KB
ID:	1134815

    Now you can easily modulate your specular color (red), add bloom (modulate > 1.0), render with a diffuse color and normal map.
    Click image for larger version

Name:	Specular02-Color+Diffuse+Bloom+Normal.png
Views:	1
Size:	550.7 KB
ID:	1134816

    And much desired, translucency + specular, so you can make realistic water (unfortunately by reducing the opacity, also specular is reduced).
    Click image for larger version

Name:	Specular03-Translucent.png
Views:	1
Size:	586.7 KB
ID:	1134817

    You can also make realistic glass. Note that translucent material does not cast a shadow.
    Click image for larger version

Name:	Specular04-Glass.png
Views:	1
Size:	519.9 KB
ID:	1134818

    To avoid the reduction of translucency with opacity, you can just set the blend mode to additive and only render the specular light as a second render-pass (So first you render translucent water without opacity and, then you render a second mesh, just slightly above your water surface, with the specular highlights). (Still something needs to be made for reflections).
    Click image for larger version

Name:	Specular05-Additive.png
Views:	1
Size:	548.7 KB
ID:	1134819

    When using "Default lit" lighting mode, you can make use of normal maps, for nice, particle like effects. When using unlit mode, you can make force-field-like effects.
    Click image for larger version

Name:	Specular06-AdditiveLitOrUnlit.png
Views:	1
Size:	361.5 KB
ID:	1134820

    #2
    Dude...I have not yet reviewed your shader, but it looks completely awesome! Very cool idea.

    I might give it a try when I have time and share my thoughts on it (will probably do that quite soon since I am working on some car rendering stuff where this could come in handy^^)

    Cheers!
    Check out UNREAL 4 Lighting Academy
    https://forums.unrealengine.com/show...ng-like-that-)

    Comment


      #3
      Just wanted to drop by and say thanks man for making this tutorial.

      I've recently gotten inspired to go make a cartoony game in UE4 and my first thought was "how am I going to create the specular??!" but I found an answer quick.
      Last edited by JordanN; 12-08-2014, 08:16 AM.

      Comment


        #4
        Originally posted by JordanN View Post
        Just wanted to drop by and say thanks man for making this tutorial.

        I've recently gotten inspired to go make a cartoony game in UE4 and my first thought was "how am I going to create the specular??!" but I found an answer quick.
        Great!

        FYI: I found a mistake in the tutorial: The object position should be replaced by pixel position (or it is called something like that). If you are very far from an object, the object position and pixel position are more or less equivalent, but up close you get very different results.

        Comment


          #5
          OK, I just found out that UE4.6 sort of supports this:
          https://forums.unrealengine.com/show...063#post197063

          Comment


            #6
            Hey isgoed, just wanted to thank you for this TUT, Ive been wanting an easy way to add a colored spec for a transition from ue3 to 4.
            you have saved my life
            keep being a bad ***
            thanks again

            Comment


              #7
              So I noticed that you can also copy paste blueprints (as text); so for your convenience: This is my Material-Function F_Specular from my UE 4.11.2 Project. You can easily add this material function to your existing Materials:

              Code:
              Begin Object Class=MaterialGraphNode Name="MaterialGraphNode_18"
                 Begin Object Class=EdGraphPin Name="EdGraphPin_80426"
                 End Object
                 Begin Object Class=EdGraphPin Name="EdGraphPin_80425"
                 End Object
                 Begin Object Class=MaterialExpressionFunctionOutput Name="MaterialExpressionFunctionOutput_0"
                 End Object
                 Begin Object Name="EdGraphPin_80426"
                    PinName="Output"
                    PinFriendlyName=" "
                    Direction=EGPD_Output
                 End Object
                 Begin Object Name="EdGraphPin_80425"
                    PinName="Input"
                    PinFriendlyName=" "
                    PinType=(PinCategory="required")
                    LinkedTo(0)=EdGraphPin'MaterialGraphNode_19.EdGraphPin_80429'
                 End Object
                 Begin Object Name="MaterialExpressionFunctionOutput_0"
                    A=(Expression=MaterialExpressionPower'MaterialGraphNode_19.MaterialExpressionPower_0')
                    bLastPreviewed=True
                    Id=35D0033047C831402AEF5C98FECC5473
                    MaterialExpressionEditorX=-250
                    MaterialExpressionEditorY=375
                    MaterialExpressionGuid=DC7F39BD4679F1E0AE03C99C7EF36ED4
                    Material=Material'/Engine/Transient.Material_0'
                 End Object
                 MaterialExpression=MaterialExpressionFunctionOutput'MaterialExpressionFunctionOutput_0'
                 Pins(0)=EdGraphPin'EdGraphPin_80425'
                 Pins(1)=EdGraphPin'EdGraphPin_80426'
                 NodePosX=-250
                 NodePosY=375
                 NodeGuid=D3A16F9F40078B45108280B1B5E8C448
              End Object
              Begin Object Class=MaterialGraphNode Name="MaterialGraphNode_19"
                 Begin Object Class=EdGraphPin Name="EdGraphPin_80429"
                 End Object
                 Begin Object Class=EdGraphPin Name="EdGraphPin_80428"
                 End Object
                 Begin Object Class=EdGraphPin Name="EdGraphPin_80427"
                 End Object
                 Begin Object Class=MaterialExpressionPower Name="MaterialExpressionPower_0"
                 End Object
                 Begin Object Name="EdGraphPin_80429"
                    PinName="Output"
                    PinFriendlyName=" "
                    Direction=EGPD_Output
                    LinkedTo(0)=EdGraphPin'MaterialGraphNode_18.EdGraphPin_80425'
                 End Object
                 Begin Object Name="EdGraphPin_80428"
                    PinName="Exp"
                    PinType=(PinCategory="optional")
                 End Object
                 Begin Object Name="EdGraphPin_80427"
                    PinName="Base"
                    PinType=(PinCategory="required")
                    LinkedTo(0)=EdGraphPin'MaterialGraphNode_32.EdGraphPin_80464'
                 End Object
                 Begin Object Name="MaterialExpressionPower_0"
                    Base=(Expression=MaterialExpressionMin'MaterialGraphNode_32.MaterialExpressionMin_0')
                    ConstExponent=40.000000
                    MaterialExpressionEditorX=-560
                    MaterialExpressionEditorY=440
                    MaterialExpressionGuid=9F503533470CE5805D2B4B9048BBB2FB
                    Material=Material'/Engine/Transient.Material_0'
                 End Object
                 MaterialExpression=MaterialExpressionPower'MaterialExpressionPower_0'
                 Pins(0)=EdGraphPin'EdGraphPin_80427'
                 Pins(1)=EdGraphPin'EdGraphPin_80428'
                 Pins(2)=EdGraphPin'EdGraphPin_80429'
                 NodePosX=-560
                 NodePosY=440
                 NodeGuid=AF50DC93477729DF845F7498DB3ADC04
              End Object
              Begin Object Class=MaterialGraphNode Name="MaterialGraphNode_20"
                 Begin Object Class=EdGraphPin Name="EdGraphPin_80432"
                 End Object
                 Begin Object Class=EdGraphPin Name="EdGraphPin_80431"
                 End Object
                 Begin Object Class=EdGraphPin Name="EdGraphPin_80430"
                 End Object
                 Begin Object Class=MaterialExpressionMaterialFunctionCall Name="MaterialExpressionMaterialFunctionCall_0"
                 End Object
                 Begin Object Name="EdGraphPin_80432"
                    PinName="Reflection Vector"
                    Direction=EGPD_Output
                    LinkedTo(0)=EdGraphPin'MaterialGraphNode_25.EdGraphPin_80442'
                 End Object
                 Begin Object Name="EdGraphPin_80431"
                    PinName="CameraVector (V3)"
                    PinType=(PinCategory="optional")
                    LinkedTo(0)=EdGraphPin'MaterialGraphNode_26.EdGraphPin_80446'
                 End Object
                 Begin Object Name="EdGraphPin_80430"
                    PinName="Normal (V3)"
                    PinType=(PinCategory="optional")
                    LinkedTo(0)=EdGraphPin'MaterialGraphNode_21.EdGraphPin_80433'
                 End Object
                 Begin Object Name="MaterialExpressionMaterialFunctionCall_0"
                    MaterialFunction=MaterialFunction'/Engine/Functions/Engine_MaterialFunctions02/Utility/CustomReflectionVector.CustomReflectionVector'
                    FunctionInputs(0)=(ExpressionInputId=41DFA13C4219BE10B5068D96A0FF40CA,Input=(Expression=MaterialExpressionPixelNormalWS'MaterialGraphNode_21.MaterialExpressionPixelNormalWS_0',InputName="Normal"))
                    FunctionInputs(1)=(ExpressionInputId=28004D7B4A42C1E4E7DD328B7CE81115,Input=(Expression=MaterialExpressionSubtract'MaterialGraphNode_26.MaterialExpressionSubtract_1',InputName="CameraVector"))
                    FunctionOutputs(0)=(ExpressionOutputId=250DB93F499D65BE37807FBAB01777F8,Output=(OutputName="Reflection Vector"))
                    MaterialExpressionEditorX=-2320
                    MaterialExpressionEditorY=520
                    MaterialExpressionGuid=510DFFF54DAE7CA4E237BA99F055D0C1
                    Material=Material'/Engine/Transient.Material_0'
                    Outputs(0)=(OutputName="Reflection Vector")
                 End Object
                 MaterialExpression=MaterialExpressionMaterialFunctionCall'MaterialExpressionMaterialFunctionCall_0'
                 Pins(0)=EdGraphPin'EdGraphPin_80430'
                 Pins(1)=EdGraphPin'EdGraphPin_80431'
                 Pins(2)=EdGraphPin'EdGraphPin_80432'
                 NodePosX=-2320
                 NodePosY=520
                 NodeGuid=3C7FE8C1481D4914C2E42C9AC8D968DE
              End Object
              Begin Object Class=MaterialGraphNode Name="MaterialGraphNode_21"
                 Begin Object Class=EdGraphPin Name="EdGraphPin_80433"
                 End Object
                 Begin Object Class=MaterialExpressionPixelNormalWS Name="MaterialExpressionPixelNormalWS_0"
                 End Object
                 Begin Object Name="EdGraphPin_80433"
                    PinName="Output"
                    PinFriendlyName=" "
                    Direction=EGPD_Output
                    LinkedTo(0)=EdGraphPin'MaterialGraphNode_20.EdGraphPin_80430'
                    LinkedTo(1)=EdGraphPin'MaterialGraphNode_27.EdGraphPin_80447'
                 End Object
                 Begin Object Name="MaterialExpressionPixelNormalWS_0"
                    MaterialExpressionEditorX=-2640
                    MaterialExpressionEditorY=40
                    MaterialExpressionGuid=4B82EA3E4474FB3A2EE09C88CFD837D1
                    Material=Material'/Engine/Transient.Material_0'
                 End Object
                 MaterialExpression=MaterialExpressionPixelNormalWS'MaterialExpressionPixelNormalWS_0'
                 Pins(0)=EdGraphPin'EdGraphPin_80433'
                 NodePosX=-2640
                 NodePosY=40
                 NodeGuid=835B0BBB40E659938C6A63B33686A1B0
              End Object
              Begin Object Class=MaterialGraphNode Name="MaterialGraphNode_22"
                 Begin Object Class=EdGraphPin Name="EdGraphPin_80436"
                 End Object
                 Begin Object Class=EdGraphPin Name="EdGraphPin_80435"
                 End Object
                 Begin Object Class=EdGraphPin Name="EdGraphPin_80434"
                 End Object
                 Begin Object Class=MaterialExpressionDotProduct Name="MaterialExpressionDotProduct_0"
                 End Object
                 Begin Object Name="EdGraphPin_80436"
                    PinName="Output"
                    PinFriendlyName=" "
                    Direction=EGPD_Output
                    LinkedTo(0)=EdGraphPin'MaterialGraphNode_28.EdGraphPin_80454'
                 End Object
                 Begin Object Name="EdGraphPin_80435"
                    PinName="B"
                    PinType=(PinCategory="required")
                    LinkedTo(0)=EdGraphPin'MaterialGraphNode_25.EdGraphPin_80443'
                 End Object
                 Begin Object Name="EdGraphPin_80434"
                    PinName="A"
                    PinType=(PinCategory="required")
                    LinkedTo(0)=EdGraphPin'MaterialGraphNode_24.EdGraphPin_80441'
                 End Object
                 Begin Object Name="MaterialExpressionDotProduct_0"
                    A=(Expression=MaterialExpressionNormalize'MaterialGraphNode_24.MaterialExpressionNormalize_0')
                    B=(Expression=MaterialExpressionNormalize'MaterialGraphNode_25.MaterialExpressionNormalize_1')
                    MaterialExpressionEditorX=-1680
                    MaterialExpressionEditorY=340
                    MaterialExpressionGuid=A49C889F45A2E200C268C1AE857C19B8
                    Material=Material'/Engine/Transient.Material_0'
                 End Object
                 MaterialExpression=MaterialExpressionDotProduct'MaterialExpressionDotProduct_0'
                 Pins(0)=EdGraphPin'EdGraphPin_80434'
                 Pins(1)=EdGraphPin'EdGraphPin_80435'
                 Pins(2)=EdGraphPin'EdGraphPin_80436'
                 NodePosX=-1680
                 NodePosY=340
                 NodeGuid=38E1093B4D5A394DEC0D63B658F40A7D
              End Object
              Begin Object Class=MaterialGraphNode Name="MaterialGraphNode_23"
                 Begin Object Class=EdGraphPin Name="EdGraphPin_80439"
                 End Object
                 Begin Object Class=EdGraphPin Name="EdGraphPin_80438"
                 End Object
                 Begin Object Class=EdGraphPin Name="EdGraphPin_80437"
                 End Object
                 Begin Object Class=MaterialExpressionSubtract Name="MaterialExpressionSubtract_0"
                 End Object
                 Begin Object Name="EdGraphPin_80439"
                    PinName="Output"
                    PinFriendlyName=" "
                    Direction=EGPD_Output
                    LinkedTo(0)=EdGraphPin'MaterialGraphNode_24.EdGraphPin_80440'
                    LinkedTo(1)=EdGraphPin'MaterialGraphNode_27.EdGraphPin_80448'
                 End Object
                 Begin Object Name="EdGraphPin_80438"
                    PinName="B"
                    PinType=(PinCategory="optional")
                    LinkedTo(0)=EdGraphPin'MaterialGraphNode_34.EdGraphPin_80467'
                 End Object
                 Begin Object Name="EdGraphPin_80437"
                    PinName="A"
                    PinType=(PinCategory="optional")
                    LinkedTo(0)=EdGraphPin'MaterialGraphNode_33.EdGraphPin_80465'
                 End Object
                 Begin Object Name="MaterialExpressionSubtract_0"
                    A=(Expression=MaterialExpressionWorldPosition'MaterialGraphNode_33.MaterialExpressionWorldPosition_0')
                    B=(Expression=MaterialExpressionFunctionInput'MaterialGraphNode_34.MaterialExpressionFunctionInput_0')
                    MaterialExpressionEditorX=-2040
                    MaterialExpressionEditorY=220
                    MaterialExpressionGuid=26BFA4864FD804C160D524B0CE1A67A0
                    Material=Material'/Engine/Transient.Material_0'
                 End Object
                 MaterialExpression=MaterialExpressionSubtract'MaterialExpressionSubtract_0'
                 Pins(0)=EdGraphPin'EdGraphPin_80437'
                 Pins(1)=EdGraphPin'EdGraphPin_80438'
                 Pins(2)=EdGraphPin'EdGraphPin_80439'
                 NodePosX=-2040
                 NodePosY=220
                 NodeGuid=B2CB71A04D98046AB96EDDBA76592BCC
              End Object
              Begin Object Class=MaterialGraphNode Name="MaterialGraphNode_24"
                 Begin Object Class=EdGraphPin Name="EdGraphPin_80441"
                 End Object
                 Begin Object Class=EdGraphPin Name="EdGraphPin_80440"
                 End Object
                 Begin Object Class=MaterialExpressionNormalize Name="MaterialExpressionNormalize_0"
                 End Object
                 Begin Object Name="EdGraphPin_80441"
                    PinName="Output"
                    PinFriendlyName=" "
                    Direction=EGPD_Output
                    LinkedTo(0)=EdGraphPin'MaterialGraphNode_22.EdGraphPin_80434'
                 End Object
                 Begin Object Name="EdGraphPin_80440"
                    PinName="VectorInput"
                    PinType=(PinCategory="required")
                    LinkedTo(0)=EdGraphPin'MaterialGraphNode_23.EdGraphPin_80439'
                 End Object
                 Begin Object Name="MaterialExpressionNormalize_0"
                    VectorInput=(Expression=MaterialExpressionSubtract'MaterialGraphNode_23.MaterialExpressionSubtract_0')
                    MaterialExpressionEditorX=-1880
                    MaterialExpressionEditorY=300
                    MaterialExpressionGuid=74EA38C94C0DCD82FBA071BF43F862BE
                    Material=Material'/Engine/Transient.Material_0'
                 End Object
                 MaterialExpression=MaterialExpressionNormalize'MaterialExpressionNormalize_0'
                 Pins(0)=EdGraphPin'EdGraphPin_80440'
                 Pins(1)=EdGraphPin'EdGraphPin_80441'
                 NodePosX=-1880
                 NodePosY=300
                 NodeGuid=86F13B6D4C40D92ECC9E28A48A3D571D
              End Object
              Begin Object Class=MaterialGraphNode Name="MaterialGraphNode_25"
                 Begin Object Class=EdGraphPin Name="EdGraphPin_80443"
                 End Object
                 Begin Object Class=EdGraphPin Name="EdGraphPin_80442"
                 End Object
                 Begin Object Class=MaterialExpressionNormalize Name="MaterialExpressionNormalize_1"
                 End Object
                 Begin Object Name="EdGraphPin_80443"
                    PinName="Output"
                    PinFriendlyName=" "
                    Direction=EGPD_Output
                    LinkedTo(0)=EdGraphPin'MaterialGraphNode_22.EdGraphPin_80435'
                 End Object
                 Begin Object Name="EdGraphPin_80442"
                    PinName="VectorInput"
                    PinType=(PinCategory="required")
                    LinkedTo(0)=EdGraphPin'MaterialGraphNode_20.EdGraphPin_80432'
                 End Object
                 Begin Object Name="MaterialExpressionNormalize_1"
                    VectorInput=(Expression=MaterialExpressionMaterialFunctionCall'MaterialGraphNode_20.MaterialExpressionMaterialFunctionCall_0')
                    MaterialExpressionEditorX=-1960
                    MaterialExpressionEditorY=460
                    MaterialExpressionGuid=7CEC27AD4098EAF01CE164BDCAF110C8
                    Material=Material'/Engine/Transient.Material_0'
                 End Object
                 MaterialExpression=MaterialExpressionNormalize'MaterialExpressionNormalize_1'
                 Pins(0)=EdGraphPin'EdGraphPin_80442'
                 Pins(1)=EdGraphPin'EdGraphPin_80443'
                 NodePosX=-1960
                 NodePosY=460
                 NodeGuid=3C4ABF6040B85358641EC6B463AAAF65
              End Object
              Begin Object Class=MaterialGraphNode Name="MaterialGraphNode_26"
                 Begin Object Class=EdGraphPin Name="EdGraphPin_80446"
                 End Object
                 Begin Object Class=EdGraphPin Name="EdGraphPin_80445"
                 End Object
                 Begin Object Class=EdGraphPin Name="EdGraphPin_80444"
                 End Object
                 Begin Object Class=MaterialExpressionSubtract Name="MaterialExpressionSubtract_1"
                 End Object
                 Begin Object Name="EdGraphPin_80446"
                    PinName="Output"
                    PinFriendlyName=" "
                    Direction=EGPD_Output
                    LinkedTo(0)=EdGraphPin'MaterialGraphNode_20.EdGraphPin_80431'
                 End Object
                 Begin Object Name="EdGraphPin_80445"
                    PinName="B"
                    PinType=(PinCategory="optional")
                    LinkedTo(0)=EdGraphPin'MaterialGraphNode_35.EdGraphPin_80468'
                 End Object
                 Begin Object Name="EdGraphPin_80444"
                    PinName="A"
                    PinType=(PinCategory="optional")
                 End Object
                 Begin Object Name="MaterialExpressionSubtract_1"
                    B=(Expression=MaterialExpressionCameraVectorWS'MaterialGraphNode_35.MaterialExpressionCameraVectorWS_0')
                    ConstA=0.000000
                    MaterialExpressionEditorX=-2500
                    MaterialExpressionEditorY=560
                    MaterialExpressionGuid=B27C01E2443A6693C6120D926CC1F8DD
                    Material=Material'/Engine/Transient.Material_0'
                 End Object
                 MaterialExpression=MaterialExpressionSubtract'MaterialExpressionSubtract_1'
                 Pins(0)=EdGraphPin'EdGraphPin_80444'
                 Pins(1)=EdGraphPin'EdGraphPin_80445'
                 Pins(2)=EdGraphPin'EdGraphPin_80446'
                 NodePosX=-2500
                 NodePosY=560
                 NodeGuid=537EC56F49895E2E0431ABA91F1CEB3D
              End Object
              Begin Object Class=MaterialGraphNode Name="MaterialGraphNode_27"
                 Begin Object Class=EdGraphPin Name="EdGraphPin_80449"
                 End Object
                 Begin Object Class=EdGraphPin Name="EdGraphPin_80448"
                 End Object
                 Begin Object Class=EdGraphPin Name="EdGraphPin_80447"
                 End Object
                 Begin Object Class=MaterialExpressionDotProduct Name="MaterialExpressionDotProduct_1"
                 End Object
                 Begin Object Name="EdGraphPin_80449"
                    PinName="Output"
                    PinFriendlyName=" "
                    Direction=EGPD_Output
                    LinkedTo(0)=EdGraphPin'MaterialGraphNode_28.EdGraphPin_80450'
                 End Object
                 Begin Object Name="EdGraphPin_80448"
                    PinName="B"
                    PinType=(PinCategory="required")
                    LinkedTo(0)=EdGraphPin'MaterialGraphNode_23.EdGraphPin_80439'
                 End Object
                 Begin Object Name="EdGraphPin_80447"
                    PinName="A"
                    PinType=(PinCategory="required")
                    LinkedTo(0)=EdGraphPin'MaterialGraphNode_21.EdGraphPin_80433'
                 End Object
                 Begin Object Name="MaterialExpressionDotProduct_1"
                    A=(Expression=MaterialExpressionPixelNormalWS'MaterialGraphNode_21.MaterialExpressionPixelNormalWS_0')
                    B=(Expression=MaterialExpressionSubtract'MaterialGraphNode_23.MaterialExpressionSubtract_0')
                    MaterialExpressionEditorX=-1840
                    MaterialExpressionEditorY=120
                    MaterialExpressionGuid=6B3B5F2745CB4ACC65031A81CCADDC56
                    Material=Material'/Engine/Transient.Material_0'
                 End Object
                 MaterialExpression=MaterialExpressionDotProduct'MaterialExpressionDotProduct_1'
                 Pins(0)=EdGraphPin'EdGraphPin_80447'
                 Pins(1)=EdGraphPin'EdGraphPin_80448'
                 Pins(2)=EdGraphPin'EdGraphPin_80449'
                 NodePosX=-1840
                 NodePosY=120
                 NodeGuid=FA41C1104689112ADE3459819060CDD1
              End Object
              Begin Object Class=MaterialGraphNode Name="MaterialGraphNode_28"
                 Begin Object Class=EdGraphPin Name="EdGraphPin_80455"
                 End Object
                 Begin Object Class=EdGraphPin Name="EdGraphPin_80454"
                 End Object
                 Begin Object Class=EdGraphPin Name="EdGraphPin_80453"
                 End Object
                 Begin Object Class=EdGraphPin Name="EdGraphPin_80452"
                 End Object
                 Begin Object Class=EdGraphPin Name="EdGraphPin_80451"
                 End Object
                 Begin Object Class=EdGraphPin Name="EdGraphPin_80450"
                 End Object
                 Begin Object Class=MaterialExpressionIf Name="MaterialExpressionIf_0"
                 End Object
                 Begin Object Name="EdGraphPin_80455"
                    PinName="Output"
                    PinFriendlyName=" "
                    Direction=EGPD_Output
                    LinkedTo(0)=EdGraphPin'MaterialGraphNode_30.EdGraphPin_80457'
                 End Object
                 Begin Object Name="EdGraphPin_80454"
                    PinName="A<B"
                    PinType=(PinCategory="required")
                    LinkedTo(0)=EdGraphPin'MaterialGraphNode_22.EdGraphPin_80436'
                 End Object
                 Begin Object Name="EdGraphPin_80453"
                    PinName="A==B"
                    PinType=(PinCategory="optional")
                 End Object
                 Begin Object Name="EdGraphPin_80452"
                    PinName="A>=B"
                    PinType=(PinCategory="required")
                    LinkedTo(0)=EdGraphPin'MaterialGraphNode_29.EdGraphPin_80456'
                 End Object
                 Begin Object Name="EdGraphPin_80451"
                    PinName="B"
                    PinType=(PinCategory="optional")
                 End Object
                 Begin Object Name="EdGraphPin_80450"
                    PinName="A"
                    PinType=(PinCategory="required")
                    LinkedTo(0)=EdGraphPin'MaterialGraphNode_27.EdGraphPin_80449'
                 End Object
                 Begin Object Name="MaterialExpressionIf_0"
                    A=(Expression=MaterialExpressionDotProduct'MaterialGraphNode_27.MaterialExpressionDotProduct_1')
                    AGreaterThanB=(Expression=MaterialExpressionConstant'MaterialGraphNode_29.MaterialExpressionConstant_0')
                    ALessThanB=(Expression=MaterialExpressionDotProduct'MaterialGraphNode_22.MaterialExpressionDotProduct_0')
                    MaterialExpressionEditorX=-1500
                    MaterialExpressionEditorY=320
                    MaterialExpressionGuid=22FD26C24C4FD0776F97AAAD1414DACC
                    Material=Material'/Engine/Transient.Material_0'
                 End Object
                 MaterialExpression=MaterialExpressionIf'MaterialExpressionIf_0'
                 Pins(0)=EdGraphPin'EdGraphPin_80450'
                 Pins(1)=EdGraphPin'EdGraphPin_80451'
                 Pins(2)=EdGraphPin'EdGraphPin_80452'
                 Pins(3)=EdGraphPin'EdGraphPin_80453'
                 Pins(4)=EdGraphPin'EdGraphPin_80454'
                 Pins(5)=EdGraphPin'EdGraphPin_80455'
                 NodePosX=-1500
                 NodePosY=320
                 NodeGuid=1682D5F14805A0854FD0FDAF8191EF35
              End Object
              Begin Object Class=MaterialGraphNode Name="MaterialGraphNode_29"
                 Begin Object Class=EdGraphPin Name="EdGraphPin_80456"
                 End Object
                 Begin Object Class=MaterialExpressionConstant Name="MaterialExpressionConstant_0"
                 End Object
                 Begin Object Name="EdGraphPin_80456"
                    PinName="Output"
                    PinFriendlyName=" "
                    Direction=EGPD_Output
                    LinkedTo(0)=EdGraphPin'MaterialGraphNode_28.EdGraphPin_80452'
                 End Object
                 Begin Object Name="MaterialExpressionConstant_0"
                    MaterialExpressionEditorX=-1740
                    MaterialExpressionEditorY=520
                    MaterialExpressionGuid=0742581A4FA4FE5097146FA47B1F09DE
                    Material=Material'/Engine/Transient.Material_0'
                 End Object
                 MaterialExpression=MaterialExpressionConstant'MaterialExpressionConstant_0'
                 Pins(0)=EdGraphPin'EdGraphPin_80456'
                 NodePosX=-1740
                 NodePosY=520
                 NodeGuid=62BCD0F84846FAD2F8AE04BDE0B2E258
              End Object
              Begin Object Class=MaterialGraphNode Name="MaterialGraphNode_30"
                 Begin Object Class=EdGraphPin Name="EdGraphPin_80458"
                 End Object
                 Begin Object Class=EdGraphPin Name="EdGraphPin_80457"
                 End Object
                 Begin Object Class=MaterialExpressionComponentMask Name="MaterialExpressionComponentMask_0"
                 End Object
                 Begin Object Name="EdGraphPin_80458"
                    PinName="Output"
                    PinFriendlyName=" "
                    Direction=EGPD_Output
                    LinkedTo(0)=EdGraphPin'MaterialGraphNode_31.EdGraphPin_80459'
                 End Object
                 Begin Object Name="EdGraphPin_80457"
                    PinName="Input"
                    PinFriendlyName=" "
                    PinType=(PinCategory="required")
                    LinkedTo(0)=EdGraphPin'MaterialGraphNode_28.EdGraphPin_80455'
                 End Object
                 Begin Object Name="MaterialExpressionComponentMask_0"
                    Input=(Expression=MaterialExpressionIf'MaterialGraphNode_28.MaterialExpressionIf_0')
                    R=True
                    MaterialExpressionEditorX=-1320
                    MaterialExpressionEditorY=360
                    MaterialExpressionGuid=A6E8D2F4492655DE3B63078529DC4571
                    Material=Material'/Engine/Transient.Material_0'
                 End Object
                 MaterialExpression=MaterialExpressionComponentMask'MaterialExpressionComponentMask_0'
                 Pins(0)=EdGraphPin'EdGraphPin_80457'
                 Pins(1)=EdGraphPin'EdGraphPin_80458'
                 NodePosX=-1320
                 NodePosY=360
                 NodeGuid=46E6F3C04D22CA7DE4F14FA691014B21
              End Object
              Begin Object Class=MaterialGraphNode Name="MaterialGraphNode_31"
                 Begin Object Class=EdGraphPin Name="EdGraphPin_80461"
                 End Object
                 Begin Object Class=EdGraphPin Name="EdGraphPin_80460"
                 End Object
                 Begin Object Class=EdGraphPin Name="EdGraphPin_80459"
                 End Object
                 Begin Object Class=MaterialExpressionMax Name="MaterialExpressionMax_0"
                 End Object
                 Begin Object Name="EdGraphPin_80461"
                    PinName="Output"
                    PinFriendlyName=" "
                    Direction=EGPD_Output
                    LinkedTo(0)=EdGraphPin'MaterialGraphNode_32.EdGraphPin_80462'
                 End Object
                 Begin Object Name="EdGraphPin_80460"
                    PinName="B"
                    PinType=(PinCategory="optional")
                 End Object
                 Begin Object Name="EdGraphPin_80459"
                    PinName="A"
                    PinType=(PinCategory="optional")
                    LinkedTo(0)=EdGraphPin'MaterialGraphNode_30.EdGraphPin_80458'
                 End Object
                 Begin Object Name="MaterialExpressionMax_0"
                    A=(Expression=MaterialExpressionComponentMask'MaterialGraphNode_30.MaterialExpressionComponentMask_0')
                    ConstB=0.000000
                    MaterialExpressionEditorX=-1120
                    MaterialExpressionEditorY=360
                    MaterialExpressionGuid=9098B3944F61669A792CB698644CFDF3
                    Material=Material'/Engine/Transient.Material_0'
                 End Object
                 MaterialExpression=MaterialExpressionMax'MaterialExpressionMax_0'
                 Pins(0)=EdGraphPin'EdGraphPin_80459'
                 Pins(1)=EdGraphPin'EdGraphPin_80460'
                 Pins(2)=EdGraphPin'EdGraphPin_80461'
                 NodePosX=-1120
                 NodePosY=360
                 NodeGuid=08D14EC549979B2223FAC1B03257DCDA
              End Object
              Begin Object Class=MaterialGraphNode Name="MaterialGraphNode_32"
                 Begin Object Class=EdGraphPin Name="EdGraphPin_80464"
                 End Object
                 Begin Object Class=EdGraphPin Name="EdGraphPin_80463"
                 End Object
                 Begin Object Class=EdGraphPin Name="EdGraphPin_80462"
                 End Object
                 Begin Object Class=MaterialExpressionMin Name="MaterialExpressionMin_0"
                 End Object
                 Begin Object Name="EdGraphPin_80464"
                    PinName="Output"
                    PinFriendlyName=" "
                    Direction=EGPD_Output
                    LinkedTo(0)=EdGraphPin'MaterialGraphNode_19.EdGraphPin_80427'
                 End Object
                 Begin Object Name="EdGraphPin_80463"
                    PinName="B"
                    PinType=(PinCategory="optional")
                 End Object
                 Begin Object Name="EdGraphPin_80462"
                    PinName="A"
                    PinType=(PinCategory="optional")
                    LinkedTo(0)=EdGraphPin'MaterialGraphNode_31.EdGraphPin_80461'
                 End Object
                 Begin Object Name="MaterialExpressionMin_0"
                    A=(Expression=MaterialExpressionMax'MaterialGraphNode_31.MaterialExpressionMax_0')
                    ConstB=1.500000
                    MaterialExpressionEditorX=-720
                    MaterialExpressionEditorY=440
                    MaterialExpressionGuid=CA49C08A4FAF9056EA6A31AF711F85F3
                    Material=Material'/Engine/Transient.Material_0'
                 End Object
                 MaterialExpression=MaterialExpressionMin'MaterialExpressionMin_0'
                 Pins(0)=EdGraphPin'EdGraphPin_80462'
                 Pins(1)=EdGraphPin'EdGraphPin_80463'
                 Pins(2)=EdGraphPin'EdGraphPin_80464'
                 NodePosX=-720
                 NodePosY=440
                 NodeGuid=5594F97040456CFD3AB8E18C3EFF9CF9
              End Object
              Begin Object Class=MaterialGraphNode Name="MaterialGraphNode_33"
                 Begin Object Class=EdGraphPin Name="EdGraphPin_80465"
                 End Object
                 Begin Object Class=MaterialExpressionWorldPosition Name="MaterialExpressionWorldPosition_0"
                 End Object
                 Begin Object Name="EdGraphPin_80465"
                    PinName="Output"
                    PinFriendlyName=" "
                    Direction=EGPD_Output
                    LinkedTo(0)=EdGraphPin'MaterialGraphNode_23.EdGraphPin_80437'
                 End Object
                 Begin Object Name="MaterialExpressionWorldPosition_0"
                    MaterialExpressionEditorX=-2400
                    MaterialExpressionEditorY=176
                    MaterialExpressionGuid=33AC0B854C313B862EC0069D40543C6C
                    Material=Material'/Engine/Transient.Material_0'
                 End Object
                 MaterialExpression=MaterialExpressionWorldPosition'MaterialExpressionWorldPosition_0'
                 Pins(0)=EdGraphPin'EdGraphPin_80465'
                 NodePosX=-2400
                 NodePosY=176
                 NodeGuid=60C459A844B6FC45D94FF4B31064FD02
              End Object
              Begin Object Class=MaterialGraphNode Name="MaterialGraphNode_34"
                 Begin Object Class=EdGraphPin Name="EdGraphPin_80467"
                 End Object
                 Begin Object Class=EdGraphPin Name="EdGraphPin_80466"
                 End Object
                 Begin Object Class=MaterialExpressionFunctionInput Name="MaterialExpressionFunctionInput_0"
                 End Object
                 Begin Object Name="EdGraphPin_80467"
                    PinName="Output"
                    PinFriendlyName=" "
                    Direction=EGPD_Output
                    LinkedTo(0)=EdGraphPin'MaterialGraphNode_23.EdGraphPin_80438'
                 End Object
                 Begin Object Name="EdGraphPin_80466"
                    PinName="Preview"
                    PinType=(PinCategory="optional")
                 End Object
                 Begin Object Name="MaterialExpressionFunctionInput_0"
                    InputName="LightSourcePositon"
                    Id=1FD9998A4437359B9CD96DA9BB4ED611
                    PreviewValue=(X=0.000000,Y=1000.000000,Z=800.000000,W=1.000000)
                    MaterialExpressionEditorX=-2700
                    MaterialExpressionEditorY=300
                    MaterialExpressionGuid=9CDE91E543BB852CE381F4B1C26BC787
                    Material=Material'/Engine/Transient.Material_0'
                    Desc="Attach Light Source position here"
                 End Object
                 MaterialExpression=MaterialExpressionFunctionInput'MaterialExpressionFunctionInput_0'
                 Pins(0)=EdGraphPin'EdGraphPin_80466'
                 Pins(1)=EdGraphPin'EdGraphPin_80467'
                 NodePosX=-2700
                 NodePosY=300
                 NodeComment="Attach Light Source position here"
                 NodeGuid=338104064853548E07B226A4ABD06D11
              End Object
              Begin Object Class=MaterialGraphNode Name="MaterialGraphNode_35"
                 Begin Object Class=EdGraphPin Name="EdGraphPin_80468"
                 End Object
                 Begin Object Class=MaterialExpressionCameraVectorWS Name="MaterialExpressionCameraVectorWS_0"
                 End Object
                 Begin Object Name="EdGraphPin_80468"
                    PinName="Output"
                    PinFriendlyName=" "
                    Direction=EGPD_Output
                    LinkedTo(0)=EdGraphPin'MaterialGraphNode_26.EdGraphPin_80445'
                 End Object
                 Begin Object Name="MaterialExpressionCameraVectorWS_0"
                    MaterialExpressionEditorX=-2768
                    MaterialExpressionEditorY=656
                    MaterialExpressionGuid=7E6C9D1D48174B478F2CCDB70BEE923A
                    Material=Material'/Engine/Transient.Material_0'
                 End Object
                 MaterialExpression=MaterialExpressionCameraVectorWS'MaterialExpressionCameraVectorWS_0'
                 Pins(0)=EdGraphPin'EdGraphPin_80468'
                 NodePosX=-2768
                 NodePosY=656
                 NodeGuid=E15ADCF440DDE80130A7F88F7FCEBC60
              End Object
              Begin Object Class=MaterialGraphNode_Comment Name="MaterialGraphNode_Comment_4"
                 Begin Object Class=MaterialExpressionComment Name="MaterialExpressionComment_0"
                 End Object
                 Begin Object Name="MaterialExpressionComment_0"
                    SizeX=300
                    SizeY=320
                    Text="Light Source position in world space"
                    MaterialExpressionEditorX=-2720
                    MaterialExpressionEditorY=200
                    MaterialExpressionGuid=F7B35E8248FAB1C002C2FC9D02F485C5
                    Function=MaterialFunction'/Engine/Transient.F_Specular'
                 End Object
                 MaterialExpressionComment=MaterialExpressionComment'MaterialExpressionComment_0'
                 NodePosX=-2720
                 NodePosY=200
                 NodeWidth=300
                 NodeHeight=320
                 NodeComment="Light Source position in world space"
                 NodeGuid=33A0A9454713929DDC6337A64BD275BA
              End Object
              Begin Object Class=MaterialGraphNode_Comment Name="MaterialGraphNode_Comment_5"
                 Begin Object Class=MaterialExpressionComment Name="MaterialExpressionComment_1"
                 End Object
                 Begin Object Name="MaterialExpressionComment_1"
                    SizeX=380
                    SizeY=260
                    Text="Phong size (greater power is smaller phong)"
                    MaterialExpressionEditorX=-760
                    MaterialExpressionEditorY=320
                    MaterialExpressionGuid=9E3A2D8348BBF1FC2A883795EE938C45
                    Function=MaterialFunction'/Engine/Transient.F_Specular'
                 End Object
                 MaterialExpressionComment=MaterialExpressionComment'MaterialExpressionComment_1'
                 NodePosX=-760
                 NodePosY=320
                 NodeWidth=380
                 NodeHeight=260
                 NodeComment="Phong size (greater power is smaller phong)"
                 NodeGuid=87FB6DFD401D6E01AC8ECAB35A601097
              End Object
              Begin Object Class=MaterialGraphNode_Comment Name="MaterialGraphNode_Comment_6"
                 Begin Object Class=MaterialExpressionComment Name="MaterialExpressionComment_2"
                 End Object
                 Begin Object Name="MaterialExpressionComment_2"
                    SizeX=180
                    SizeY=400
                    Text="Only draw specular if reflected light is towards camera"
                    MaterialExpressionEditorX=-1160
                    MaterialExpressionEditorY=120
                    MaterialExpressionGuid=15F251BF47F74FDAB63748971DF9F53D
                    Function=MaterialFunction'/Engine/Transient.F_Specular'
                 End Object
                 MaterialExpressionComment=MaterialExpressionComment'MaterialExpressionComment_2'
                 NodePosX=-1160
                 NodePosY=120
                 NodeWidth=180
                 NodeHeight=400
                 NodeComment="Only draw specular if reflected light is towards camera"
                 NodeGuid=27CE19A44B0EE0DAB995E083357D9AB8
              End Object
              Begin Object Class=MaterialGraphNode_Comment Name="MaterialGraphNode_Comment_7"
                 Begin Object Class=MaterialExpressionComment Name="MaterialExpressionComment_3"
                 End Object
                 Begin Object Name="MaterialExpressionComment_3"
                    SizeX=200
                    SizeY=520
                    Text="Only draw specular if surface is facing the camera"
                    MaterialExpressionEditorX=-1540
                    MaterialExpressionEditorY=80
                    MaterialExpressionGuid=1B2E9F4C4F3D096CD7385CBE34C8841F
                    Function=MaterialFunction'/Engine/Transient.F_Specular'
                 End Object
                 MaterialExpressionComment=MaterialExpressionComment'MaterialExpressionComment_3'
                 NodePosX=-1540
                 NodePosY=80
                 NodeWidth=200
                 NodeHeight=520
                 NodeComment="Only draw specular if surface is facing the camera"
                 NodeGuid=1F8AAEF44FC5EA13D84D549E0456F149
              End Object

              Comment


                #8
                Hey man thanks for the tutorial! But when I try this my entire material becomes bright white. Any idea what I could be doing wrong?

                Comment


                  #9
                  Hmmm, no not really. It could be anything. Just play around with the camera, change some values of the constants. One of them should get you on the right track.

                  Comment

                  Working...
                  X