浏览代码

[Material Graph]Split out lighting functions to different files

/main
Tim Cooper 8 年前
当前提交
480131e4
共有 5 个文件被更改,包括 143 次插入110 次删除
  1. 110
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Light/BaseLightFunction.cs
  2. 61
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Light/PBRMetalicLightFunction.cs
  3. 12
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Light/PBRMetalicLightFunction.cs.meta
  4. 58
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Light/PBRSpecularLightFunction.cs
  5. 12
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Light/PBRSpecularLightFunction.cs.meta

110
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Light/BaseLightFunction.cs


using System;
using UnityEngine.Graphing;
namespace UnityEngine.MaterialGraph
{

public virtual int GetFirstPassSlotId()
{
return NormalSlotId;
}
}
[Serializable]
public class PBRMetalicLightFunction : BaseLightFunction
{
public const string AlbedoSlotName = "Albedo";
public const string MetallicSlotName = "Metallic";
public const string EmissionSlotName = "Emission";
public const string SmoothnessSlotName = "Smoothness";
public const string OcclusionSlotName = "Occlusion";
public const string AlphaSlotName = "Alpha";
public const string LightFunctionName = "Standard";
public const string SurfaceOutputStructureName = "SurfaceOutputStandard";
public const int AlbedoSlotId = 0;
public const int MetallicSlotId = 2;
public const int EmissionSlotId = 3;
public const int SmoothnessSlotId = 4;
public const int OcclusionSlotId = 5;
public const int AlphaSlotId = 6;
public override string lightFunctionName
{
get { return LightFunctionName; }
}
public override string surfaceOutputStructureName
{
get { return SurfaceOutputStructureName; }
}
public override void DoSlotsForConfiguration(PixelShaderNode node)
{
node.AddSlot(new MaterialSlot(AlbedoSlotId, AlbedoSlotName, AlbedoSlotName, SlotType.Input, SlotValueType.Vector3, Vector4.zero));
node.AddSlot(new MaterialSlot(NormalSlotId, kNormalSlotName, kNormalSlotName, SlotType.Input, SlotValueType.Vector3, Vector4.zero));
node.AddSlot(new MaterialSlot(EmissionSlotId, EmissionSlotName, EmissionSlotName, SlotType.Input, SlotValueType.Vector3, Vector4.zero));
node.AddSlot(new MaterialSlot(MetallicSlotId, MetallicSlotName, MetallicSlotName, SlotType.Input, SlotValueType.Vector1, Vector4.zero));
node.AddSlot(new MaterialSlot(SmoothnessSlotId, SmoothnessSlotName, SmoothnessSlotName, SlotType.Input, SlotValueType.Vector1, Vector4.zero));
node.AddSlot(new MaterialSlot(OcclusionSlotId, OcclusionSlotName, OcclusionSlotName, SlotType.Input, SlotValueType.Vector1, Vector4.zero));
node.AddSlot(new MaterialSlot(AlphaSlotId, AlphaSlotName, AlphaSlotName, SlotType.Input, SlotValueType.Vector1, Vector4.zero));
// clear out slot names that do not match the slots
// we support
node.RemoveSlotsNameNotMatching(
new[]
{
AlbedoSlotId,
NormalSlotId,
EmissionSlotId,
MetallicSlotId,
SmoothnessSlotId,
OcclusionSlotId,
AlphaSlotId
});
}
}
[Serializable]
public class PBRSpecularLightFunction : BaseLightFunction
{
public const string kAlbedoSlotName = "Albedo";
public const string kSpecularSlotName = "Specular";
public const string kEmissionSlotName = "Emission";
public const string kSmoothnessSlotName = "Smoothness";
public const string kOcclusionSlotName = "Occlusion";
public const string kAlphaSlotName = "Alpha";
public const int kAlbedoSlotId = 0;
public const int kSpecularSlotId = 2;
public const int kEmissionSlotId = 3;
public const int kSmoothnessSlotId = 4;
public const int kOcclusionSlotId = 5;
public const int kAlphaSlotId = 6;
public override string lightFunctionName
{
get { return "StandardSpecular"; }
}
public override string surfaceOutputStructureName
{
get { return "SurfaceOutputStandardSpecular"; }
}
public override void DoSlotsForConfiguration(PixelShaderNode node)
{
node.AddSlot(new MaterialSlot(kAlbedoSlotId, kAlbedoSlotName, kAlbedoSlotName, SlotType.Input, SlotValueType.Vector3, Vector4.zero));
node.AddSlot(new MaterialSlot(NormalSlotId, kNormalSlotName, kNormalSlotName, SlotType.Input, SlotValueType.Vector3, Vector4.zero));
node.AddSlot(new MaterialSlot(kSpecularSlotId, kSpecularSlotName, kSpecularSlotName, SlotType.Input, SlotValueType.Vector3, Vector4.zero));
node.AddSlot(new MaterialSlot(kEmissionSlotId, kEmissionSlotName, kEmissionSlotName, SlotType.Input, SlotValueType.Vector3, Vector4.zero));
node.AddSlot(new MaterialSlot(kSmoothnessSlotId, kSmoothnessSlotName, kSmoothnessSlotName, SlotType.Input, SlotValueType.Vector1, Vector4.zero));
node.AddSlot(new MaterialSlot(kOcclusionSlotId, kOcclusionSlotName, kOcclusionSlotName, SlotType.Input, SlotValueType.Vector1, Vector4.zero));
node.AddSlot(new MaterialSlot(kAlphaSlotId, kAlphaSlotName, kAlphaSlotName, SlotType.Input, SlotValueType.Vector1, Vector4.zero));
// clear out slot names that do not match the slots
// we support
node.RemoveSlotsNameNotMatching(
new[]
{
kAlbedoSlotId,
NormalSlotId,
kSpecularSlotId,
kEmissionSlotId,
kSmoothnessSlotId,
kOcclusionSlotId,
kAlphaSlotId
});
}
}
}

