浏览代码
Fixes for PR
Fixes for PR
- Rename Tangent/Normal/Bitangent nodes - Make GetHLSLSafeNAme static - Rename MatrixCommonNode > TransformationMatrixNode - Rename enums for Log and Exponential base - String interpolation > Switch statement - Full names for all Trigonometry nodes - Rename Reflect/Project/Reject > Reflection/Projection/Rejection - Rename Fresnel/FresnelEffect - Rename unit enum in RotateNode (remove duplicate in UVTransform) - Add min/max clamp to Gradient2D evaluation/main
Matt Dean
7 年前
当前提交
e44629cb
共有 65 个文件被更改,包括 735 次插入 和 672 次删除
-
5MaterialGraphProject/Assets/NewNodes/Editor/Kill/UVTransform.cs
-
2MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/AbstractMaterialGraph.cs
-
2MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/AbstractMaterialNode.cs
-
7MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Gradient/Gradient2DNode.cs
-
32MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Advanced/ExponentialNode.cs
-
36MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Advanced/LogNode.cs
-
49MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Advanced/ReciprocalNode.cs
-
11MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Derivative/DDXNode.cs
-
11MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Derivative/DDXYNode.cs
-
11MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Derivative/DDYNode.cs
-
17MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/UV/RotateNode.cs
-
34MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/BitangentVectorNode.cs
-
34MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/NormalVectorNode.cs
-
34MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/TangentVectorNode.cs
-
83MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Matrix/TransformationMatrixNode.cs
-
30MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Trigonometry/ArccosineNode.cs
-
30MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Trigonometry/ArcsineNode.cs
-
31MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Trigonometry/Arctangent2Node.cs
-
30MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Trigonometry/ArctangentNode.cs
-
30MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Trigonometry/CosineNode.cs
-
30MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Trigonometry/HyperbolicCosineNode.cs
-
30MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Trigonometry/HyperbolicSineNode.cs
-
30MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Trigonometry/HyperbolicTangentNode.cs
-
30MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Trigonometry/SineNode.cs
-
30MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Trigonometry/TangentNode.cs
-
33MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Vector/FresnelEffectNode.cs
-
30MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Vector/ProjectionNode.cs
-
32MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Vector/ReflectionNode.cs
-
31MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Vector/RejectionNode.cs
-
34MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/BitangentNode.cs
-
34MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/NormalNode.cs
-
34MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/TangentNode.cs
-
83MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Matrix/MatrixCommonNode.cs
-
30MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Trigonometry/ArcCosNode.cs
-
30MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Trigonometry/ArcSinNode.cs
-
31MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Trigonometry/ArcTan2Node.cs
-
30MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Trigonometry/ArcTanNode.cs
-
30MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Trigonometry/CosNode.cs
-
30MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Trigonometry/HyperbolicCosNode.cs
-
30MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Trigonometry/HyperbolicSinNode.cs
-
30MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Trigonometry/HyperbolicTanNode.cs
-
30MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Trigonometry/SinNode.cs
-
30MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Trigonometry/TanNode.cs
-
33MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Vector/FresnelNode.cs
-
30MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Vector/ProjectNode.cs
-
32MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Vector/ReflectNode.cs
-
31MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Vector/RejectNode.cs
-
0/MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/BitangentVectorNode.cs.meta
-
0/MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/NormalVectorNode.cs.meta
-
0/MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/TangentVectorNode.cs.meta
-
0/MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Matrix/TransformationMatrixNode.cs.meta
-
0/MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Trigonometry/ArccosineNode.cs.meta
-
0/MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Trigonometry/ArcsineNode.cs.meta
-
0/MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Trigonometry/Arctangent2Node.cs.meta
-
0/MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Trigonometry/ArctangentNode.cs.meta
-
0/MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Trigonometry/CosineNode.cs.meta
-
0/MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Trigonometry/HyperbolicCosineNode.cs.meta
-
0/MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Trigonometry/HyperbolicSineNode.cs.meta
-
0/MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Trigonometry/HyperbolicTangentNode.cs.meta
-
0/MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Trigonometry/SineNode.cs.meta
-
0/MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Trigonometry/TangentNode.cs.meta
-
0/MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Vector/FresnelEffectNode.cs.meta
-
0/MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Vector/ProjectionNode.cs.meta
-
0/MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Vector/ReflectionNode.cs.meta
-
0/MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Vector/RejectionNode.cs.meta
|
|||
using UnityEngine; |
|||
using UnityEditor.Graphing; |
|||
|
|||
namespace UnityEditor.ShaderGraph |
|||
{ |
|||
[Title("Input/Geometry/Bitangent Vector")] |
|||
public class BitangentVectorNode : GeometryNode, IMayRequireBitangent |
|||
{ |
|||
public const int kOutputSlotId = 0; |
|||
public const string kOutputSlotName = "Out"; |
|||
|
|||
public BitangentVectorNode() |
|||
{ |
|||
name = "Bitangent Vector"; |
|||
UpdateNodeAfterDeserialization(); |
|||
} |
|||
|
|||
public sealed override void UpdateNodeAfterDeserialization() |
|||
{ |
|||
AddSlot(new Vector3MaterialSlot(kOutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, new Vector4(0, 0, 1))); |
|||
RemoveSlotsNameNotMatching(new[] { kOutputSlotId }); |
|||
} |
|||
|
|||
public override string GetVariableNameForSlot(int slotId) |
|||
{ |
|||
return space.ToVariableName(InterpolatorType.BiTangent); |
|||
} |
|||
|
|||
public NeededCoordinateSpace RequiresBitangent() |
|||
{ |
|||
return space.ToNeededCoordinateSpace(); |
|||
} |
|||
} |
|||
} |
|
|||
using UnityEngine; |
|||
using UnityEditor.Graphing; |
|||
|
|||
namespace UnityEditor.ShaderGraph |
|||
{ |
|||
[Title("Input/Geometry/Normal Vector")] |
|||
public class NormalVectorNode : GeometryNode, IMayRequireNormal |
|||
{ |
|||
public const int kOutputSlotId = 0; |
|||
public const string kOutputSlotName = "Out"; |
|||
|
|||
public NormalVectorNode() |
|||
{ |
|||
name = "Normal Vector"; |
|||
UpdateNodeAfterDeserialization(); |
|||
} |
|||
|
|||
public sealed override void UpdateNodeAfterDeserialization() |
|||
{ |
|||
AddSlot(new Vector3MaterialSlot(kOutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, new Vector4(0, 0, 1))); |
|||
RemoveSlotsNameNotMatching(new[] { kOutputSlotId }); |
|||
} |
|||
|
|||
public override string GetVariableNameForSlot(int slotId) |
|||
{ |
|||
return space.ToVariableName(InterpolatorType.Normal); |
|||
} |
|||
|
|||
public NeededCoordinateSpace RequiresNormal() |
|||
{ |
|||
return space.ToNeededCoordinateSpace(); |
|||
} |
|||
} |
|||
} |
|
|||
using UnityEngine; |
|||
using UnityEditor.Graphing; |
|||
|
|||
namespace UnityEditor.ShaderGraph |
|||
{ |
|||
[Title("Input/Geometry/Tangent Vector")] |
|||
public class TangentVectorNode : GeometryNode, IMayRequireTangent |
|||
{ |
|||
public const int kOutputSlotId = 0; |
|||
public const string kOutputSlotName = "Out"; |
|||
|
|||
public TangentVectorNode() |
|||
{ |
|||
name = "Tangent Vector"; |
|||
UpdateNodeAfterDeserialization(); |
|||
} |
|||
|
|||
public sealed override void UpdateNodeAfterDeserialization() |
|||
{ |
|||
AddSlot(new Vector3MaterialSlot(kOutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, new Vector4(0, 0, 1, 1))); |
|||
RemoveSlotsNameNotMatching(new[] { kOutputSlotId }); |
|||
} |
|||
|
|||
public override string GetVariableNameForSlot(int slotId) |
|||
{ |
|||
return space.ToVariableName(InterpolatorType.Tangent); |
|||
} |
|||
|
|||
public NeededCoordinateSpace RequiresTangent() |
|||
{ |
|||
return space.ToNeededCoordinateSpace(); |
|||
} |
|||
} |
|||
} |
|
|||
using System.ComponentModel; |
|||
using UnityEditor.Graphing; |
|||
using System.Collections.Generic; |
|||
using UnityEditor.ShaderGraph.Drawing.Controls; |
|||
using UnityEngine; |
|||
|
|||
namespace UnityEditor.ShaderGraph |
|||
{ |
|||
public enum TransformationMatrixType |
|||
{ |
|||
ModelView, |
|||
View, |
|||
Projection, |
|||
ViewProjection, |
|||
TransposeModelView, |
|||
InverseTransposeModelView, |
|||
ObjectToWorld, |
|||
WorldToObject |
|||
}; |
|||
|
|||
[Title("Input/Matrix/Transformation Matrix")] |
|||
public class TransformationMatrixNode : AbstractMaterialNode |
|||
{ |
|||
static Dictionary<TransformationMatrixType, string> m_matrixList = new Dictionary<TransformationMatrixType, string> |
|||
{ |
|||
{TransformationMatrixType.ModelView, "UNITY_MATRIX_MV"}, |
|||
{TransformationMatrixType.View, "UNITY_MATRIX_V"}, |
|||
{TransformationMatrixType.Projection, "UNITY_MATRIX_P"}, |
|||
{TransformationMatrixType.ViewProjection, "UNITY_MATRIX_VP"}, |
|||
{TransformationMatrixType.TransposeModelView, "UNITY_MATRIX_T_MV"}, |
|||
{TransformationMatrixType.InverseTransposeModelView, "UNITY_MATRIX_IT_MV"}, |
|||
{TransformationMatrixType.ObjectToWorld, "unity_ObjectToWorld"}, |
|||
{TransformationMatrixType.WorldToObject, "unity_WorldToObject"}, |
|||
}; |
|||
|
|||
[SerializeField] |
|||
private TransformationMatrixType m_matrix = TransformationMatrixType.ModelView; |
|||
|
|||
private const int kOutputSlotId = 0; |
|||
private const string kOutputSlotName = "Out"; |
|||
|
|||
public override bool hasPreview { get { return false; } } |
|||
|
|||
[EnumControl("")] |
|||
public TransformationMatrixType matrix |
|||
{ |
|||
get { return m_matrix; } |
|||
set |
|||
{ |
|||
if (m_matrix == value) |
|||
return; |
|||
|
|||
m_matrix = value; |
|||
if (onModified != null) |
|||
{ |
|||
onModified(this, ModificationScope.Graph); |
|||
} |
|||
} |
|||
} |
|||
|
|||
public TransformationMatrixNode() |
|||
{ |
|||
name = "Transformation Matrix"; |
|||
UpdateNodeAfterDeserialization(); |
|||
} |
|||
|
|||
public sealed override void UpdateNodeAfterDeserialization() |
|||
{ |
|||
AddSlot(new Matrix4MaterialSlot(kOutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output)); |
|||
RemoveSlotsNameNotMatching(new[] { kOutputSlotId }); |
|||
} |
|||
|
|||
public override string GetVariableNameForSlot(int slotId) |
|||
{ |
|||
return m_matrixList[matrix]; |
|||
} |
|||
|
|||
public bool RequiresVertexColor() |
|||
{ |
|||
return true; |
|||
} |
|||
} |
|||
} |
|
|||
using System.Reflection; |
|||
|
|||
namespace UnityEditor.ShaderGraph |
|||
{ |
|||
[Title("Math/Trigonometry/Arccosine")] |
|||
public class ArccosineNode : CodeFunctionNode |
|||
{ |
|||
public ArccosineNode() |
|||
{ |
|||
name = "Arccosine"; |
|||
} |
|||
|
|||
protected override MethodInfo GetFunctionToConvert() |
|||
{ |
|||
return GetType().GetMethod("Unity_Arccosine", BindingFlags.Static | BindingFlags.NonPublic); |
|||
} |
|||
|
|||
static string Unity_Arccosine( |
|||
[Slot(0, Binding.None)] DynamicDimensionVector In, |
|||
[Slot(1, Binding.None)] out DynamicDimensionVector Out) |
|||
{ |
|||
return |
|||
@"
|
|||
{ |
|||
Out = acos(In); |
|||
} |
|||
";
|
|||
} |
|||
} |
|||
} |
|
|||
using System.Reflection; |
|||
|
|||
namespace UnityEditor.ShaderGraph |
|||
{ |
|||
[Title("Math/Trigonometry/Arcsine")] |
|||
public class ArcsineNode : CodeFunctionNode |
|||
{ |
|||
public ArcsineNode() |
|||
{ |
|||
name = "Arcsine"; |
|||
} |
|||
|
|||
protected override MethodInfo GetFunctionToConvert() |
|||
{ |
|||
return GetType().GetMethod("Unity_Arcsine", BindingFlags.Static | BindingFlags.NonPublic); |
|||
} |
|||
|
|||
static string Unity_Arcsine( |
|||
[Slot(0, Binding.None)] DynamicDimensionVector In, |
|||
[Slot(1, Binding.None)] out DynamicDimensionVector Out) |
|||
{ |
|||
return |
|||
@"
|
|||
{ |
|||
Out = asin(In); |
|||
} |
|||
";
|
|||
} |
|||
} |
|||
} |
|
|||
using System.Reflection; |
|||
|
|||
namespace UnityEditor.ShaderGraph |
|||
{ |
|||
[Title("Math/Trigonometry/Arctangent2")] |
|||
public class Arctangent2Node : CodeFunctionNode |
|||
{ |
|||
public Arctangent2Node() |
|||
{ |
|||
name = "Arctangent2"; |
|||
} |
|||
|
|||
protected override MethodInfo GetFunctionToConvert() |
|||
{ |
|||
return GetType().GetMethod("Unity_Arctangent2", BindingFlags.Static | BindingFlags.NonPublic); |
|||
} |
|||
|
|||
static string Unity_Arctangent2( |
|||
[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 UnityEditor.ShaderGraph |
|||
{ |
|||
[Title("Math/Trigonometry/Arctangent")] |
|||
public class ArctangentNode : CodeFunctionNode |
|||
{ |
|||
public ArctangentNode() |
|||
{ |
|||
name = "Arctangent"; |
|||
} |
|||
|
|||
protected override MethodInfo GetFunctionToConvert() |
|||
{ |
|||
return GetType().GetMethod("Unity_Arctangent", BindingFlags.Static | BindingFlags.NonPublic); |
|||
} |
|||
|
|||
static string Unity_Arctangent( |
|||
[Slot(0, Binding.None)] DynamicDimensionVector In, |
|||
[Slot(1, Binding.None)] out DynamicDimensionVector Out) |
|||
{ |
|||
return |
|||
@"
|
|||
{ |
|||
Out = atan(In); |
|||
} |
|||
";
|
|||
} |
|||
} |
|||
} |
|
|||
using System.Reflection; |
|||
|
|||
namespace UnityEditor.ShaderGraph |
|||
{ |
|||
[Title("Math/Trigonometry/Cosine")] |
|||
public class CosineNode : CodeFunctionNode |
|||
{ |
|||
public CosineNode() |
|||
{ |
|||
name = "Cosine"; |
|||
} |
|||
|
|||
protected override MethodInfo GetFunctionToConvert() |
|||
{ |
|||
return GetType().GetMethod("Unity_Cosine", BindingFlags.Static | BindingFlags.NonPublic); |
|||
} |
|||
|
|||
static string Unity_Cosine( |
|||
[Slot(0, Binding.None)] DynamicDimensionVector In, |
|||
[Slot(1, Binding.None)] out DynamicDimensionVector Out) |
|||
{ |
|||
return |
|||
@"
|
|||
{ |
|||
Out = cos(In); |
|||
} |
|||
";
|
|||
} |
|||
} |
|||
} |
|
|||
using System.Reflection; |
|||
|
|||
namespace UnityEditor.ShaderGraph |
|||
{ |
|||
[Title("Math/Trigonometry/Hyperbolic Cosine")] |
|||
class HyperbolicCosineNode : CodeFunctionNode |
|||
{ |
|||
public HyperbolicCosineNode() |
|||
{ |
|||
name = "Hyperbolic Cosine"; |
|||
} |
|||
|
|||
protected override MethodInfo GetFunctionToConvert() |
|||
{ |
|||
return GetType().GetMethod("Unity_HyperbolicCosine", BindingFlags.Static | BindingFlags.NonPublic); |
|||
} |
|||
|
|||
static string Unity_HyperbolicCosine( |
|||
[Slot(0, Binding.None)] DynamicDimensionVector In, |
|||
[Slot(1, Binding.None)] out DynamicDimensionVector Out) |
|||
{ |
|||
return |
|||
@"
|
|||
{ |
|||
Out = sinh(In); |
|||
} |
|||
";
|
|||
} |
|||
} |
|||
} |
|
|||
using System.Reflection; |
|||
|
|||
namespace UnityEditor.ShaderGraph |
|||
{ |
|||
[Title("Math/Trigonometry/Hyperbolic Sine")] |
|||
class HyperbolicSineNode : CodeFunctionNode |
|||
{ |
|||
public HyperbolicSineNode() |
|||
{ |
|||
name = "Hyperbolic Sine"; |
|||
} |
|||
|
|||
protected override MethodInfo GetFunctionToConvert() |
|||
{ |
|||
return GetType().GetMethod("Unity_HyperbolicSine", BindingFlags.Static | BindingFlags.NonPublic); |
|||
} |
|||
|
|||
static string Unity_HyperbolicSine( |
|||
[Slot(0, Binding.None)] DynamicDimensionVector In, |
|||
[Slot(1, Binding.None)] out DynamicDimensionVector Out) |
|||
{ |
|||
return |
|||
@"
|
|||
{ |
|||
Out = sinh(In); |
|||
} |
|||
";
|
|||
} |
|||
} |
|||
} |
|
|||
using System.Reflection; |
|||
|
|||
namespace UnityEditor.ShaderGraph |
|||
{ |
|||
[Title("Math/Trigonometry/Hyperbolic Tangent")] |
|||
class HyperbolicTangentNode : CodeFunctionNode |
|||
{ |
|||
public HyperbolicTangentNode() |
|||
{ |
|||
name = "Hyperbolic Tangent"; |
|||
} |
|||
|
|||
protected override MethodInfo GetFunctionToConvert() |
|||
{ |
|||
return GetType().GetMethod("Unity_HyperbolicTangent", BindingFlags.Static | BindingFlags.NonPublic); |
|||
} |
|||
|
|||
static string Unity_HyperbolicTangent( |
|||
[Slot(0, Binding.None)] DynamicDimensionVector In, |
|||
[Slot(1, Binding.None)] out DynamicDimensionVector Out) |
|||
{ |
|||
return |
|||
@"
|
|||
{ |
|||
Out = tanh(In); |
|||
} |
|||
";
|
|||
} |
|||
} |
|||
} |
|
|||
using System.Reflection; |
|||
|
|||
namespace UnityEditor.ShaderGraph |
|||
{ |
|||
[Title("Math/Trigonometry/Sine")] |
|||
class SineNode : CodeFunctionNode |
|||
{ |
|||
public SineNode() |
|||
{ |
|||
name = "Sine"; |
|||
} |
|||
|
|||
protected override MethodInfo GetFunctionToConvert() |
|||
{ |
|||
return GetType().GetMethod("Unity_Sine", BindingFlags.Static | BindingFlags.NonPublic); |
|||
} |
|||
|
|||
static string Unity_Sine( |
|||
[Slot(0, Binding.None)] DynamicDimensionVector In, |
|||
[Slot(1, Binding.None)] out DynamicDimensionVector Out) |
|||
{ |
|||
return |
|||
@"
|
|||
{ |
|||
Out = sin(In); |
|||
} |
|||
";
|
|||
} |
|||
} |
|||
} |
|
|||
using System.Reflection; |
|||
|
|||
namespace UnityEditor.ShaderGraph |
|||
{ |
|||
[Title("Math/Trigonometry/Tangent")] |
|||
public class TangentNode : CodeFunctionNode |
|||
{ |
|||
public TangentNode() |
|||
{ |
|||
name = "Tangent"; |
|||
} |
|||
|
|||
protected override MethodInfo GetFunctionToConvert() |
|||
{ |
|||
return GetType().GetMethod("Unity_Tangent", BindingFlags.Static | BindingFlags.NonPublic); |
|||
} |
|||
|
|||
static string Unity_Tangent( |
|||
[Slot(0, Binding.None)] DynamicDimensionVector In, |
|||
[Slot(1, Binding.None)] out DynamicDimensionVector Out) |
|||
{ |
|||
return |
|||
@"
|
|||
{ |
|||
Out = tan(In); |
|||
} |
|||
";
|
|||
} |
|||
} |
|||
} |
|
|||
using System.Reflection; |
|||
using UnityEngine; |
|||
|
|||
namespace UnityEditor.ShaderGraph |
|||
{ |
|||
[Title("Math/Vector/Fresnel Effect")] |
|||
class FresnelNode : CodeFunctionNode |
|||
{ |
|||
public FresnelNode() |
|||
{ |
|||
name = "Fresnel Effect"; |
|||
} |
|||
|
|||
protected override MethodInfo GetFunctionToConvert() |
|||
{ |
|||
return GetType().GetMethod("Unity_FresnelEffect", BindingFlags.Static | BindingFlags.NonPublic); |
|||
} |
|||
|
|||
static string Unity_FresnelEffect( |
|||
[Slot(0, Binding.None)] Vector3 Normal, |
|||
[Slot(1, Binding.None)] Vector3 ViewDir, |
|||
[Slot(2, Binding.None, 1, 1, 1, 1)] Vector1 Power, |
|||
[Slot(3, Binding.None)] out Vector1 Out) |
|||
{ |
|||
return |
|||
@"
|
|||
{ |
|||
Out = pow((1.0 - dot (normalize (Normal), normalize (ViewDir))), Power); |
|||
} |
|||
";
|
|||
} |
|||
} |
|||
} |
|
|||
using System.Reflection; |
|||
|
|||
namespace UnityEditor.ShaderGraph |
|||
{ |
|||
[Title("Math/Vector/Projection")] |
|||
public class ProjectionNode : CodeFunctionNode |
|||
{ |
|||
public ProjectionNode() |
|||
{ |
|||
name = "Projection"; |
|||
} |
|||
|
|||
protected override MethodInfo GetFunctionToConvert() |
|||
{ |
|||
return GetType().GetMethod("Unity_Projection", BindingFlags.Static | BindingFlags.NonPublic); |
|||
} |
|||
|
|||
static string Unity_Projection( |
|||
[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; |
|||
using UnityEngine; |
|||
|
|||
namespace UnityEditor.ShaderGraph |
|||
{ |
|||
[Title("Math/Vector/Reflection")] |
|||
class ReflectionNode : CodeFunctionNode |
|||
{ |
|||
public ReflectionNode() |
|||
{ |
|||
name = "Reflection"; |
|||
} |
|||
|
|||
protected override MethodInfo GetFunctionToConvert() |
|||
{ |
|||
return GetType().GetMethod("Unity_Reflection", BindingFlags.Static | BindingFlags.NonPublic); |
|||
} |
|||
|
|||
static string Unity_Reflection( |
|||
[Slot(0, Binding.None)] Vector3 In, |
|||
[Slot(1, Binding.None)] Vector3 Normal, |
|||
[Slot(2, Binding.None)] out Vector3 Out) |
|||
{ |
|||
Out = Vector3.one; |
|||
|
|||
return @"
|
|||
{ |
|||
Out = reflect(In, Normal); |
|||
}";
|
|||
} |
|||
} |
|||
} |
|
|||
using System.Reflection; |
|||
|
|||
namespace UnityEditor.ShaderGraph |
|||
{ |
|||
[Title("Math/Vector/Rejection")] |
|||
public class RejectionNode : CodeFunctionNode |
|||
{ |
|||
public RejectionNode() |
|||
{ |
|||
name = "Rejection"; |
|||
} |
|||
|
|||
protected override MethodInfo GetFunctionToConvert() |
|||
{ |
|||
return GetType().GetMethod("Unity_Rejection", BindingFlags.Static | BindingFlags.NonPublic); |
|||
} |
|||
|
|||
static string Unity_Rejection( |
|||
[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 UnityEngine; |
|||
using UnityEditor.Graphing; |
|||
|
|||
namespace UnityEditor.ShaderGraph |
|||
{ |
|||
[Title("Input/Geometry/Bitangent")] |
|||
public class BitangentNode : GeometryNode, IMayRequireBitangent |
|||
{ |
|||
public const int kOutputSlotId = 0; |
|||
public const string kOutputSlotName = "Out"; |
|||
|
|||
public BitangentNode() |
|||
{ |
|||
name = "Bitangent"; |
|||
UpdateNodeAfterDeserialization(); |
|||
} |
|||
|
|||
public sealed override void UpdateNodeAfterDeserialization() |
|||
{ |
|||
AddSlot(new Vector3MaterialSlot(kOutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, new Vector4(0, 0, 1))); |
|||
RemoveSlotsNameNotMatching(new[] { kOutputSlotId }); |
|||
} |
|||
|
|||
public override string GetVariableNameForSlot(int slotId) |
|||
{ |
|||
return space.ToVariableName(InterpolatorType.BiTangent); |
|||
} |
|||
|
|||
public NeededCoordinateSpace RequiresBitangent() |
|||
{ |
|||
return space.ToNeededCoordinateSpace(); |
|||
} |
|||
} |
|||
} |
|
|||
using UnityEngine; |
|||
using UnityEditor.Graphing; |
|||
|
|||
namespace UnityEditor.ShaderGraph |
|||
{ |
|||
[Title("Input/Geometry/Normal")] |
|||
public class NormalNode : GeometryNode, IMayRequireNormal |
|||
{ |
|||
public const int kOutputSlotId = 0; |
|||
public const string kOutputSlotName = "Out"; |
|||
|
|||
public NormalNode() |
|||
{ |
|||
name = "Normal"; |
|||
UpdateNodeAfterDeserialization(); |
|||
} |
|||
|
|||
public sealed override void UpdateNodeAfterDeserialization() |
|||
{ |
|||
AddSlot(new Vector3MaterialSlot(kOutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, new Vector4(0, 0, 1))); |
|||
RemoveSlotsNameNotMatching(new[] { kOutputSlotId }); |
|||
} |
|||
|
|||
public override string GetVariableNameForSlot(int slotId) |
|||
{ |
|||
return space.ToVariableName(InterpolatorType.Normal); |
|||
} |
|||
|
|||
public NeededCoordinateSpace RequiresNormal() |
|||
{ |
|||
return space.ToNeededCoordinateSpace(); |
|||
} |
|||
} |
|||
} |
|
|||
using UnityEngine; |
|||
using UnityEditor.Graphing; |
|||
|
|||
namespace UnityEditor.ShaderGraph |
|||
{ |
|||
[Title("Input/Geometry/Tangent")] |
|||
public class TangentNode : GeometryNode, IMayRequireTangent |
|||
{ |
|||
public const int kOutputSlotId = 0; |
|||
public const string kOutputSlotName = "Out"; |
|||
|
|||
public TangentNode() |
|||
{ |
|||
name = "Tangent"; |
|||
UpdateNodeAfterDeserialization(); |
|||
} |
|||
|
|||
public sealed override void UpdateNodeAfterDeserialization() |
|||
{ |
|||
AddSlot(new Vector3MaterialSlot(kOutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, new Vector4(0, 0, 1, 1))); |
|||
RemoveSlotsNameNotMatching(new[] { kOutputSlotId }); |
|||
} |
|||
|
|||
public override string GetVariableNameForSlot(int slotId) |
|||
{ |
|||
return space.ToVariableName(InterpolatorType.Tangent); |
|||
} |
|||
|
|||
public NeededCoordinateSpace RequiresTangent() |
|||
{ |
|||
return space.ToNeededCoordinateSpace(); |
|||
} |
|||
} |
|||
} |
|
|||
using System.ComponentModel; |
|||
using UnityEditor.Graphing; |
|||
using System.Collections.Generic; |
|||
using UnityEditor.ShaderGraph.Drawing.Controls; |
|||
using UnityEngine; |
|||
|
|||
namespace UnityEditor.ShaderGraph |
|||
{ |
|||
public enum CommonMatrixType |
|||
{ |
|||
ModelView, |
|||
View, |
|||
Projection, |
|||
ViewProjection, |
|||
TransposeModelView, |
|||
InverseTransposeModelView, |
|||
ObjectToWorld, |
|||
WorldToObject |
|||
}; |
|||
|
|||
[Title("Input/Matrix/Common Matrix")] |
|||
public class MatrixCommonNode : AbstractMaterialNode |
|||
{ |
|||
static Dictionary<CommonMatrixType, string> m_matrixList = new Dictionary<CommonMatrixType, string> |
|||
{ |
|||
{CommonMatrixType.ModelView, "UNITY_MATRIX_MV"}, |
|||
{CommonMatrixType.View, "UNITY_MATRIX_V"}, |
|||
{CommonMatrixType.Projection, "UNITY_MATRIX_P"}, |
|||
{CommonMatrixType.ViewProjection, "UNITY_MATRIX_VP"}, |
|||
{CommonMatrixType.TransposeModelView, "UNITY_MATRIX_T_MV"}, |
|||
{CommonMatrixType.InverseTransposeModelView, "UNITY_MATRIX_IT_MV"}, |
|||
{CommonMatrixType.ObjectToWorld, "unity_ObjectToWorld"}, |
|||
{CommonMatrixType.WorldToObject, "unity_WorldToObject"}, |
|||
}; |
|||
|
|||
[SerializeField] |
|||
private CommonMatrixType m_matrix = CommonMatrixType.ModelView; |
|||
|
|||
private const int kOutputSlotId = 0; |
|||
private const string kOutputSlotName = "Out"; |
|||
|
|||
public override bool hasPreview { get { return false; } } |
|||
|
|||
[EnumControl("")] |
|||
public CommonMatrixType matrix |
|||
{ |
|||
get { return m_matrix; } |
|||
set |
|||
{ |
|||
if (m_matrix == value) |
|||
return; |
|||
|
|||
m_matrix = value; |
|||
if (onModified != null) |
|||
{ |
|||
onModified(this, ModificationScope.Graph); |
|||
} |
|||
} |
|||
} |
|||
|
|||
public MatrixCommonNode() |
|||
{ |
|||
name = "CommonMatrix"; |
|||
UpdateNodeAfterDeserialization(); |
|||
} |
|||
|
|||
public sealed override void UpdateNodeAfterDeserialization() |
|||
{ |
|||
AddSlot(new Matrix4MaterialSlot(kOutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output)); |
|||
RemoveSlotsNameNotMatching(new[] { kOutputSlotId }); |
|||
} |
|||
|
|||
public override string GetVariableNameForSlot(int slotId) |
|||
{ |
|||
return m_matrixList[matrix]; |
|||
} |
|||
|
|||
public bool RequiresVertexColor() |
|||
{ |
|||
return true; |
|||
} |
|||
} |
|||
} |
|
|||
using System.Reflection; |
|||
|
|||
namespace UnityEditor.ShaderGraph |
|||
{ |
|||
[Title("Math/Trigonometry/ArcCos")] |
|||
public class ArcCosNode : CodeFunctionNode |
|||
{ |
|||
public ArcCosNode() |
|||
{ |
|||
name = "ArcCos"; |
|||
} |
|||
|
|||
protected override MethodInfo GetFunctionToConvert() |
|||
{ |
|||
return GetType().GetMethod("Unity_ArcCos", BindingFlags.Static | BindingFlags.NonPublic); |
|||
} |
|||
|
|||
static string Unity_ArcCos( |
|||
[Slot(0, Binding.None)] DynamicDimensionVector In, |
|||
[Slot(1, Binding.None)] out DynamicDimensionVector Out) |
|||
{ |
|||
return |
|||
@"
|
|||
{ |
|||
Out = acos(In); |
|||
} |
|||
";
|
|||
} |
|||
} |
|||
} |
|
|||
using System.Reflection; |
|||
|
|||
namespace UnityEditor.ShaderGraph |
|||
{ |
|||
[Title("Math/Trigonometry/ArcSin")] |
|||
public class ArcSinNode : CodeFunctionNode |
|||
{ |
|||
public ArcSinNode() |
|||
{ |
|||
name = "ArcSin"; |
|||
} |
|||
|
|||
protected override MethodInfo GetFunctionToConvert() |
|||
{ |
|||
return GetType().GetMethod("Unity_ArcSin", BindingFlags.Static | BindingFlags.NonPublic); |
|||
} |
|||
|
|||
static string Unity_ArcSin( |
|||
[Slot(0, Binding.None)] DynamicDimensionVector In, |
|||
[Slot(1, Binding.None)] out DynamicDimensionVector Out) |
|||
{ |
|||
return |
|||
@"
|
|||
{ |
|||
Out = asin(In); |
|||
} |
|||
";
|
|||
} |
|||
} |
|||
} |
|
|||
using System.Reflection; |
|||
|
|||
namespace UnityEditor.ShaderGraph |
|||
{ |
|||
[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 UnityEditor.ShaderGraph |
|||
{ |
|||
[Title("Math/Trigonometry/ArcTan")] |
|||
public class ArcTanNode : CodeFunctionNode |
|||
{ |
|||
public ArcTanNode() |
|||
{ |
|||
name = "ArcTan"; |
|||
} |
|||
|
|||
protected override MethodInfo GetFunctionToConvert() |
|||
{ |
|||
return GetType().GetMethod("Unity_ArcTan", BindingFlags.Static | BindingFlags.NonPublic); |
|||
} |
|||
|
|||
static string Unity_ArcTan( |
|||
[Slot(0, Binding.None)] DynamicDimensionVector In, |
|||
[Slot(1, Binding.None)] out DynamicDimensionVector Out) |
|||
{ |
|||
return |
|||
@"
|
|||
{ |
|||
Out = atan(In); |
|||
} |
|||
";
|
|||
} |
|||
} |
|||
} |
|
|||
using System.Reflection; |
|||
|
|||
namespace UnityEditor.ShaderGraph |
|||
{ |
|||
[Title("Math/Trigonometry/Cos")] |
|||
public class CosNode : CodeFunctionNode |
|||
{ |
|||
public CosNode() |
|||
{ |
|||
name = "Cos"; |
|||
} |
|||
|
|||
protected override MethodInfo GetFunctionToConvert() |
|||
{ |
|||
return GetType().GetMethod("Unity_Cos", BindingFlags.Static | BindingFlags.NonPublic); |
|||
} |
|||
|
|||
static string Unity_Cos( |
|||
[Slot(0, Binding.None)] DynamicDimensionVector In, |
|||
[Slot(1, Binding.None)] out DynamicDimensionVector Out) |
|||
{ |
|||
return |
|||
@"
|
|||
{ |
|||
Out = cos(In); |
|||
} |
|||
";
|
|||
} |
|||
} |
|||
} |
|
|||
using System.Reflection; |
|||
|
|||
namespace UnityEditor.ShaderGraph |
|||
{ |
|||
[Title("Math/Trigonometry/Hyperbolic Cos")] |
|||
class HyperbolicCosNode : CodeFunctionNode |
|||
{ |
|||
public HyperbolicCosNode() |
|||
{ |
|||
name = "Hyperbolic Cos"; |
|||
} |
|||
|
|||
protected override MethodInfo GetFunctionToConvert() |
|||
{ |
|||
return GetType().GetMethod("Unity_HyperbolicCos", BindingFlags.Static | BindingFlags.NonPublic); |
|||
} |
|||
|
|||
static string Unity_HyperbolicCos( |
|||
[Slot(0, Binding.None)] DynamicDimensionVector In, |
|||
[Slot(1, Binding.None)] out DynamicDimensionVector Out) |
|||
{ |
|||
return |
|||
@"
|
|||
{ |
|||
Out = sinh(In); |
|||
} |
|||
";
|
|||
} |
|||
} |
|||
} |
|
|||
using System.Reflection; |
|||
|
|||
namespace UnityEditor.ShaderGraph |
|||
{ |
|||
[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); |
|||
} |
|||
";
|
|||
} |
|||
} |
|||
} |
|
|||
using System.Reflection; |
|||
|
|||
namespace UnityEditor.ShaderGraph |
|||
{ |
|||
[Title("Math/Trigonometry/Hyperbolic Tan")] |
|||
class HyperbolicTanNode : CodeFunctionNode |
|||
{ |
|||
public HyperbolicTanNode() |
|||
{ |
|||
name = "Hyperbolic Tan"; |
|||
} |
|||
|
|||
protected override MethodInfo GetFunctionToConvert() |
|||
{ |
|||
return GetType().GetMethod("Unity_HyperbolicTan", BindingFlags.Static | BindingFlags.NonPublic); |
|||
} |
|||
|
|||
static string Unity_HyperbolicTan( |
|||
[Slot(0, Binding.None)] DynamicDimensionVector In, |
|||
[Slot(1, Binding.None)] out DynamicDimensionVector Out) |
|||
{ |
|||
return |
|||
@"
|
|||
{ |
|||
Out = tanh(In); |
|||
} |
|||
";
|
|||
} |
|||
} |
|||
} |
|
|||
using System.Reflection; |
|||
|
|||
namespace UnityEditor.ShaderGraph |
|||
{ |
|||
[Title("Math/Trigonometry/Sin")] |
|||
class SinNode : CodeFunctionNode |
|||
{ |
|||
public SinNode() |
|||
{ |
|||
name = "Sin"; |
|||
} |
|||
|
|||
protected override MethodInfo GetFunctionToConvert() |
|||
{ |
|||
return GetType().GetMethod("Unity_Sin", BindingFlags.Static | BindingFlags.NonPublic); |
|||
} |
|||
|
|||
static string Unity_Sin( |
|||
[Slot(0, Binding.None)] DynamicDimensionVector In, |
|||
[Slot(1, Binding.None)] out DynamicDimensionVector Out) |
|||
{ |
|||
return |
|||
@"
|
|||
{ |
|||
Out = sin(In); |
|||
} |
|||
";
|
|||
} |
|||
} |
|||
} |
|
|||
using System.Reflection; |
|||
|
|||
namespace UnityEditor.ShaderGraph |
|||
{ |
|||
[Title("Math/Trigonometry/Tan")] |
|||
public class TanNode : CodeFunctionNode |
|||
{ |
|||
public TanNode() |
|||
{ |
|||
name = "Tan"; |
|||
} |
|||
|
|||
protected override MethodInfo GetFunctionToConvert() |
|||
{ |
|||
return GetType().GetMethod("Unity_Tan", BindingFlags.Static | BindingFlags.NonPublic); |
|||
} |
|||
|
|||
static string Unity_Tan( |
|||
[Slot(0, Binding.None)] DynamicDimensionVector In, |
|||
[Slot(1, Binding.None)] out DynamicDimensionVector Out) |
|||
{ |
|||
return |
|||
@"
|
|||
{ |
|||
Out = tan(In); |
|||
} |
|||
";
|
|||
} |
|||
} |
|||
} |
|
|||
using System.Reflection; |
|||
using UnityEngine; |
|||
|
|||
namespace UnityEditor.ShaderGraph |
|||
{ |
|||
[Title("Math/Vector/Fresnel")] |
|||
class FresnelNode : CodeFunctionNode |
|||
{ |
|||
public FresnelNode() |
|||
{ |
|||
name = "Fresnel"; |
|||
} |
|||
|
|||
protected override MethodInfo GetFunctionToConvert() |
|||
{ |
|||
return GetType().GetMethod("Unity_Fresnel", BindingFlags.Static | BindingFlags.NonPublic); |
|||
} |
|||
|
|||
static string Unity_Fresnel( |
|||
[Slot(0, Binding.None)] Vector3 Normal, |
|||
[Slot(1, Binding.None)] Vector3 ViewDir, |
|||
[Slot(2, Binding.None, 1, 1, 1, 1)] Vector1 Power, |
|||
[Slot(3, Binding.None)] out Vector1 Out) |
|||
{ |
|||
return |
|||
@"
|
|||
{ |
|||
Out = pow((1.0 - dot (normalize (Normal), normalize (ViewDir))), Power); |
|||
} |
|||
";
|
|||
} |
|||
} |
|||
} |
|
|||
using System.Reflection; |
|||
|
|||
namespace UnityEditor.ShaderGraph |
|||
{ |
|||
[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; |
|||
using UnityEngine; |
|||
|
|||
namespace UnityEditor.ShaderGraph |
|||
{ |
|||
[Title("Math/Vector/Reflect")] |
|||
class ReflectNode : CodeFunctionNode |
|||
{ |
|||
public ReflectNode() |
|||
{ |
|||
name = "Reflect"; |
|||
} |
|||
|
|||
protected override MethodInfo GetFunctionToConvert() |
|||
{ |
|||
return GetType().GetMethod("Unity_Reflect", BindingFlags.Static | BindingFlags.NonPublic); |
|||
} |
|||
|
|||
static string Unity_Reflect( |
|||
[Slot(0, Binding.None)] Vector3 In, |
|||
[Slot(1, Binding.None)] Vector3 Normal, |
|||
[Slot(2, Binding.None)] out Vector3 Out) |
|||
{ |
|||
Out = Vector3.one; |
|||
|
|||
return @"
|
|||
{ |
|||
Out = reflect(In, Normal); |
|||
}";
|
|||
} |
|||
} |
|||
} |
|
|||
using System.Reflection; |
|||
|
|||
namespace UnityEditor.ShaderGraph |
|||
{ |
|||
[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)); |
|||
} |
|||
";
|
|||
} |
|||
} |
|||
} |
撰写
预览
正在加载...
取消
保存
Reference in new issue