浏览代码

Maths Part 2

- Maths/Interpolation
- Maths/Round
- Fix merge conflict for PR
/main
Matt Dean 7 年前
当前提交
3ca3abee
共有 27 个文件被更改,包括 180 次插入179 次删除
  1. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Basic/ConstantNode.cs
  2. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/WorldSpaceTangentNode.cs
  3. 6
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Round/FloorNode.cs
  4. 6
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Round/RoundNode.cs
  5. 6
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Round/SignNode.cs
  6. 8
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Round/StepNode.cs
  7. 6
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Round/TruncateNode.cs
  8. 7
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Vector/TransformNode.cs
  9. 31
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Interpolation/InverseLinearInterpolationNode.cs
  10. 31
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Interpolation/LinearInterpolationNode.cs
  11. 31
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Interpolation/SmoothHermiteInterpolationNode.cs
  12. 30
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Round/CeilingNode.cs
  13. 35
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Vector/TangentToWorldNode.cs
  14. 35
      MaterialGraphProject/Assets/NewNodes/Editor/Keep/TangentToWorldNode.cs
  15. 31
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Interpolation/LerpNode.cs
  16. 31
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Interpolation/SmoothStepNode.cs
  17. 31
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Interpolation/InverseLerpNode.cs
  18. 30
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Round/CeilNode.cs
  19. 0
      /MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Interpolation/InverseLinearInterpolationNode.cs.meta
  20. 0
      /MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Interpolation/LinearInterpolationNode.cs.meta
  21. 0
      /MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Interpolation/SmoothHermiteInterpolationNode.cs.meta
  22. 0
      /MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Round/CeilingNode.cs.meta
  23. 0
      /MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Round/TruncateNode.cs.meta
  24. 0
      /MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Round/TruncateNode.cs
  25. 0
      /MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Vector/TangentToWorldNode.cs.meta
  26. 0
      /MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Vector/TransformNode.cs.meta
  27. 0
      /MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Vector/TransformNode.cs

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


public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new MaterialSlot(kOutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, SlotValueType.Vector1, Vector4.zero));
AddSlot(new Vector1MaterialSlot(kOutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, 0));
RemoveSlotsNameNotMatching(new[] { kOutputSlotId });
}

2
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/WorldSpaceTangentNode.cs


public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new MaterialSlot(kOutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, SlotValueType.Vector3, new Vector4(0, 0, 1, 1)));
AddSlot(new MaterialSlot(kOutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, SlotValueType.Vector4, new Vector4(0, 0, 1, 1)));
RemoveSlotsNameNotMatching(new[] { kOutputSlotId });
}

6
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Round/FloorNode.cs


}
static string Unity_Floor(
[Slot(0, Binding.None)] DynamicDimensionVector argument,
[Slot(1, Binding.None)] out DynamicDimensionVector result)
[Slot(0, Binding.None)] DynamicDimensionVector In,
[Slot(1, Binding.None)] out DynamicDimensionVector Out)
result = floor(argument);
Out = floor(In);
}
";
}

6
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Round/RoundNode.cs


}
static string Unity_Round(
[Slot(0, Binding.None)] DynamicDimensionVector argument,
[Slot(1, Binding.None)] out DynamicDimensionVector result)
[Slot(0, Binding.None)] DynamicDimensionVector In,
[Slot(1, Binding.None)] out DynamicDimensionVector Out)
result = round(argument);
Out = round(In);
}
";
}

6
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Round/SignNode.cs


}
static string Unity_Sign(
[Slot(0, Binding.None)] DynamicDimensionVector argument,
[Slot(1, Binding.None)] out DynamicDimensionVector result)
[Slot(0, Binding.None)] DynamicDimensionVector In,
[Slot(1, Binding.None)] out DynamicDimensionVector Out)
result = sign(argument);
Out = sign(In);
}
";
}