61
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Light/PBRMetalicLightFunction.cs


using System;
using UnityEngine.Graphing;
namespace UnityEngine.MaterialGraph
{
[Serializable]
public class PBRMetalicLightFunction : BaseLightFunction
{
public const string AlbedoSlotName = "Albedo";
public const string MetallicSlotName = "Metallic";
public const string EmissionSlotName = "Emission";
public const string SmoothnessSlotName = "Smoothness";
public const string OcclusionSlotName = "Occlusion";
public const string AlphaSlotName = "Alpha";
public const string LightFunctionName = "Standard";
public const string SurfaceOutputStructureName = "SurfaceOutputStandard";
public const int AlbedoSlotId = 0;
public const int MetallicSlotId = 2;
public const int EmissionSlotId = 3;
public const int SmoothnessSlotId = 4;
public const int OcclusionSlotId = 5;
public const int AlphaSlotId = 6;
public override string lightFunctionName
{
get { return LightFunctionName; }
}
public override string surfaceOutputStructureName
{
get { return SurfaceOutputStructureName; }
}
public override void DoSlotsForConfiguration(PixelShaderNode node)
{
node.AddSlot(new MaterialSlot(AlbedoSlotId, AlbedoSlotName, AlbedoSlotName, SlotType.Input, SlotValueType.Vector3, Vector4.zero));
node.AddSlot(new MaterialSlot(NormalSlotId, kNormalSlotName, kNormalSlotName, SlotType.Input, SlotValueType.Vector3, Vector4.zero));
node.AddSlot(new MaterialSlot(EmissionSlotId, EmissionSlotName, EmissionSlotName, SlotType.Input, SlotValueType.Vector3, Vector4.zero));
node.AddSlot(new MaterialSlot(MetallicSlotId, MetallicSlotName, MetallicSlotName, SlotType.Input, SlotValueType.Vector1, Vector4.zero));
node.AddSlot(new MaterialSlot(SmoothnessSlotId, SmoothnessSlotName, SmoothnessSlotName, SlotType.Input, SlotValueType.Vector1, Vector4.zero));
node.AddSlot(new MaterialSlot(OcclusionSlotId, OcclusionSlotName, OcclusionSlotName, SlotType.Input, SlotValueType.Vector1, Vector4.zero));
node.AddSlot(new MaterialSlot(AlphaSlotId, AlphaSlotName, AlphaSlotName, SlotType.Input, SlotValueType.Vector1, Vector4.zero));
// clear out slot names that do not match the slots
// we support
node.RemoveSlotsNameNotMatching(
new[]
{
AlbedoSlotId,
NormalSlotId,
EmissionSlotId,
MetallicSlotId,
SmoothnessSlotId,
OcclusionSlotId,
AlphaSlotId
});
}
}
}

