浏览代码

Merge pull request #250 from Unity-Technologies/bound-type-defualt-slots

Bound type default slots
/main
GitHub 7 年前
当前提交
998d8e22
共有 7 个文件被更改,包括 51 次插入6 次删除
  1. 7
      com.unity.shadergraph/Editor/Data/Graphs/BitangentMaterialSlot.cs
  2. 8
      com.unity.shadergraph/Editor/Data/Graphs/NormalMaterialSlot.cs
  3. 8
      com.unity.shadergraph/Editor/Data/Graphs/PositionMaterialSlot.cs
  4. 8
      com.unity.shadergraph/Editor/Data/Graphs/TangentMaterialSlot.cs
  5. 7
      com.unity.shadergraph/Editor/Data/Graphs/VertexColorMaterialSlot.cs
  6. 7
      com.unity.shadergraph/Editor/Data/Graphs/ViewDirectionMaterialSlot.cs
  7. 12
      com.unity.shadergraph/Editor/Data/MasterNodes/PBRMasterNode.cs

7
com.unity.shadergraph/Editor/Data/Graphs/BitangentMaterialSlot.cs


using System;
using UnityEditor.ShaderGraph.Drawing.Slots;
using UnityEngine.Experimental.UIElements;
namespace UnityEditor.ShaderGraph
{

ShaderStage shaderStage = ShaderStage.Dynamic, bool hidden = false)
: base(slotId, displayName, shaderOutputName, space, shaderStage, hidden)
{}
public override VisualElement InstantiateControl()
{
return new LabelSlotControlView(space + " Space");
}
public override string GetDefaultValue(GenerationMode generationMode)
{

8
com.unity.shadergraph/Editor/Data/Graphs/NormalMaterialSlot.cs


using System;
using UnityEngine;
using UnityEditor.ShaderGraph.Drawing.Slots;
using UnityEngine.Experimental.UIElements;
namespace UnityEditor.ShaderGraph
{

ShaderStage shaderStage = ShaderStage.Dynamic, bool hidden = false)
: base(slotId, displayName, shaderOutputName, space, shaderStage, hidden)
{}
public override VisualElement InstantiateControl()
{
return new LabelSlotControlView(space + " Space");
}
public override string GetDefaultValue(GenerationMode generationMode)
{

8
com.unity.shadergraph/Editor/Data/Graphs/PositionMaterialSlot.cs


using System;
using UnityEngine;
using UnityEditor.ShaderGraph.Drawing.Slots;
using UnityEngine.Experimental.UIElements;
namespace UnityEditor.ShaderGraph
{

ShaderStage shaderStage = ShaderStage.Dynamic, bool hidden = false)
: base(slotId, displayName, shaderOutputName, space, shaderStage, hidden)
{}
public override VisualElement InstantiateControl()
{
return new LabelSlotControlView(space + " Space");
}
public override string GetDefaultValue(GenerationMode generationMode)
{

8
com.unity.shadergraph/Editor/Data/Graphs/TangentMaterialSlot.cs


using System;
using UnityEngine;
using UnityEditor.ShaderGraph.Drawing.Slots;
using UnityEngine.Experimental.UIElements;
namespace UnityEditor.ShaderGraph
{

ShaderStage shaderStage = ShaderStage.Dynamic, bool hidden = false)
: base(slotId, displayName, shaderOutputName, space, shaderStage, hidden)
{}
public override VisualElement InstantiateControl()
{
return new LabelSlotControlView(space + " Space");
}
public override string GetDefaultValue(GenerationMode generationMode)
{

7
com.unity.shadergraph/Editor/Data/Graphs/VertexColorMaterialSlot.cs


using System;
using UnityEditor.Graphing;
using UnityEngine;
using UnityEditor.ShaderGraph.Drawing.Slots;
using UnityEngine.Experimental.UIElements;
namespace UnityEditor.ShaderGraph
{

ShaderStage shaderStage = ShaderStage.Dynamic, bool hidden = false)
: base(slotId, displayName, shaderOutputName, SlotType.Input, Vector3.zero, shaderStage, hidden)
{}
public override VisualElement InstantiateControl()
{
return new LabelSlotControlView("Vertex Color");
}
public override string GetDefaultValue(GenerationMode generationMode)
{

7
com.unity.shadergraph/Editor/Data/Graphs/ViewDirectionMaterialSlot.cs


using System;
using UnityEngine;
using UnityEditor.ShaderGraph.Drawing.Slots;
using UnityEngine.Experimental.UIElements;
namespace UnityEditor.ShaderGraph
{

ShaderStage shaderStage = ShaderStage.Dynamic, bool hidden = false)
: base(slotId, displayName, shaderOutputName, space, shaderStage, hidden)
{}
public override VisualElement InstantiateControl()
{
return new LabelSlotControlView(space + " Space");
}
public override string GetDefaultValue(GenerationMode generationMode)
{

12
com.unity.shadergraph/Editor/Data/MasterNodes/PBRMasterNode.cs


using System;
using System.Linq;
using System.Collections.Generic;
using UnityEditor.Graphing;
using UnityEditor.ShaderGraph.Drawing.Controls;
using UnityEngine;

[Serializable]
[Title("Master", "PBR")]
public class PBRMasterNode : MasterNode<IPBRSubShader>
public class PBRMasterNode : MasterNode<IPBRSubShader>, IMayRequireNormal
{
public const string AlbedoSlotName = "Albedo";
public const string NormalSlotName = "Normal";

base.UpdateNodeAfterDeserialization();
name = "PBR Master";
AddSlot(new ColorRGBMaterialSlot(AlbedoSlotId, AlbedoSlotName, AlbedoSlotName, SlotType.Input, Color.grey, ShaderStage.Fragment));
AddSlot(new Vector3MaterialSlot(NormalSlotId, NormalSlotName, NormalSlotName, SlotType.Input, new Vector3(0, 0, 1), ShaderStage.Fragment));
AddSlot(new NormalMaterialSlot(NormalSlotId, NormalSlotName, NormalSlotName, CoordinateSpace.Tangent, ShaderStage.Fragment));
AddSlot(new ColorRGBMaterialSlot(EmissionSlotId, EmissionSlotName, EmissionSlotName, SlotType.Input, Color.black, ShaderStage.Fragment));
if (model == Model.Metallic)
AddSlot(new Vector1MaterialSlot(MetallicSlotId, MetallicSlotName, MetallicSlotName, SlotType.Input, 0, ShaderStage.Fragment));

AlphaSlotId,
AlphaThresholdSlotId
}, true);
}
public NeededCoordinateSpace RequiresNormal()
{
List<ISlot> slots = new List<ISlot>();
GetSlots(slots);
return slots.OfType<IMayRequireNormal>().Aggregate(NeededCoordinateSpace.None, (mask, node) => mask | node.RequiresNormal());
}
}
}
正在加载...
取消
保存