8
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Round/StepNode.cs


}
static string Unity_Step(
[Slot(0, Binding.None)] DynamicDimensionVector first,
[Slot(1, Binding.None)] DynamicDimensionVector second,
[Slot(2, Binding.None)] out DynamicDimensionVector result)
[Slot(0, Binding.None)] DynamicDimensionVector A,
[Slot(1, Binding.None)] DynamicDimensionVector B,
[Slot(2, Binding.None)] out DynamicDimensionVector Out)
result = step(first, second);
Out = step(A, B);
}
";
}

6
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Round/TruncateNode.cs


}
static string Unity_Truncate(
[Slot(0, Binding.None)] DynamicDimensionVector argument,
[Slot(1, Binding.None)] out DynamicDimensionVector result)
[Slot(0, Binding.None)] DynamicDimensionVector In,
[Slot(1, Binding.None)] out DynamicDimensionVector Out)
result = truncate(argument);
Out = trunc(In);
}
";
}

7
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Vector/TransformNode.cs


{
get { return ConvertConcreteSlotValueTypeToString(FindOutputSlot<MaterialSlot>(OutputSlotId).concreteValueType); }
}
private string inputDimension
{
get { return ConvertConcreteSlotValueTypeToString(FindInputSlot<MaterialSlot>(InputSlotId).concreteValueType); }

{
return NeededCoordinateSpace.World;
return NeededCoordinateSpace.Local;
return NeededCoordinateSpace.World;
return NeededCoordinateSpace.Local;
return NeededCoordinateSpace.World;
return NeededCoordinateSpace.Local;
}
}
}

31
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Interpolation/InverseLinearInterpolationNode.cs


using System.Reflection;
namespace UnityEngine.MaterialGraph
{
[Title("Math/Interpolation/Inverse Linear Interpolation")]
public class InverseLerpNode : CodeFunctionNode
{
public InverseLerpNode()
{
name = "Inverse Linear Interpolation";
}
protected override MethodInfo GetFunctionToConvert()
{
return GetType().GetMethod("Unity_InverseLinearInterpolation", BindingFlags.Static | BindingFlags.NonPublic);
}
static string Unity_InverseLinearInterpolation(
[Slot(0, Binding.None)] DynamicDimensionVector A,
[Slot(1, Binding.None)] DynamicDimensionVector B,
[Slot(2, Binding.None)] DynamicDimensionVector T,
[Slot(3, Binding.None)] out DynamicDimensionVector Out)
{
return
@"
{
Out = (T - A)/(B - A);
}";
}
}
}

31
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Interpolation/LinearInterpolationNode.cs


using System.Reflection;
namespace UnityEngine.MaterialGraph
{
[Title("Math/Interpolation/Linear Interpolation")]
public class LinearInterpolationNode : CodeFunctionNode
{
public LinearInterpolationNode()
{
name = "Linear Interpolation";
}
protected override MethodInfo GetFunctionToConvert()
{
return GetType().GetMethod("Unity_LinearInterpolation", BindingFlags.Static | BindingFlags.NonPublic);
}
static string Unity_LinearInterpolation(
[Slot(0, Binding.None)] DynamicDimensionVector A,
[Slot(1, Binding.None)] DynamicDimensionVector B,
[Slot(2, Binding.None)] DynamicDimensionVector T,
[Slot(3, Binding.None)] out DynamicDimensionVector Out)
{
return
@"
{
Out = lerp(A, B, T);
}";
}
}
}

31
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Interpolation/SmoothHermiteInterpolationNode.cs


using System.Reflection;
namespace UnityEngine.MaterialGraph
{
[Title("Math/Interpolation/Smooth Hermite Interpolation")]
class SmoothHermiteInterpolationNode : CodeFunctionNode
{
public SmoothHermiteInterpolationNode()
{
name = "Smooth Hermite Interpolation";
}
protected override MethodInfo GetFunctionToConvert()
{
return GetType().GetMethod("Unity_SmoothHermiteInterpolation", BindingFlags.Static | BindingFlags.NonPublic);
}
static string Unity_SmoothHermiteInterpolation(
[Slot(0, Binding.None)] DynamicDimensionVector A,
[Slot(1, Binding.None)] DynamicDimensionVector B,
[Slot(2, Binding.None)] DynamicDimensionVector T,
[Slot(3, Binding.None)] out DynamicDimensionVector Out)
{
return
@"
{
Out = smoothstep(A, B, T);
}";
}
}
}