12
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Light/PBRMetalicLightFunction.cs.meta


fileFormatVersion: 2
guid: 64e4baa4ca6aac847b9fdd022c9ab494
timeCreated: 1470127749
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

58
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Light/PBRSpecularLightFunction.cs


using System;
using UnityEngine.Graphing;
namespace UnityEngine.MaterialGraph
{
[Serializable]
public class PBRSpecularLightFunction : BaseLightFunction
{
public const string kAlbedoSlotName = "Albedo";
public const string kSpecularSlotName = "Specular";
public const string kEmissionSlotName = "Emission";
public const string kSmoothnessSlotName = "Smoothness";
public const string kOcclusionSlotName = "Occlusion";
public const string kAlphaSlotName = "Alpha";
public const int kAlbedoSlotId = 0;
public const int kSpecularSlotId = 2;
public const int kEmissionSlotId = 3;
public const int kSmoothnessSlotId = 4;
public const int kOcclusionSlotId = 5;
public const int kAlphaSlotId = 6;
public override string lightFunctionName
{
get { return "StandardSpecular"; }
}
public override string surfaceOutputStructureName
{
get { return "SurfaceOutputStandardSpecular"; }
}
public override void DoSlotsForConfiguration(PixelShaderNode node)
{
node.AddSlot(new MaterialSlot(kAlbedoSlotId, kAlbedoSlotName, kAlbedoSlotName, SlotType.Input, SlotValueType.Vector3, Vector4.zero));
node.AddSlot(new MaterialSlot(NormalSlotId, kNormalSlotName, kNormalSlotName, SlotType.Input, SlotValueType.Vector3, Vector4.zero));
node.AddSlot(new MaterialSlot(kSpecularSlotId, kSpecularSlotName, kSpecularSlotName, SlotType.Input, SlotValueType.Vector3, Vector4.zero));
node.AddSlot(new MaterialSlot(kEmissionSlotId, kEmissionSlotName, kEmissionSlotName, SlotType.Input, SlotValueType.Vector3, Vector4.zero));
node.AddSlot(new MaterialSlot(kSmoothnessSlotId, kSmoothnessSlotName, kSmoothnessSlotName, SlotType.Input, SlotValueType.Vector1, Vector4.zero));
node.AddSlot(new MaterialSlot(kOcclusionSlotId, kOcclusionSlotName, kOcclusionSlotName, SlotType.Input, SlotValueType.Vector1, Vector4.zero));
node.AddSlot(new MaterialSlot(kAlphaSlotId, kAlphaSlotName, kAlphaSlotName, SlotType.Input, SlotValueType.Vector1, Vector4.zero));
// clear out slot names that do not match the slots
// we support
node.RemoveSlotsNameNotMatching(
new[]
{
kAlbedoSlotId,
NormalSlotId,
kSpecularSlotId,
kEmissionSlotId,
kSmoothnessSlotId,
kOcclusionSlotId,
kAlphaSlotId
});
}
}
}

12
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Light/PBRSpecularLightFunction.cs.meta


fileFormatVersion: 2
guid: 5dc7e9bab3ce3ee40b1ae67470605456
timeCreated: 1470127749
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存