浏览代码

Input Part 3

- Final for now
- No texture nodes
- No gradient nodes
- Havent check parity
- Fixes for PR
/main
Matt Dean 7 年前
当前提交
a02b954a
共有 29 个文件被更改,包括 196 次插入67 次删除
  1. 8
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Basic/ConstantNode.cs
  2. 5
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Scene/LightProbeNode.cs
  3. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Time/SinTimeNode.cs
  4. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Time/TimeNode.cs
  5. 5
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Texture/TextureSamplerNode.cs
  6. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Gradient/GradientNode.cs
  7. 64
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Basic/TimeNode.cs
  8. 11
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Basic/TimeNode.cs.meta
  9. 97
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/ScreenPositionNode.cs
  10. 8
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Gradient.meta
  11. 59
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Scene/ScreenPosNode.cs
  12. 0
      /MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Texture/SamplerStateNode.cs.meta
  13. 0
      /MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Texture/TextureSamplerNode.cs.meta
  14. 0
      /MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Texture/SamplerStateNode.cs
  15. 0
      /MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Texture/TextureSamplerNode.cs
  16. 0
      /MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Gradient/GradientNode.cs.meta
  17. 0
      /MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Gradient/GradientNode.cs
  18. 0
      /MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/GeometryNode.cs.meta
  19. 0
      /MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Interfaces/IMayRequireBitangent.cs.meta
  20. 0
      /MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Interfaces/IMayRequirePosition.cs.meta
  21. 0
      /MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Interfaces/IMayRequireTangent.cs.meta
  22. 0
      /MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Interfaces/IMayRequireViewDirection.cs.meta
  23. 0
      /MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/GeometryNode.cs
  24. 0
      /MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Interfaces/IMayRequireBitangent.cs
  25. 0
      /MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Interfaces/IMayRequirePosition.cs
  26. 0
      /MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Interfaces/IMayRequireTangent.cs
  27. 0
      /MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Interfaces/IMayRequireViewDirection.cs
  28. 0
      /MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/ScreenPositionNode.cs.meta

8
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Basic/ConstantNode.cs