30
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Round/CeilingNode.cs


using System.Reflection;
namespace UnityEngine.MaterialGraph
{
[Title("Math/Round/Ceiling")]
public class CeilingNode : CodeFunctionNode
{
public CeilingNode()
{
name = "Ceiling";
}
protected override MethodInfo GetFunctionToConvert()
{
return GetType().GetMethod("Unity_Ceiling", BindingFlags.Static | BindingFlags.NonPublic);
}
static string Unity_Ceiling(
[Slot(0, Binding.None)] DynamicDimensionVector In,
[Slot(1, Binding.None)] out DynamicDimensionVector Out)
{
return
@"
{
Out = ceil(In);
}
";
}
}
}

35
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Vector/TangentToWorldNode.cs


using System.Reflection;
namespace UnityEngine.MaterialGraph
{
[Title("Math/Vector/Tangent To World")]
public class TangentToWorldNode : CodeFunctionNode
{
public TangentToWorldNode()
{
name = "Tangent To World";
}
protected override MethodInfo GetFunctionToConvert()
{
return GetType().GetMethod("Unity_TangentToWorld", BindingFlags.Static | BindingFlags.NonPublic);
}
static string Unity_TangentToWorld(
[Slot(0, Binding.None)] Vector3 In,
[Slot(1, Binding.None)] out Vector3 Out,
[Slot(2, Binding.WorldSpaceTangent)] Vector3 Tangent,
[Slot(3, Binding.WorldSpaceBitangent)] Vector3 Bitangent,
[Slot(4, Binding.WorldSpaceNormal)] Vector3 Normal)
{
Out = Vector3.zero;
return
@"
{
{precision}3x3 tangentToWorld = transpose({precision}3x3(Tangent, Bitangent, Normal));
Out = saturate(mul(tangentToWorld, normalize(In)));
}
";
}
}
}

35
MaterialGraphProject/Assets/NewNodes/Editor/Keep/TangentToWorldNode.cs


using System.Reflection;
namespace UnityEngine.MaterialGraph
{
[Title("Math/Vector/TangentToWorld")]
public class TangentToWorldNode : CodeFunctionNode
{
public TangentToWorldNode()
{
name = "TangentToWorld";
}
protected override MethodInfo GetFunctionToConvert()
{
return GetType().GetMethod("Unity_TangentToWorld", BindingFlags.Static | BindingFlags.NonPublic);
}
static string Unity_TangentToWorld(
[Slot(0, Binding.None)] Vector3 inVector,
[Slot(1, Binding.None)] out Vector3 result,
[Slot(2, Binding.WorldSpaceTangent)] Vector3 tangent,
[Slot(3, Binding.WorldSpaceBitangent)] Vector3 biTangent,
[Slot(4, Binding.WorldSpaceNormal)] Vector3 normal)
{
result = Vector3.zero;
return
@"
{
{precision}3x3 tangentToWorld = transpose({precision}3x3(tangent, biTangent, normal));
result= saturate(mul(tangentToWorld, normalize(inVector)));
}
";
}
}
}

31
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Interpolation/LerpNode.cs


using System.Reflection;
namespace UnityEngine.MaterialGraph
{
[Title("Math/Interpolation/Lerp")]
public class LerpNode : CodeFunctionNode
{
public LerpNode()
{
name = "Lerp";
}
protected override MethodInfo GetFunctionToConvert()
{
return GetType().GetMethod("Unity_Lerp", BindingFlags.Static | BindingFlags.NonPublic);
}
static string Unity_Lerp(
[Slot(0, Binding.None)] DynamicDimensionVector inputA,
[Slot(1, Binding.None)] DynamicDimensionVector inputB,
[Slot(2, Binding.None)] DynamicDimensionVector t,
[Slot(3, Binding.None)] out DynamicDimensionVector result)
{
return
@"
{
result = lerp(inputA, inputB, t);
}";
}
}
}

