using System.Collections.Generic ;
using UnityEditor.Graphs ;
namespace UnityEditor.MaterialGraph
public const string kNormalSlotName = "Normal" ;
public virtual string GetLightFunctionName ( ) { return "" ; }
public virtual string GetSurfaceOutputStructureName ( ) { return "" ; }
public virtual void GenerateLightFunctionBody ( ShaderGenerator visitor ) { }
visitor . AddPragmaChunk ( GetSurfaceOutputStructureName ( ) ) ;
}
public virtual IEnumerable < Slot > FilterSlots ( List < Slot > slots )
public abstract void DoSlotsForConfiguration ( PixelShaderNode node ) ;
public virtual string GetFirstPassSlotName ( )
return new List < Slot > ( ) ;
return kNormalSlotName ;
public const string kAlbedoSlotName = "Albedo" ;
public const string kEmissionSlotName = "Emission" ;
public const string kMetallicSlotName = "Metallic" ;
public const string kSmoothnessSlotName = "Smoothness" ;
public const string kOcclusion = "Occlusion" ;
public const string kAlphaSlotName = "Alpha" ;
public override void DoSlotsForConfiguration ( PixelShaderNode node )
{
node . AddSlot ( new MaterialGraphSlot ( new Slot ( SlotType . InputSlot , kAlbedoSlotName ) , SlotValueType . Vector3 ) ) ;
node . AddSlot ( new MaterialGraphSlot ( new Slot ( SlotType . InputSlot , kNormalSlotName ) , SlotValueType . Vector3 ) ) ;
node . AddSlot ( new MaterialGraphSlot ( new Slot ( SlotType . InputSlot , kEmissionSlotName ) , SlotValueType . Vector3 ) ) ;
node . AddSlot ( new MaterialGraphSlot ( new Slot ( SlotType . InputSlot , kMetallicSlotName ) , SlotValueType . Vector1 ) ) ;
node . AddSlot ( new MaterialGraphSlot ( new Slot ( SlotType . InputSlot , kSmoothnessSlotName ) , SlotValueType . Vector1 ) ) ;
node . AddSlot ( new MaterialGraphSlot ( new Slot ( SlotType . InputSlot , kOcclusion ) , SlotValueType . Vector1 ) ) ;
node . AddSlot ( new MaterialGraphSlot ( new Slot ( SlotType . InputSlot , kAlphaSlotName ) , SlotValueType . Vector1 ) ) ;
public override IEnumerable < Slot > FilterSlots ( List < Slot > slots )
{
var rSlots = new List < Slot > ( ) ;
foreach ( var slot in slots )
{
switch ( slot . name )
// clear out slot names that do not match the slots
// we support
node . RemoveSlotsNameNotMatching (
new [ ]
case PixelShaderNode . kAlbedoSlotName :
case PixelShaderNode . kNormalSlotName :
case PixelShaderNode . kEmissionSlotName :
case PixelShaderNode . kMetallicSlotName :
case PixelShaderNode . kSmoothnessSlotName :
case PixelShaderNode . kOcclusion :
case PixelShaderNode . kAlphaSlotName :
rSlots . Add ( slot ) ;
break ;
}
}
return rSlots ;
kAlbedoSlotName ,
kNormalSlotName ,
kEmissionSlotName ,
kMetallicSlotName ,
kSmoothnessSlotName ,
kOcclusion ,
kAlphaSlotName
} ) ;
public const string kAlbedoSlotName = "Albedo" ;
public const string kSpecularSlotName = "Specular" ;
public const string kEmissionSlotName = "Emission" ;
public const string kSmoothnessSlotName = "Smoothness" ;
public const string kOcclusion = "Occlusion" ;
public const string kAlphaSlotName = "Alpha" ;
public override IEnumerable < Slot > FilterSlots ( List < Slot > slots )
public override void DoSlotsForConfiguration ( PixelShaderNode node )
var rSlots = new List < Slot > ( ) ;
foreach ( var slot in slots )
{
switch ( slot . name )
node . AddSlot ( new MaterialGraphSlot ( new Slot ( SlotType . InputSlot , kAlbedoSlotName ) , SlotValueType . Vector3 ) ) ;
node . AddSlot ( new MaterialGraphSlot ( new Slot ( SlotType . InputSlot , kNormalSlotName ) , SlotValueType . Vector3 ) ) ;
node . AddSlot ( new MaterialGraphSlot ( new Slot ( SlotType . InputSlot , kSpecularSlotName ) , SlotValueType . Vector3 ) ) ;
node . AddSlot ( new MaterialGraphSlot ( new Slot ( SlotType . InputSlot , kEmissionSlotName ) , SlotValueType . Vector3 ) ) ;
node . AddSlot ( new MaterialGraphSlot ( new Slot ( SlotType . InputSlot , kSmoothnessSlotName ) , SlotValueType . Vector1 ) ) ;
node . AddSlot ( new MaterialGraphSlot ( new Slot ( SlotType . InputSlot , kOcclusion ) , SlotValueType . Vector1 ) ) ;
node . AddSlot ( new MaterialGraphSlot ( new Slot ( SlotType . InputSlot , kAlphaSlotName ) , SlotValueType . Vector1 ) ) ;
// clear out slot names that do not match the slots
// we support
node . RemoveSlotsNameNotMatching (
new [ ]
case PixelShaderNode . kAlbedoSlotName :
case PixelShaderNode . kSpecularSlotName :
case PixelShaderNode . kNormalSlotName :
case PixelShaderNode . kEmissionSlotName :
case PixelShaderNode . kSmoothnessSlotName :
case PixelShaderNode . kOcclusion :
case PixelShaderNode . kAlphaSlotName :
rSlots . Add ( slot ) ;
break ;
}
}
return rSlots ;
kAlbedoSlotName ,
kNormalSlotName ,
kSpecularSlotName ,
kEmissionSlotName ,
kSmoothnessSlotName ,
kOcclusion ,
kAlphaSlotName
} ) ;
}
}
}