using System.Collections.Generic;
using UnityEditor.MaterialGraph.Drawing.Controls;
using UnityEngine.Graphing;
using UnityEditor.ShaderGraph.Drawing.Controls;
using UnityEngine;
using UnityEditor.ShaderGraph;
using UnityEditor.Graphing;
namespace UnityEngine.MaterialGraph
namespace UnityEditor.ShaderGraph
{
public enum ConstantType
{

5
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Scene/LightProbeNode.cs


using System.Reflection;
using UnityEngine;
namespace UnityEngine.MaterialGraph
namespace UnityEditor.ShaderGraph
//public override bool hasPreview { get { return false; } }
public override bool hasPreview { get { return false; } }
public LightProbeNode()
{

2
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Time/SinTimeNode.cs


namespace UnityEditor.ShaderGraph
{
/*
[Title("Input/Time/Sine Time")]
public class SinTimeNode : AbstractMaterialNode, IMayRequireTime
{

return true;
}
}
*/
}

2
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Time/TimeNode.cs


namespace UnityEditor.ShaderGraph
{
/*
[Title("Input/Time/Time")]
public class TimeNode : AbstractMaterialNode, IMayRequireTime
{

return true;
}
}
*/
}

5
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Texture/TextureSamplerNode.cs


namespace UnityEditor.ShaderGraph
{
[Title("Texture/Sample 2D")]
/*
[Title("Input/Texture/Sample 2D")]
public class Sample2DTexture : AbstractMaterialNode, IGeneratesBodyCode, IMayRequireMeshUV
{
public const int OutputSlotRGBAId = 0;

var edges = owner.GetEdges(uvSlot.slotReference).ToList();
return edges.Count == 0;
}
}
}*/
}

2
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Gradient/GradientNode.cs


namespace UnityEditor.ShaderGraph
{
[Title("Input/Basic/Gradient")]
[Title("Input/Gradient/Gradient 2D")]
public class GradientNode : AbstractMaterialNode, IGeneratesBodyCode
{
Gradient m_Gradient = new Gradient();

64
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Basic/TimeNode.cs


using UnityEngine;
using UnityEditor.Graphing;
namespace UnityEditor.ShaderGraph
{
[Title("Input/Basic/Time")]
public class TimeNode : AbstractMaterialNode, IMayRequireTime
{
private const string kOutputSlotName = "Time";
private const string kOutputSlot1Name = "SinTime";
private const string kOutputSlot2Name = "CosTime";
private const string kOutputSlot3Name = "DeltaTime";
private const string kOutputSlot4Name = "SmoothDelta";
public const int OutputSlotId = 0;
public const int OutputSlot1Id = 1;
public const int OutputSlot2Id = 2;
public const int OutputSlot3Id = 3;
public const int OutputSlot4Id = 4;
public TimeNode()
{
name = "Time";
UpdateNodeAfterDeserialization();
}
public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new Vector1MaterialSlot(OutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, 0));
AddSlot(new Vector1MaterialSlot(OutputSlot1Id, kOutputSlot1Name, kOutputSlot1Name, SlotType.Output, 0));
AddSlot(new Vector1MaterialSlot(OutputSlot2Id, kOutputSlot2Name, kOutputSlot2Name, SlotType.Output, 0));
AddSlot(new Vector1MaterialSlot(OutputSlot3Id, kOutputSlot3Name, kOutputSlot3Name, SlotType.Output, 0));
AddSlot(new Vector1MaterialSlot(OutputSlot4Id, kOutputSlot4Name, kOutputSlot4Name, SlotType.Output, 0));
RemoveSlotsNameNotMatching(validSlots);
}
protected int[] validSlots
{
get { return new[] { OutputSlotId, OutputSlot1Id, OutputSlot2Id, OutputSlot3Id, OutputSlot4Id }; }
}
public override string GetVariableNameForSlot(int slotId)
{
switch (slotId)
{
case OutputSlot1Id:
return "_SinTime.w";
case OutputSlot2Id:
return "_CosTime.w";
case OutputSlot3Id:
return "unity_DeltaTime.x";
case OutputSlot4Id:
return "unity_DeltaTime.z";
default:
return "_Time.y";
}
}
public bool RequiresTime()
{
return true;
}
}
}

11
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Basic/TimeNode.cs.meta


fileFormatVersion: 2
guid: 66310de0dabd3074aa56ab7714324cc0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

97
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/ScreenPositionNode.cs


using System.Reflection;
using UnityEngine;
using UnityEditor.Graphing;
using UnityEditor.ShaderGraph.Drawing.Controls;
namespace UnityEditor.ShaderGraph
{
public interface IMayRequireScreenPosition
{
bool RequiresScreenPosition();
}
public enum ScreenSpaceType
{
Default,
Center,
Tiled
};
[Title("Input/Geometry/Screen Position")]
public class ScreenPositionNode : AbstractMaterialNode, IGeneratesBodyCode, IMayRequireScreenPosition
{
public ScreenPositionNode()
{
name = "Screen Position";
UpdateNodeAfterDeserialization();
}
[SerializeField]
private ScreenSpaceType m_ScreenSpaceType = ScreenSpaceType.Default;
[EnumControl("")]
public ScreenSpaceType screenSpaceType
{
get { return m_ScreenSpaceType; }
set
{
if (m_ScreenSpaceType == value)
return;
m_ScreenSpaceType = value;
if (onModified != null)
{
onModified(this, ModificationScope.Graph);
}
}
}
string GetCurrentType()
{
return System.Enum.GetName(typeof(ScreenSpaceType), m_ScreenSpaceType);
}
private const int kOutputSlot1Id = 0;
private const string kOutputSlot1Name = "Out";
public override bool hasPreview { get { return true; } }
public override PreviewMode previewMode
{
get { return PreviewMode.Preview2D; }
}
public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new Vector2MaterialSlot(kOutputSlot1Id, kOutputSlot1Name, kOutputSlot1Name, SlotType.Output, Vector2.zero));
RemoveSlotsNameNotMatching(new[] { kOutputSlot1Id });
}
public override string GetVariableNameForSlot(int slotId)
{
return ShaderGeneratorNames.ScreenPosition;
}
public void GenerateNodeCode(ShaderGenerator visitor, GenerationMode generationMode)
{
switch (m_ScreenSpaceType)
{
case ScreenSpaceType.Center:
visitor.AddShaderChunk(string.Format("{0} = {1};", ShaderGeneratorNames.ScreenPosition, "float4((" + ShaderGeneratorNames.ScreenPosition + ".xy / " + ShaderGeneratorNames.ScreenPosition + ".w) * 2 - 1, 0, 0)"), false);
break;
case ScreenSpaceType.Tiled:
visitor.AddShaderChunk(string.Format("{0} = {1};", ShaderGeneratorNames.ScreenPosition, "float4((" + ShaderGeneratorNames.ScreenPosition + ".xy / " + ShaderGeneratorNames.ScreenPosition + ".w) * 2 - 1, 0, 0)"), false);
visitor.AddShaderChunk(string.Format("{0} = {1};", ShaderGeneratorNames.ScreenPosition, "float4(" + ShaderGeneratorNames.ScreenPosition + ".x * _ScreenParams.x / _ScreenParams.y, " + ShaderGeneratorNames.ScreenPosition + ".y, 0, 0)"), false);
break;
default:
visitor.AddShaderChunk(string.Format("{0} = {1};", ShaderGeneratorNames.ScreenPosition, "float4(" + ShaderGeneratorNames.ScreenPosition + ".xy / " + ShaderGeneratorNames.ScreenPosition + ".w, 0, 0)"), false);
break;
}
}
public bool RequiresScreenPosition()
{
return true;
}
}
}

8
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Gradient.meta


fileFormatVersion: 2
guid: 4655415e388e6914ebefaaf9e2148ff1
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

59
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Scene/ScreenPosNode.cs


using UnityEngine;
using UnityEditor.Graphing;
namespace UnityEditor.ShaderGraph
{
public interface IMayRequireScreenPosition
{
bool RequiresScreenPosition();
}
[Title("Input/Scene Data/Screen Position")]
public class ScreenPosNode : AbstractMaterialNode, IMayRequireScreenPosition
{
public ScreenPosNode()
{
name = "ScreenPosition";
UpdateNodeAfterDeserialization();
}
private const int kOutputSlot1Id = 0;
private const string kOutputSlot1Name = "Raw ScreenPos";
private const int kOutputSlot2Id = 1;
private const string kOutputSlot2Name = "Normalized";
public override bool hasPreview { get { return true; } }
public override PreviewMode previewMode
{
get { return PreviewMode.Preview2D; }
}
public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new Vector4MaterialSlot(kOutputSlot1Id, kOutputSlot1Name, kOutputSlot1Name, SlotType.Output, Vector4.zero));
AddSlot(new Vector3MaterialSlot(kOutputSlot2Id, kOutputSlot2Name, kOutputSlot2Name, SlotType.Output, Vector3.zero));
RemoveSlotsNameNotMatching(new[] { kOutputSlot1Id, kOutputSlot2Id });
}
public override string GetVariableNameForSlot(int slotId)
{
string returnString = "";
switch (slotId)
{
case 0:
returnString = ShaderGeneratorNames.ScreenPosition;
break;
case 1:
returnString = "float3(" + ShaderGeneratorNames.ScreenPosition + ".xy / " + ShaderGeneratorNames.ScreenPosition + ".w, 0)";
break;
}
return returnString;
}
public bool RequiresScreenPosition()
{
return true;
}
}
}