31
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Interpolation/SmoothStepNode.cs


using System.Reflection;
namespace UnityEngine.MaterialGraph
{
[Title("Math/Interpolation/SmoothStep")]
class SmoothStepNode : CodeFunctionNode
{
public SmoothStepNode()
{
name = "SmoothStep";
}
protected override MethodInfo GetFunctionToConvert()
{
return GetType().GetMethod("Unity_Smoothstep", BindingFlags.Static | BindingFlags.NonPublic);
}
static string Unity_Smoothstep(
[Slot(0, Binding.None)] DynamicDimensionVector inputA,
[Slot(1, Binding.None)] DynamicDimensionVector inputB,
[Slot(2, Binding.None)] DynamicDimensionVector t,
[Slot(3, Binding.None)] out DynamicDimensionVector result)
{
return
@"
{
result = smoothstep(inputA, inputB, t);
}";
}
}
}

31
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Interpolation/InverseLerpNode.cs


using System.Reflection;
namespace UnityEngine.MaterialGraph
{
[Title("Math/Interpolation/InverseLerp")]
public class InverseLerpNode : CodeFunctionNode
{
public InverseLerpNode()
{
name = "InverseLerp";
}
protected override MethodInfo GetFunctionToConvert()
{
return GetType().GetMethod("Unity_InverseLerp", BindingFlags.Static | BindingFlags.NonPublic);
}
static string Unity_InverseLerp(
[Slot(0, Binding.None)] DynamicDimensionVector inputA,
[Slot(1, Binding.None)] DynamicDimensionVector inputB,
[Slot(2, Binding.None)] DynamicDimensionVector t,
[Slot(3, Binding.None)] out DynamicDimensionVector result)
{
return
@"
{
result = (t - inputA)/(inputB - inputA);
}";
}
}
}

30
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Round/CeilNode.cs


using System.Reflection;
namespace UnityEngine.MaterialGraph
{
[Title("Math/Round/Ceil")]
public class CeilNode : CodeFunctionNode
{
public CeilNode()
{
name = "Ceil";
}
protected override MethodInfo GetFunctionToConvert()
{
return GetType().GetMethod("Unity_Ceil", BindingFlags.Static | BindingFlags.NonPublic);
}
static string Unity_Ceil(
[Slot(0, Binding.None)] DynamicDimensionVector argument,
[Slot(1, Binding.None)] out DynamicDimensionVector result)
{
return
@"
{
result = ceil(argument);
}
";
}
}
}

/MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Interpolation/InverseLerpNode.cs.meta → /MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Interpolation/InverseLinearInterpolationNode.cs.meta

/MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Interpolation/LerpNode.cs.meta → /MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Interpolation/LinearInterpolationNode.cs.meta

/MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Interpolation/SmoothStepNode.cs.meta → /MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Interpolation/SmoothHermiteInterpolationNode.cs.meta

/MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Round/CeilNode.cs.meta → /MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Round/CeilingNode.cs.meta

/MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Round/TruncNode.cs.meta → /MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Round/TruncateNode.cs.meta

/MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Round/TruncNode.cs → /MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Round/TruncateNode.cs

/MaterialGraphProject/Assets/NewNodes/Editor/Keep/TangentToWorldNode.cs.meta → /MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Vector/TangentToWorldNode.cs.meta

/MaterialGraphProject/Assets/NewNodes/Editor/Keep/TransformNode.cs.meta → /MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Vector/TransformNode.cs.meta

/MaterialGraphProject/Assets/NewNodes/Editor/Keep/TransformNode.cs → /MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Vector/TransformNode.cs

正在加载...
取消
保存