浏览代码
Maths Part 4
Maths Part 4
- Maths/Vector (finish) - Maths/Derivative - Maths/Trigonometry - Maths/Matrix (temporarily removed for rewrite) - Moved CommonMatrix enum to MatrixCommonNode.cs and removed file/main
Matt Dean
7 年前
当前提交
da4c61fd
共有 56 个文件被更改,包括 606 次插入 和 665 次删除
-
12MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Matrix/MatrixCommonNode.cs
-
14MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Trigonometry/ArcCosNode.cs
-
14MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Trigonometry/ArcSinNode.cs
-
14MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Trigonometry/ArcTanNode.cs
-
6MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Trigonometry/CosNode.cs
-
8MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Trigonometry/DegreesToRadiansNode.cs
-
8MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Trigonometry/RadiansToDegreesNode.cs
-
6MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Trigonometry/SinNode.cs
-
6MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Trigonometry/TanNode.cs
-
9MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Vector/FresnelNode.cs
-
12MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Vector/ReflectNode.cs
-
8MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Derivative.meta
-
31MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Interpolation/InverseLerpNode.cs
-
31MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Interpolation/LerpNode.cs
-
31MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Interpolation/SmoothstepNode.cs
-
31MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Trigonometry/ArcTan2Node.cs
-
30MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Trigonometry/HyperbolicSinNode.cs
-
8MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Trigonometry/HyperbolicSinNode.cs.meta
-
31MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Vector/DistanceNode.cs
-
31MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Vector/DotProductNode.cs
-
30MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Vector/ProjectNode.cs
-
31MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Vector/RejectNode.cs
-
89MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Derivative/DDXNode.cs
-
82MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Derivative/DDXYNode.cs
-
82MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Derivative/DDYNode.cs
-
12MaterialGraphProject/Assets/NewNodes/Editor/CommonMatrixType.cs.meta
-
14MaterialGraphProject/Assets/NewNodes/Editor/CommonMatrixType.cs
-
31MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Interpolation/InverseLinearInterpolationNode.cs
-
31MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Interpolation/LinearInterpolationNode.cs
-
31MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Interpolation/SmoothHermiteInterpolationNode.cs
-
12MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Trigonometry/SinCosNode.cs.meta
-
31MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Trigonometry/ATan2Node.cs
-
31MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Trigonometry/SinCosNode.cs
-
31MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Vector/DotNode.cs
-
30MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Vector/DDX.cs
-
30MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Vector/DDXY.cs
-
30MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Vector/DDY.cs
-
31MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Vector/Distance.cs
-
156MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Vector/PartialDerivativeNode.cs
-
11MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Vector/PartialDerivativeNode.cs.meta
-
35MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Vector/TangentToWorldNode.cs
-
8MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Vector/TangentToWorldNode.cs.meta
-
30MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/VectorProjectionNode.cs
-
31MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/VectorRejectionNode.cs
-
0/MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Interpolation/InverseLerpNode.cs.meta
-
0/MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Interpolation/LerpNode.cs.meta
-
0/MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Interpolation/SmoothstepNode.cs.meta
-
0/MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Trigonometry/ArcTan2Node.cs.meta
-
0/MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Vector/DistanceNode.cs.meta
-
0/MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Vector/DotProductNode.cs.meta
-
0/MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Derivative/DDYNode.cs.meta
-
0/MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Derivative/DDXYNode.cs.meta
-
0/MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Derivative/DDXNode.cs.meta
-
0/MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Vector/ProjectNode.cs.meta
-
0/MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Vector/RejectNode.cs.meta
|
|||
fileFormatVersion: 2 |
|||
guid: c10838deaed74574a94a340e53c2b229 |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Reflection; |
|||
|
|||
namespace UnityEngine.MaterialGraph |
|||
{ |
|||
[Title("Math/Interpolation/Inverse Lerp")] |
|||
public class InverseLerpNode : CodeFunctionNode |
|||
{ |
|||
public InverseLerpNode() |
|||
{ |
|||
name = "Inverse Lerp"; |
|||
} |
|||
|
|||
protected override MethodInfo GetFunctionToConvert() |
|||
{ |
|||
return GetType().GetMethod("Unity_InverseLerp", BindingFlags.Static | BindingFlags.NonPublic); |
|||
} |
|||
|
|||
static string Unity_InverseLerp( |
|||
[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); |
|||
}";
|
|||
} |
|||
} |
|||
} |
|
|||
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 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); |
|||
}";
|
|||
} |
|||
} |
|||
} |
|
|||
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 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); |
|||
}";
|
|||
} |
|||
} |
|||
} |
|
|||
using System.Reflection; |
|||
|
|||
namespace UnityEngine.MaterialGraph |
|||
{ |
|||
[Title("Math/Trigonometry/ArcTan2")] |
|||
public class ArcTan2Node : CodeFunctionNode |
|||
{ |
|||
public ArcTan2Node() |
|||
{ |
|||
name = "ArcTan2"; |
|||
} |
|||
|
|||
protected override MethodInfo GetFunctionToConvert() |
|||
{ |
|||
return GetType().GetMethod("Unity_ArcTan2", BindingFlags.Static | BindingFlags.NonPublic); |
|||
} |
|||
|
|||
static string Unity_ArcTan2( |
|||
[Slot(0, Binding.None)] DynamicDimensionVector A, |
|||
[Slot(1, Binding.None)] DynamicDimensionVector B, |
|||
[Slot(2, Binding.None)] out DynamicDimensionVector Out) |
|||
{ |
|||
return |
|||
@"
|
|||
{ |
|||
Out = atan2(A, B); |
|||
} |
|||
";
|
|||
} |
|||
} |
|||
} |
|
|||
using System.Reflection; |
|||
|
|||
namespace UnityEngine.MaterialGraph |
|||
{ |
|||
[Title("Math/Trigonometry/Hyperbolic Sin")] |
|||
class HyperbolicSinNode : CodeFunctionNode |
|||
{ |
|||
public HyperbolicSinNode() |
|||
{ |
|||
name = "Hyperbolic Sin"; |
|||
} |
|||
|
|||
protected override MethodInfo GetFunctionToConvert() |
|||
{ |
|||
return GetType().GetMethod("Unity_HyperbolicSin", BindingFlags.Static | BindingFlags.NonPublic); |
|||
} |
|||
|
|||
static string Unity_HyperbolicSin( |
|||
[Slot(0, Binding.None)] DynamicDimensionVector In, |
|||
[Slot(1, Binding.None)] out DynamicDimensionVector Out) |
|||
{ |
|||
return |
|||
@"
|
|||
{ |
|||
Out = sinh(In); |
|||
} |
|||
";
|
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: aac1ed8451e23d34ab8a362ad52fce32 |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|
|||
using System.Reflection; |
|||
|
|||
namespace UnityEngine.MaterialGraph |
|||
{ |
|||
[Title("Math/Vector/Distance")] |
|||
public class DistanceNode : CodeFunctionNode |
|||
{ |
|||
public DistanceNode() |
|||
{ |
|||
name = "Distance"; |
|||
} |
|||
|
|||
protected override MethodInfo GetFunctionToConvert() |
|||
{ |
|||
return GetType().GetMethod("Unity_Distance", BindingFlags.Static | BindingFlags.NonPublic); |
|||
} |
|||
|
|||
static string Unity_Distance( |
|||
[Slot(0, Binding.None)] DynamicDimensionVector A, |
|||
[Slot(1, Binding.None)] DynamicDimensionVector B, |
|||
[Slot(2, Binding.None)] out DynamicDimensionVector Out) |
|||
{ |
|||
return |
|||
@"
|
|||
{ |
|||
Out = distance(A, B); |
|||
} |
|||
";
|
|||
} |
|||
} |
|||
} |
|
|||
using System.Reflection; |
|||
|
|||
namespace UnityEngine.MaterialGraph |
|||
{ |
|||
[Title("Math/Vector/Dot Product")] |
|||
public class DotProductNode : CodeFunctionNode |
|||
{ |
|||
public DotProductNode() |
|||
{ |
|||
name = "Dot Product"; |
|||
} |
|||
|
|||
protected override MethodInfo GetFunctionToConvert() |
|||
{ |
|||
return GetType().GetMethod("Unity_DotProduct", BindingFlags.Static | BindingFlags.NonPublic); |
|||
} |
|||
|
|||
static string Unity_DotProduct( |
|||
[Slot(0, Binding.None)] Vector3 A, |
|||
[Slot(1, Binding.None)] Vector3 B, |
|||
[Slot(2, Binding.None)] out Vector1 Out) |
|||
{ |
|||
return |
|||
@"
|
|||
{ |
|||
Out = dot(A, B); |
|||
} |
|||
";
|
|||
} |
|||
} |
|||
} |
|
|||
using System.Reflection; |
|||
|
|||
namespace UnityEngine.MaterialGraph |
|||
{ |
|||
[Title("Math/Vector/Project")] |
|||
public class ProjectNode : CodeFunctionNode |
|||
{ |
|||
public ProjectNode() |
|||
{ |
|||
name = "Project"; |
|||
} |
|||
|
|||
protected override MethodInfo GetFunctionToConvert() |
|||
{ |
|||
return GetType().GetMethod("Unity_Project", BindingFlags.Static | BindingFlags.NonPublic); |
|||
} |
|||
|
|||
static string Unity_Project( |
|||
[Slot(0, Binding.None)] DynamicDimensionVector A, |
|||
[Slot(1, Binding.None)] DynamicDimensionVector B, |
|||
[Slot(2, Binding.None)] out DynamicDimensionVector Out) |
|||
{ |
|||
return |
|||
@"
|
|||
{ |
|||
Out = B * dot(A, B) / dot(B, B); |
|||
}";
|
|||
} |
|||
} |
|||
} |
|
|||
using System.Reflection; |
|||
|
|||
namespace UnityEngine.MaterialGraph |
|||
{ |
|||
[Title("Math/Vector/Reject")] |
|||
public class RejectNode : CodeFunctionNode |
|||
{ |
|||
public RejectNode() |
|||
{ |
|||
name = "Reject"; |
|||
} |
|||
|
|||
protected override MethodInfo GetFunctionToConvert() |
|||
{ |
|||
return GetType().GetMethod("Unity_Reject", BindingFlags.Static | BindingFlags.NonPublic); |
|||
} |
|||
|
|||
static string Unity_Reject( |
|||
[Slot(0, Binding.None)] DynamicDimensionVector A, |
|||
[Slot(1, Binding.None)] DynamicDimensionVector B, |
|||
[Slot(2, Binding.None)] out DynamicDimensionVector Out) |
|||
{ |
|||
return |
|||
@"
|
|||
{ |
|||
Out = A - (B * dot(A, B) / dot(B, B)); |
|||
} |
|||
";
|
|||
} |
|||
} |
|||
} |
|
|||
using System.Reflection; |
|||
using UnityEditor.MaterialGraph.Drawing.Controls; |
|||
using UnityEngine.Graphing; |
|||
|
|||
namespace UnityEngine.MaterialGraph |
|||
{ |
|||
public enum PartialDerivativePrecision |
|||
{ |
|||
Coarse, |
|||
Default, |
|||
Fine |
|||
}; |
|||
|
|||
[Title("Math/Derivative/DDX")] |
|||
public class DDXNode : CodeFunctionNode |
|||
{ |
|||
public DDXNode() |
|||
{ |
|||
name = "DDX"; |
|||
} |
|||
|
|||
[SerializeField] |
|||
private PartialDerivativePrecision m_PartialDerivativePrecision = PartialDerivativePrecision.Default; |
|||
|
|||
[EnumControl("Precision")] |
|||
public PartialDerivativePrecision partialDerivativePrecision |
|||
{ |
|||
get { return m_PartialDerivativePrecision; } |
|||
set |
|||
{ |
|||
if (m_PartialDerivativePrecision == value) |
|||
return; |
|||
|
|||
m_PartialDerivativePrecision = value; |
|||
if (onModified != null) |
|||
{ |
|||
onModified(this, ModificationScope.Graph); |
|||
} |
|||
} |
|||
} |
|||
|
|||
string GetCurrentPrecision() |
|||
{ |
|||
return System.Enum.GetName(typeof(PartialDerivativePrecision), m_PartialDerivativePrecision); |
|||
} |
|||
|
|||
protected override MethodInfo GetFunctionToConvert() |
|||
{ |
|||
return GetType().GetMethod(string.Format("Unity_DDX_{0}", GetCurrentPrecision()), |
|||
BindingFlags.Static | BindingFlags.NonPublic); |
|||
} |
|||
|
|||
static string Unity_DDX_Default( |
|||
[Slot(0, Binding.None)] Vector1 In, |
|||
[Slot(1, Binding.None)] out Vector1 Out) |
|||
{ |
|||
return |
|||
@"
|
|||
{ |
|||
Out = ddx(In); |
|||
} |
|||
";
|
|||
} |
|||
|
|||
static string Unity_DDX_Coarse( |
|||
[Slot(0, Binding.None)] Vector1 In, |
|||
[Slot(1, Binding.None)] out Vector1 Out) |
|||
{ |
|||
return |
|||
@"
|
|||
{ |
|||
Out = ddx_coarse(In); |
|||
} |
|||
";
|
|||
} |
|||
|
|||
static string Unity_DDX_Fine( |
|||
[Slot(0, Binding.None)] Vector1 In, |
|||
[Slot(1, Binding.None)] out Vector1 Out) |
|||
{ |
|||
return |
|||
@"
|
|||
{ |
|||
Out = ddx_fine(In); |
|||
} |
|||
";
|
|||
} |
|||
} |
|||
} |
|
|||
using System.Reflection; |
|||
using UnityEditor.MaterialGraph.Drawing.Controls; |
|||
using UnityEngine.Graphing; |
|||
|
|||
namespace UnityEngine.MaterialGraph |
|||
{ |
|||
[Title("Math/Derivative/DDXY")] |
|||
public class DDXYNode : CodeFunctionNode |
|||
{ |
|||
public DDXYNode() |
|||
{ |
|||
name = "DDXY"; |
|||
} |
|||
|
|||
[SerializeField] |
|||
private PartialDerivativePrecision m_PartialDerivativePrecision = PartialDerivativePrecision.Default; |
|||
|
|||
[EnumControl("Precision")] |
|||
public PartialDerivativePrecision partialDerivativePrecision |
|||
{ |
|||
get { return m_PartialDerivativePrecision; } |
|||
set |
|||
{ |
|||
if (m_PartialDerivativePrecision == value) |
|||
return; |
|||
|
|||
m_PartialDerivativePrecision = value; |
|||
if (onModified != null) |
|||
{ |
|||
onModified(this, ModificationScope.Graph); |
|||
} |
|||
} |
|||
} |
|||
|
|||
string GetCurrentPrecision() |
|||
{ |
|||
return System.Enum.GetName(typeof(PartialDerivativePrecision), m_PartialDerivativePrecision); |
|||
} |
|||
|
|||
protected override MethodInfo GetFunctionToConvert() |
|||
{ |
|||
return GetType().GetMethod(string.Format("Unity_DDXY_{0}", GetCurrentPrecision()), |
|||
BindingFlags.Static | BindingFlags.NonPublic); |
|||
} |
|||
|
|||
static string Unity_DDXY_Default( |
|||
[Slot(0, Binding.None)] Vector1 In, |
|||
[Slot(1, Binding.None)] out Vector1 Out) |
|||
{ |
|||
return |
|||
@"
|
|||
{ |
|||
Out = abs(ddx(In) + ddy(In)); |
|||
} |
|||
";
|
|||
} |
|||
|
|||
static string Unity_DDXY_Coarse( |
|||
[Slot(0, Binding.None)] Vector1 In, |
|||
[Slot(1, Binding.None)] out Vector1 Out) |
|||
{ |
|||
return |
|||
@"
|
|||
{ |
|||
Out = abs(ddx_coarse(In) + ddy_coarse(In)); |
|||
} |
|||
";
|
|||
} |
|||
|
|||
static string Unity_DDXY_Fine( |
|||
[Slot(0, Binding.None)] Vector1 In, |
|||
[Slot(1, Binding.None)] out Vector1 Out) |
|||
{ |
|||
return |
|||
@"
|
|||
{ |
|||
Out = abs(ddx_fine(In) + ddy_fine(In)); |
|||
} |
|||
";
|
|||
} |
|||
} |
|||
} |
|
|||
using System.Reflection; |
|||
using UnityEditor.MaterialGraph.Drawing.Controls; |
|||
using UnityEngine.Graphing; |
|||
|
|||
namespace UnityEngine.MaterialGraph |
|||
{ |
|||
[Title("Math/Derivative/DDY")] |
|||
public class DDYNode : CodeFunctionNode |
|||
{ |
|||
public DDYNode() |
|||
{ |
|||
name = "DDY"; |
|||
} |
|||
|
|||
[SerializeField] |
|||
private PartialDerivativePrecision m_PartialDerivativePrecision = PartialDerivativePrecision.Default; |
|||
|
|||
[EnumControl("Precision")] |
|||
public PartialDerivativePrecision partialDerivativePrecision |
|||
{ |
|||
get { return m_PartialDerivativePrecision; } |
|||
set |
|||
{ |
|||
if (m_PartialDerivativePrecision == value) |
|||
return; |
|||
|
|||
m_PartialDerivativePrecision = value; |
|||
if (onModified != null) |
|||
{ |
|||
onModified(this, ModificationScope.Graph); |
|||
} |
|||
} |
|||
} |
|||
|
|||
string GetCurrentPrecision() |
|||
{ |
|||
return System.Enum.GetName(typeof(PartialDerivativePrecision), m_PartialDerivativePrecision); |
|||
} |
|||
|
|||
protected override MethodInfo GetFunctionToConvert() |
|||
{ |
|||
return GetType().GetMethod(string.Format("Unity_DDY_{0}", GetCurrentPrecision()), |
|||
BindingFlags.Static | BindingFlags.NonPublic); |
|||
} |
|||
|
|||
static string Unity_DDY_Default( |
|||
[Slot(0, Binding.None)] Vector1 In, |
|||
[Slot(1, Binding.None)] out Vector1 Out) |
|||
{ |
|||
return |
|||
@"
|
|||
{ |
|||
Out = ddy(In); |
|||
} |
|||
";
|
|||
} |
|||
|
|||
static string Unity_DDY_Coarse( |
|||
[Slot(0, Binding.None)] Vector1 In, |
|||
[Slot(1, Binding.None)] out Vector1 Out) |
|||
{ |
|||
return |
|||
@"
|
|||
{ |
|||
Out = ddy_coarse(In); |
|||
} |
|||
";
|
|||
} |
|||
|
|||
static string Unity_DDY_Fine( |
|||
[Slot(0, Binding.None)] Vector1 In, |
|||
[Slot(1, Binding.None)] out Vector1 Out) |
|||
{ |
|||
return |
|||
@"
|
|||
{ |
|||
Out = ddy_fine(In); |
|||
} |
|||
";
|
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: e466cff33b1ebe64eb2b897b9534a4a4 |
|||
timeCreated: 1495703998 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
namespace UnityEngine.MaterialGraph |
|||
{ |
|||
public enum CommonMatrixType |
|||
{ |
|||
ModelView, |
|||
View, |
|||
Projection, |
|||
ViewProjection, |
|||
TransposeModelView, |
|||
InverseTransposeModelView, |
|||
ObjectToWorld, |
|||
WorldToObject |
|||
}; |
|||
} |
|
|||
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); |
|||
}";
|
|||
} |
|||
} |
|||
} |
|
|||
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); |
|||
}";
|
|||
} |
|||
} |
|||
} |
|
|||
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); |
|||
}";
|
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 61e8adbfbb5cd244fa9bb6dcc900b2bc |
|||
timeCreated: 1495447065 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Reflection; |
|||
|
|||
namespace UnityEngine.MaterialGraph |
|||
{ |
|||
[Title("Math/Trigonometry/ArcTan2")] |
|||
public class ATan2Node : CodeFunctionNode |
|||
{ |
|||
public ATan2Node() |
|||
{ |
|||
name = "ArcTan2"; |
|||
} |
|||
|
|||
protected override MethodInfo GetFunctionToConvert() |
|||
{ |
|||
return GetType().GetMethod("Unity_ATan2", BindingFlags.Static | BindingFlags.NonPublic); |
|||
} |
|||
|
|||
static string Unity_ATan2( |
|||
[Slot(0, Binding.None)] DynamicDimensionVector first, |
|||
[Slot(1, Binding.None)] DynamicDimensionVector second, |
|||
[Slot(2, Binding.None)] out DynamicDimensionVector result) |
|||
{ |
|||
return |
|||
@"
|
|||
{ |
|||
result = atan2(first, second); |
|||
} |
|||
";
|
|||
} |
|||
} |
|||
} |
|
|||
using System.Reflection; |
|||
|
|||
namespace UnityEngine.MaterialGraph |
|||
{ |
|||
[Title("Math/Trigonometry/SinCos")] |
|||
public class SinCosNode : CodeFunctionNode |
|||
{ |
|||
public SinCosNode() |
|||
{ |
|||
name = "SinCos"; |
|||
} |
|||
|
|||
protected override MethodInfo GetFunctionToConvert() |
|||
{ |
|||
return GetType().GetMethod("Unity_SinCos", BindingFlags.Static | BindingFlags.NonPublic); |
|||
} |
|||
|
|||
static string Unity_SinCos( |
|||
[Slot(0, Binding.None)] Vector1 argument, |
|||
[Slot(1, Binding.None)] out Vector1 sin, |
|||
[Slot(2, Binding.None)] out Vector1 cos) |
|||
{ |
|||
return |
|||
@"
|
|||
{ |
|||
sincos(argument, sin, cos); |
|||
} |
|||
";
|
|||
} |
|||
} |
|||
} |
|
|||
using System.Reflection; |
|||
|
|||
namespace UnityEngine.MaterialGraph |
|||
{ |
|||
[Title("Math/Vector/Dot Product")] |
|||
public class DotNode : CodeFunctionNode |
|||
{ |
|||
public DotNode() |
|||
{ |
|||
name = "DotProduct"; |
|||
} |
|||
|
|||
protected override MethodInfo GetFunctionToConvert() |
|||
{ |
|||
return GetType().GetMethod("Unity_DotProduct", BindingFlags.Static | BindingFlags.NonPublic); |
|||
} |
|||
|
|||
static string Unity_DotProduct( |
|||
[Slot(0, Binding.None)] Vector3 first, |
|||
[Slot(1, Binding.None)] Vector3 second, |
|||
[Slot(2, Binding.None)] out Vector1 result) |
|||
{ |
|||
return |
|||
@"
|
|||
{ |
|||
result = dot(first, second); |
|||
} |
|||
";
|
|||
} |
|||
} |
|||
} |
|
|||
using System.Reflection; |
|||
|
|||
namespace UnityEngine.MaterialGraph |
|||
{ |
|||
[Title("Math/Vector/DDX")] |
|||
public class DDXNode : CodeFunctionNode |
|||
{ |
|||
public DDXNode() |
|||
{ |
|||
name = "DDX"; |
|||
} |
|||
|
|||
protected override MethodInfo GetFunctionToConvert() |
|||
{ |
|||
return GetType().GetMethod("Unity_DDX", BindingFlags.Static | BindingFlags.NonPublic); |
|||
} |
|||
|
|||
static string Unity_DDX( |
|||
[Slot(0, Binding.None)] Vector1 argument, |
|||
[Slot(1, Binding.None)] out Vector1 result) |
|||
{ |
|||
return |
|||
@"
|
|||
{ |
|||
result = ddx(argument); |
|||
} |
|||
";
|
|||
} |
|||
} |
|||
} |
|
|||
using System.Reflection; |
|||
|
|||
namespace UnityEngine.MaterialGraph |
|||
{ |
|||
[Title("Math/Vector/DDXY")] |
|||
public class DDXYNode : CodeFunctionNode |
|||
{ |
|||
public DDXYNode() |
|||
{ |
|||
name = "DDXY"; |
|||
} |
|||
|
|||
protected override MethodInfo GetFunctionToConvert() |
|||
{ |
|||
return GetType().GetMethod("Unity_DDXY", BindingFlags.Static | BindingFlags.NonPublic); |
|||
} |
|||
|
|||
static string Unity_DDXY( |
|||
[Slot(0, Binding.None)] Vector1 argument, |
|||
[Slot(1, Binding.None)] out Vector1 result) |
|||
{ |
|||
return |
|||
@"
|
|||
{ |
|||
result = abs(ddx(argument) + ddy(argument)); |
|||
} |
|||
";
|
|||
} |
|||
} |
|||
} |
|
|||
using System.Reflection; |
|||
|
|||
namespace UnityEngine.MaterialGraph |
|||
{ |
|||
[Title("Math/Vector/DDY")] |
|||
public class DDYNode : CodeFunctionNode |
|||
{ |
|||
public DDYNode() |
|||
{ |
|||
name = "DDY"; |
|||
} |
|||
|
|||
protected override MethodInfo GetFunctionToConvert() |
|||
{ |
|||
return GetType().GetMethod("Unity_DDY", BindingFlags.Static | BindingFlags.NonPublic); |
|||
} |
|||
|
|||
static string Unity_DDY( |
|||
[Slot(0, Binding.None)] Vector1 argument, |
|||
[Slot(1, Binding.None)] out Vector1 result) |
|||
{ |
|||
return |
|||
@"
|
|||
{ |
|||
result = ddy(argument); |
|||
} |
|||
";
|
|||
} |
|||
} |
|||
} |
|
|||
using System.Reflection; |
|||
|
|||
namespace UnityEngine.MaterialGraph |
|||
{ |
|||
[Title("Math/Vector/Distance")] |
|||
public class DistanceNode : CodeFunctionNode |
|||
{ |
|||
public DistanceNode() |
|||
{ |
|||
name = "Distance"; |
|||
} |
|||
|
|||
protected override MethodInfo GetFunctionToConvert() |
|||
{ |
|||
return GetType().GetMethod("Unity_Distance", BindingFlags.Static | BindingFlags.NonPublic); |
|||
} |
|||
|
|||
static string Unity_Distance( |
|||
[Slot(0, Binding.None)] DynamicDimensionVector first, |
|||
[Slot(1, Binding.None)] DynamicDimensionVector second, |
|||
[Slot(2, Binding.None)] out DynamicDimensionVector result) |
|||
{ |
|||
return |
|||
@"
|
|||
{ |
|||
result = distance(first, second); |
|||
} |
|||
";
|
|||
} |
|||
} |
|||
} |
|
|||
using System.Reflection; |
|||
using UnityEditor.MaterialGraph.Drawing.Controls; |
|||
using UnityEngine.Graphing; |
|||
|
|||
namespace UnityEngine.MaterialGraph |
|||
{ |
|||
[Title("Math/Vector/Partial Derivative")] |
|||
public class PartialDerivativeNode : CodeFunctionNode |
|||
{ |
|||
public enum Precision |
|||
{ |
|||
Coarse, |
|||
Default, |
|||
Fine |
|||
}; |
|||
|
|||
public enum Coordinate |
|||
{ |
|||
X, |
|||
Y |
|||
}; |
|||
|
|||
public PartialDerivativeNode() |
|||
{ |
|||
name = "Partial Derivative"; |
|||
} |
|||
|
|||
[SerializeField] |
|||
private Precision m_Precision = Precision.Default; |
|||
|
|||
[EnumControl("Precision")] |
|||
public Precision _precision |
|||
{ |
|||
get { return m_Precision; } |
|||
set |
|||
{ |
|||
if (m_Precision == value) |
|||
return; |
|||
|
|||
m_Precision = value; |
|||
if (onModified != null) |
|||
{ |
|||
onModified(this, ModificationScope.Graph); |
|||
} |
|||
} |
|||
} |
|||
|
|||
string GetCurrentPrecision() |
|||
{ |
|||
return System.Enum.GetName(typeof(Precision), m_Precision); |
|||
} |
|||
|
|||
[SerializeField] |
|||
private Coordinate m_Coordinate = Coordinate.X; |
|||
|
|||
[EnumControl("Respect Coordinate")] |
|||
public Coordinate coordinate |
|||
{ |
|||
get { return m_Coordinate; } |
|||
set |
|||
{ |
|||
if (m_Coordinate == value) |
|||
return; |
|||
|
|||
m_Coordinate = value; |
|||
if (onModified != null) |
|||
{ |
|||
onModified(this, ModificationScope.Graph); |
|||
} |
|||
} |
|||
} |
|||
|
|||
string GetCurrentCoordinate() |
|||
{ |
|||
return System.Enum.GetName(typeof(Coordinate), m_Coordinate); |
|||
} |
|||
|
|||
protected override MethodInfo GetFunctionToConvert() |
|||
{ |
|||
return GetType().GetMethod(string.Format("Unity_DD{0}_{1}", GetCurrentCoordinate(), GetCurrentPrecision()), |
|||
BindingFlags.Static | BindingFlags.NonPublic); |
|||
} |
|||
|
|||
static string Unity_DDX_Default( |
|||
[Slot(0, Binding.None)] Vector1 In, |
|||
[Slot(1, Binding.None)] out Vector1 Out) |
|||
{ |
|||
return |
|||
@"
|
|||
{ |
|||
Out = ddx(In); |
|||
} |
|||
";
|
|||
} |
|||
|
|||
static string Unity_DDX_Coarse( |
|||
[Slot(0, Binding.None)] Vector1 In, |
|||
[Slot(1, Binding.None)] out Vector1 Out) |
|||
{ |
|||
return |
|||
@"
|
|||
{ |
|||
Out = ddx_coarse(In); |
|||
} |
|||
";
|
|||
} |
|||
|
|||
static string Unity_DDX_Fine( |
|||
[Slot(0, Binding.None)] Vector1 In, |
|||
[Slot(1, Binding.None)] out Vector1 Out) |
|||
{ |
|||
return |
|||
@"
|
|||
{ |
|||
Out = ddx_fine(In); |
|||
} |
|||
";
|
|||
} |
|||
|
|||
static string Unity_DDY_Default( |
|||
[Slot(0, Binding.None)] Vector1 In, |
|||
[Slot(1, Binding.None)] out Vector1 Out) |
|||
{ |
|||
return |
|||
@"
|
|||
{ |
|||
Out = ddy(In); |
|||
} |
|||
";
|
|||
} |
|||
|
|||
static string Unity_DDY_Coarse( |
|||
[Slot(0, Binding.None)] Vector1 In, |
|||
[Slot(1, Binding.None)] out Vector1 Out) |
|||
{ |
|||
return |
|||
@"
|
|||
{ |
|||
Out = ddy_coarse(In); |
|||
} |
|||
";
|
|||
} |
|||
|
|||
static string Unity_DDY_Fine( |
|||
[Slot(0, Binding.None)] Vector1 In, |
|||
[Slot(1, Binding.None)] out Vector1 Out) |
|||
{ |
|||
return |
|||
@"
|
|||
{ |
|||
Out = ddy_fine(In); |
|||
} |
|||
";
|
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: e1fc64adb3d116647b70ce39fb0a01fd |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
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))); |
|||
} |
|||
";
|
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: e4bc0eb2ab0981b448548e5714f19f78 |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|
|||
using System.Reflection; |
|||
|
|||
namespace UnityEngine.MaterialGraph |
|||
{ |
|||
[Title("Vector/Projection Node")] |
|||
public class VectorProjectionNode : CodeFunctionNode |
|||
{ |
|||
public VectorProjectionNode() |
|||
{ |
|||
name = "VectorProjection"; |
|||
} |
|||
|
|||
protected override MethodInfo GetFunctionToConvert() |
|||
{ |
|||
return GetType().GetMethod("Unity_VectorProjection", BindingFlags.Static | BindingFlags.NonPublic); |
|||
} |
|||
|
|||
static string Unity_VectorProjection( |
|||
[Slot(0, Binding.None)] DynamicDimensionVector first, |
|||
[Slot(1, Binding.None)] DynamicDimensionVector second, |
|||
[Slot(2, Binding.None)] out DynamicDimensionVector result) |
|||
{ |
|||
return |
|||
@"
|
|||
{ |
|||
result = second * dot(first, second) / dot(second, second); |
|||
}";
|
|||
} |
|||
} |
|||
} |
|
|||
using System.Reflection; |
|||
|
|||
namespace UnityEngine.MaterialGraph |
|||
{ |
|||
[Title("Vector/Rejection Node")] |
|||
public class VectorRejectionNode : CodeFunctionNode |
|||
{ |
|||
public VectorRejectionNode() |
|||
{ |
|||
name = "VectorRejection"; |
|||
} |
|||
|
|||
protected override MethodInfo GetFunctionToConvert() |
|||
{ |
|||
return GetType().GetMethod("Unity_VectorRejection", BindingFlags.Static | BindingFlags.NonPublic); |
|||
} |
|||
|
|||
static string Unity_VectorRejection( |
|||
[Slot(0, Binding.None)] DynamicDimensionVector first, |
|||
[Slot(1, Binding.None)] DynamicDimensionVector second, |
|||
[Slot(2, Binding.None)] out DynamicDimensionVector result) |
|||
{ |
|||
return |
|||
@"
|
|||
{ |
|||
result = first - (second * dot(first, second) / dot(second, second)); |
|||
} |
|||
";
|
|||
} |
|||
} |
|||
} |
撰写
预览
正在加载...
取消
保存
Reference in new issue