/MaterialGraphProject/Assets/NewNodes/Editor/Keep/SamplerStateNode.cs.meta → /MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Texture/SamplerStateNode.cs.meta

/MaterialGraphProject/Assets/NewNodes/Editor/Keep/TextureSamplerNode.cs.meta → /MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Texture/TextureSamplerNode.cs.meta

/MaterialGraphProject/Assets/NewNodes/Editor/Keep/SamplerStateNode.cs → /MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Texture/SamplerStateNode.cs

/MaterialGraphProject/Assets/NewNodes/Editor/Keep/TextureSamplerNode.cs → /MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Texture/TextureSamplerNode.cs

/MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Basic/GradientNode.cs.meta → /MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Gradient/GradientNode.cs.meta

/MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Basic/GradientNode.cs → /MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Gradient/GradientNode.cs

/MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/GeometryNode.cs.meta → /MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/GeometryNode.cs.meta

/MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/IMayRequireBitangent.cs.meta → /MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Interfaces/IMayRequireBitangent.cs.meta

/MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/IMayRequirePosition.cs.meta → /MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Interfaces/IMayRequirePosition.cs.meta

/MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/IMayRequireTangent.cs.meta → /MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Interfaces/IMayRequireTangent.cs.meta

/MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/IMayRequireViewDirection.cs.meta → /MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Interfaces/IMayRequireViewDirection.cs.meta

/MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/GeometryNode.cs → /MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/GeometryNode.cs

/MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/IMayRequireBitangent.cs → /MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Interfaces/IMayRequireBitangent.cs

/MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/IMayRequirePosition.cs → /MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Interfaces/IMayRequirePosition.cs

/MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/IMayRequireTangent.cs → /MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Interfaces/IMayRequireTangent.cs

/MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/IMayRequireViewDirection.cs → /MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Interfaces/IMayRequireViewDirection.cs

/MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Scene/ScreenPosNode.cs.meta → /MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/ScreenPositionNode.cs.meta

正在加载...
取消
保存