From 5792ffa06fbdfb1135843b1804569cfe59e0eb3c Mon Sep 17 00:00:00 2001 From: Chris Tchou Date: Wed, 22 Sep 2021 12:15:51 -0700 Subject: [PATCH 01/23] Adding dispose property drawer callback --- .../Editor/Data/Interfaces/IPropertyDrawer.cs | 2 ++ .../Editor/Drawing/Inspector/InspectorView.cs | 26 +++++++++++++++---- .../AbstractMaterialNodePropertyDrawer.cs | 6 +++++ .../PropertyDrawers/BoolPropertyDrawer.cs | 2 ++ .../PropertyDrawers/ColorPropertyDrawer.cs | 2 ++ .../PropertyDrawers/CubemapPropertyDrawer.cs | 2 ++ .../CustomFunctionNodePropertyDrawer.cs | 2 ++ .../PropertyDrawers/DropdownPropertyDrawer.cs | 2 ++ .../PropertyDrawers/EnumPropertyDrawer.cs | 2 ++ .../PropertyDrawers/FloatPropertyDrawer.cs | 2 ++ .../PropertyDrawers/GradientPropertyDrawer.cs | 2 ++ .../GraphDataPropertyDrawer.cs | 2 ++ .../PropertyDrawers/IntegerPropertyDrawer.cs | 2 ++ .../PropertyDrawers/MatrixPropertyDrawer.cs | 2 ++ .../SampleVirtualTextureNodePropertyDrawer.cs | 2 ++ .../SamplerStateNodePropertyDrawer.cs | 2 +- .../ShaderInputPropertyDrawer.cs | 2 ++ .../SubGraphOutputNodePropertyDrawer.cs | 2 ++ .../PropertyDrawers/TextPropertyDrawer.cs | 2 ++ .../Texture2DArrayPropertyDrawer.cs | 2 ++ .../Texture2DPropertyDrawer.cs | 2 ++ .../Texture3DPropertyDrawer.cs | 2 ++ .../ToggleDataPropertyDrawer.cs | 2 ++ .../PropertyDrawers/Vector2PropertyDrawer.cs | 2 ++ .../PropertyDrawers/Vector3PropertyDrawer.cs | 2 ++ .../PropertyDrawers/Vector4PropertyDrawer.cs | 2 ++ 26 files changed, 74 insertions(+), 6 deletions(-) diff --git a/com.unity.shadergraph/Editor/Data/Interfaces/IPropertyDrawer.cs b/com.unity.shadergraph/Editor/Data/Interfaces/IPropertyDrawer.cs index b43a4ab3ef1..7cd825769da 100644 --- a/com.unity.shadergraph/Editor/Data/Interfaces/IPropertyDrawer.cs +++ b/com.unity.shadergraph/Editor/Data/Interfaces/IPropertyDrawer.cs @@ -11,5 +11,7 @@ public interface IPropertyDrawer Action inspectorUpdateDelegate { get; set; } VisualElement DrawProperty(PropertyInfo propertyInfo, object actualObject, InspectableAttribute attribute); + + void DisposePropertyDrawer(); } } diff --git a/com.unity.shadergraph/Editor/Drawing/Inspector/InspectorView.cs b/com.unity.shadergraph/Editor/Drawing/Inspector/InspectorView.cs index 02005a22d78..d4c6538a6c9 100644 --- a/com.unity.shadergraph/Editor/Drawing/Inspector/InspectorView.cs +++ b/com.unity.shadergraph/Editor/Drawing/Inspector/InspectorView.cs @@ -36,6 +36,8 @@ class InspectorView : GraphSubWindow protected VisualElement m_GraphSettingsContainer; protected VisualElement m_NodeSettingsContainer; + List m_AllActivePropertyDrawers = new List(); + Label m_MaxItemsMessageLabel; void RegisterPropertyDrawer(Type newPropertyDrawerType) @@ -131,6 +133,11 @@ public void TriggerInspectorUpdate(IEnumerable selectionList) public void Update() { + // Tear down node all existing active property drawers, everything is getting rebuilt + foreach (IPropertyDrawer propDrawer in m_AllActivePropertyDrawers) + propDrawer.DisposePropertyDrawer(); + m_AllActivePropertyDrawers.Clear(); + ShowGraphSettings_Internal(m_GraphSettingsContainer); m_NodeSettingsContainer.Clear(); @@ -191,7 +198,7 @@ void DrawInspectable( IInspectable inspectable, IPropertyDrawer propertyDrawerToUse = null) { - InspectorUtils.GatherInspectorContent(m_PropertyDrawerList, outputVisualElement, inspectable, TriggerInspectorUpdate, propertyDrawerToUse); + InspectorUtils.GatherInspectorContent(m_PropertyDrawerList, outputVisualElement, inspectable, TriggerInspectorUpdate, m_AllActivePropertyDrawers, propertyDrawerToUse); } internal void HandleGraphChanges() @@ -222,11 +229,12 @@ void TriggerInspectorUpdate() // which for SG, is a representation of the settings in GraphData protected virtual void ShowGraphSettings_Internal(VisualElement contentContainer) { + contentContainer.Clear(); + var graphEditorView = ParentView.GetFirstAncestorOfType(); if (graphEditorView == null) return; - contentContainer.Clear(); DrawInspectable(contentContainer, (IInspectable)ParentView, m_graphSettingsPropertyDrawer); contentContainer.MarkDirtyRepaint(); } @@ -239,6 +247,7 @@ internal static void GatherInspectorContent( VisualElement outputVisualElement, IInspectable inspectable, Action propertyChangeCallback, + List allPropertyDrawerInstances, IPropertyDrawer propertyDrawerToUse = null) { var dataObject = inspectable.GetObjectToInspect(); @@ -257,16 +266,23 @@ internal static void GatherInspectorContent( var propertyType = propertyInfo.GetGetMethod(true).Invoke(inspectable, new object[] { }).GetType(); - if (IsPropertyTypeHandled(propertyDrawerList, propertyType, out var propertyDrawerTypeToUse)) + var propertyDrawerInstance = propertyDrawerToUse; + if (propertyDrawerInstance == null) + { + if (IsPropertyTypeHandled(propertyDrawerList, propertyType, out var propertyDrawerTypeToUse)) + propertyDrawerInstance = (IPropertyDrawer)Activator.CreateInstance(propertyDrawerTypeToUse); + } + + if (propertyDrawerInstance != null) { - var propertyDrawerInstance = propertyDrawerToUse ?? - (IPropertyDrawer)Activator.CreateInstance(propertyDrawerTypeToUse); // Assign the inspector update delegate so any property drawer can trigger an inspector update if it needs it propertyDrawerInstance.inspectorUpdateDelegate = propertyChangeCallback; // Supply any required data to this particular kind of property drawer inspectable.SupplyDataToPropertyDrawer(propertyDrawerInstance, propertyChangeCallback); var propertyGUI = propertyDrawerInstance.DrawProperty(propertyInfo, dataObject, attribute); outputVisualElement.Add(propertyGUI); + if (allPropertyDrawerInstances != null) + allPropertyDrawerInstances.Add(propertyDrawerInstance); } } } diff --git a/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/AbstractMaterialNodePropertyDrawer.cs b/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/AbstractMaterialNodePropertyDrawer.cs index fd57efc6d23..38558fe06ff 100644 --- a/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/AbstractMaterialNodePropertyDrawer.cs +++ b/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/AbstractMaterialNodePropertyDrawer.cs @@ -82,5 +82,11 @@ public VisualElement DrawProperty(PropertyInfo propertyInfo, object actualObject attribute, out var propertyVisualElement); } + + internal virtual void DisposePropertyDrawer() + { + } + + void IPropertyDrawer.DisposePropertyDrawer() { DisposePropertyDrawer(); } } } diff --git a/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/BoolPropertyDrawer.cs b/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/BoolPropertyDrawer.cs index 67622f49b43..1988b40d113 100644 --- a/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/BoolPropertyDrawer.cs +++ b/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/BoolPropertyDrawer.cs @@ -51,5 +51,7 @@ public VisualElement DrawProperty( attribute.labelName, out var propertyVisualElement); } + + void IPropertyDrawer.DisposePropertyDrawer() { } } } diff --git a/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/ColorPropertyDrawer.cs b/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/ColorPropertyDrawer.cs index 490ec11ee9e..ffde2e0aa0a 100644 --- a/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/ColorPropertyDrawer.cs +++ b/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/ColorPropertyDrawer.cs @@ -44,5 +44,7 @@ public VisualElement DrawProperty(PropertyInfo propertyInfo, object actualObject attribute.labelName, out var propertyVisualElement); } + + void IPropertyDrawer.DisposePropertyDrawer() { } } } diff --git a/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/CubemapPropertyDrawer.cs b/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/CubemapPropertyDrawer.cs index f3c9d0ea9dc..33d135166b8 100644 --- a/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/CubemapPropertyDrawer.cs +++ b/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/CubemapPropertyDrawer.cs @@ -45,5 +45,7 @@ public VisualElement DrawProperty(PropertyInfo propertyInfo, object actualObject attribute.labelName, out var propertyVisualElement); } + + void IPropertyDrawer.DisposePropertyDrawer() { } } } diff --git a/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/CustomFunctionNodePropertyDrawer.cs b/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/CustomFunctionNodePropertyDrawer.cs index 22cdd5b5643..2aa004fc484 100644 --- a/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/CustomFunctionNodePropertyDrawer.cs +++ b/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/CustomFunctionNodePropertyDrawer.cs @@ -55,5 +55,7 @@ public VisualElement DrawProperty(PropertyInfo propertyInfo, object actualObject attribute, out var propertyVisualElement); } + + void IPropertyDrawer.DisposePropertyDrawer() { } } } diff --git a/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/DropdownPropertyDrawer.cs b/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/DropdownPropertyDrawer.cs index 806229b30e5..363a6cfb7ba 100644 --- a/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/DropdownPropertyDrawer.cs +++ b/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/DropdownPropertyDrawer.cs @@ -45,5 +45,7 @@ public VisualElement DrawProperty(PropertyInfo propertyInfo, object actualObject attribute.labelName, out var textArrayField); } + + void IPropertyDrawer.DisposePropertyDrawer() { } } } diff --git a/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/EnumPropertyDrawer.cs b/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/EnumPropertyDrawer.cs index fdcf7c715a1..5cade065e88 100644 --- a/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/EnumPropertyDrawer.cs +++ b/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/EnumPropertyDrawer.cs @@ -50,5 +50,7 @@ public VisualElement DrawProperty( (Enum)attribute.defaultValue, out var propertyVisualElement); } + + void IPropertyDrawer.DisposePropertyDrawer() { } } } diff --git a/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/FloatPropertyDrawer.cs b/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/FloatPropertyDrawer.cs index f32c86fbb39..1b103f716dd 100644 --- a/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/FloatPropertyDrawer.cs +++ b/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/FloatPropertyDrawer.cs @@ -45,5 +45,7 @@ public VisualElement DrawProperty(PropertyInfo propertyInfo, object actualObject attribute.labelName, out var propertyVisualElement); } + + void IPropertyDrawer.DisposePropertyDrawer() { } } } diff --git a/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/GradientPropertyDrawer.cs b/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/GradientPropertyDrawer.cs index c76497386ce..6225b8a306d 100644 --- a/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/GradientPropertyDrawer.cs +++ b/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/GradientPropertyDrawer.cs @@ -46,5 +46,7 @@ public VisualElement DrawProperty(PropertyInfo propertyInfo, object actualObject attribute.labelName, out var propertyVisualElement); } + + void IPropertyDrawer.DisposePropertyDrawer() { } } } diff --git a/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/GraphDataPropertyDrawer.cs b/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/GraphDataPropertyDrawer.cs index 10dffae3421..29f12b50e11 100644 --- a/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/GraphDataPropertyDrawer.cs +++ b/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/GraphDataPropertyDrawer.cs @@ -206,5 +206,7 @@ public VisualElement DrawProperty(PropertyInfo propertyInfo, object actualObject { return this.CreateGUI((GraphData)actualObject); } + + void IPropertyDrawer.DisposePropertyDrawer() { } } } diff --git a/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/IntegerPropertyDrawer.cs b/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/IntegerPropertyDrawer.cs index fe6159ded8f..20fdc5070cf 100644 --- a/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/IntegerPropertyDrawer.cs +++ b/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/IntegerPropertyDrawer.cs @@ -46,5 +46,7 @@ public VisualElement DrawProperty(PropertyInfo propertyInfo, object actualObject attribute.labelName, out var propertyVisualElement); } + + void IPropertyDrawer.DisposePropertyDrawer() { } } } diff --git a/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/MatrixPropertyDrawer.cs b/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/MatrixPropertyDrawer.cs index 451aa23b5d5..09272f11b8e 100644 --- a/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/MatrixPropertyDrawer.cs +++ b/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/MatrixPropertyDrawer.cs @@ -368,5 +368,7 @@ public VisualElement DrawProperty(PropertyInfo propertyInfo, object actualObject attribute.labelName, out var propertyVisualElement); } + + void IPropertyDrawer.DisposePropertyDrawer() { } } } diff --git a/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/SampleVirtualTextureNodePropertyDrawer.cs b/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/SampleVirtualTextureNodePropertyDrawer.cs index 29769afafd6..8914625c4e9 100644 --- a/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/SampleVirtualTextureNodePropertyDrawer.cs +++ b/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/SampleVirtualTextureNodePropertyDrawer.cs @@ -141,5 +141,7 @@ public VisualElement DrawProperty(PropertyInfo propertyInfo, object actualObject attribute, out var propertyVisualElement); } + + void IPropertyDrawer.DisposePropertyDrawer() { } } } diff --git a/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/SamplerStateNodePropertyDrawer.cs b/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/SamplerStateNodePropertyDrawer.cs index b1a41bf18ff..150bc69d6d8 100644 --- a/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/SamplerStateNodePropertyDrawer.cs +++ b/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/SamplerStateNodePropertyDrawer.cs @@ -7,7 +7,7 @@ namespace UnityEditor.ShaderGraph.Drawing.Inspector.PropertyDrawers { [SGPropertyDrawer(typeof(SamplerStateNode))] - class SamplerStateNodeNodePropertyDrawer : AbstractMaterialNodePropertyDrawer + class SamplerStateNodePropertyDrawer : AbstractMaterialNodePropertyDrawer { internal override void AddCustomNodeProperties(VisualElement parentElement, AbstractMaterialNode nodeBase, Action setNodesAsDirtyCallback, Action updateNodeViewsCallback) { diff --git a/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/ShaderInputPropertyDrawer.cs b/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/ShaderInputPropertyDrawer.cs index 09f14a11953..b66dc59a9c8 100644 --- a/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/ShaderInputPropertyDrawer.cs +++ b/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/ShaderInputPropertyDrawer.cs @@ -159,6 +159,8 @@ public VisualElement DrawProperty( return propertySheet; } + void IPropertyDrawer.DisposePropertyDrawer() { } + void BuildPropertyNameLabel(PropertySheet propertySheet) { string prefix; diff --git a/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/SubGraphOutputNodePropertyDrawer.cs b/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/SubGraphOutputNodePropertyDrawer.cs index adb25c6a3d2..59fca0d195c 100644 --- a/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/SubGraphOutputNodePropertyDrawer.cs +++ b/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/SubGraphOutputNodePropertyDrawer.cs @@ -48,5 +48,7 @@ public VisualElement DrawProperty(PropertyInfo propertyInfo, object actualObject attribute, out var propertyVisualElement); } + + void IPropertyDrawer.DisposePropertyDrawer() { } } } diff --git a/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/TextPropertyDrawer.cs b/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/TextPropertyDrawer.cs index d3a1f941252..3e144cab545 100644 --- a/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/TextPropertyDrawer.cs +++ b/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/TextPropertyDrawer.cs @@ -49,5 +49,7 @@ public VisualElement DrawProperty(PropertyInfo propertyInfo, object actualObject (string)propertyInfo.GetValue(actualObject), attribute.labelName); } + + void IPropertyDrawer.DisposePropertyDrawer() { } } } diff --git a/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/Texture2DArrayPropertyDrawer.cs b/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/Texture2DArrayPropertyDrawer.cs index 75cd5369761..27231b4d54f 100644 --- a/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/Texture2DArrayPropertyDrawer.cs +++ b/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/Texture2DArrayPropertyDrawer.cs @@ -45,5 +45,7 @@ public VisualElement DrawProperty(PropertyInfo propertyInfo, object actualObject attribute.labelName, out var propertyVisualElement); } + + void IPropertyDrawer.DisposePropertyDrawer() { } } } diff --git a/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/Texture2DPropertyDrawer.cs b/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/Texture2DPropertyDrawer.cs index 27c12373e22..4443557c112 100644 --- a/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/Texture2DPropertyDrawer.cs +++ b/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/Texture2DPropertyDrawer.cs @@ -45,5 +45,7 @@ public VisualElement DrawProperty(PropertyInfo propertyInfo, object actualObject attribute.labelName, out var propertyVisualElement); } + + void IPropertyDrawer.DisposePropertyDrawer() { } } } diff --git a/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/Texture3DPropertyDrawer.cs b/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/Texture3DPropertyDrawer.cs index ea2bb0cbb3f..bc72eab5296 100644 --- a/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/Texture3DPropertyDrawer.cs +++ b/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/Texture3DPropertyDrawer.cs @@ -45,5 +45,7 @@ public VisualElement DrawProperty(PropertyInfo propertyInfo, object actualObject attribute.labelName, out var propertyVisualElement); } + + void IPropertyDrawer.DisposePropertyDrawer() { } } } diff --git a/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/ToggleDataPropertyDrawer.cs b/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/ToggleDataPropertyDrawer.cs index fd8a7e2871c..00db2f4da52 100644 --- a/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/ToggleDataPropertyDrawer.cs +++ b/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/ToggleDataPropertyDrawer.cs @@ -52,5 +52,7 @@ public VisualElement DrawProperty( attribute.labelName, out var propertyVisualElement); } + + void IPropertyDrawer.DisposePropertyDrawer() { } } } diff --git a/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/Vector2PropertyDrawer.cs b/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/Vector2PropertyDrawer.cs index 2e2b19094d7..88245df4b39 100644 --- a/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/Vector2PropertyDrawer.cs +++ b/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/Vector2PropertyDrawer.cs @@ -100,5 +100,7 @@ public VisualElement DrawProperty(PropertyInfo propertyInfo, object actualObject attribute.labelName, out var propertyVisualElement); } + + void IPropertyDrawer.DisposePropertyDrawer() { } } } diff --git a/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/Vector3PropertyDrawer.cs b/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/Vector3PropertyDrawer.cs index e13b5509f8d..660a3933a56 100644 --- a/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/Vector3PropertyDrawer.cs +++ b/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/Vector3PropertyDrawer.cs @@ -101,5 +101,7 @@ public VisualElement DrawProperty(PropertyInfo propertyInfo, object actualObject attribute.labelName, out var propertyVisualElement); } + + void IPropertyDrawer.DisposePropertyDrawer() { } } } diff --git a/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/Vector4PropertyDrawer.cs b/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/Vector4PropertyDrawer.cs index 480785967b0..fc589eac6fe 100644 --- a/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/Vector4PropertyDrawer.cs +++ b/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/Vector4PropertyDrawer.cs @@ -100,5 +100,7 @@ public VisualElement DrawProperty(PropertyInfo propertyInfo, object actualObject attribute.labelName, out var propertyVisualElement); } + + void IPropertyDrawer.DisposePropertyDrawer() { } } } From fef610ea7e442d4237c4532fb7a1c0a451671f54 Mon Sep 17 00:00:00 2001 From: Chris Tchou Date: Wed, 22 Sep 2021 12:19:54 -0700 Subject: [PATCH 02/23] New space transform shared utility --- .../Editor/Data/Util/SpaceTransformUtil.cs | 241 ++++++++++++++++++ .../Data/Util/SpaceTransformUtil.cs.meta | 11 + 2 files changed, 252 insertions(+) create mode 100644 com.unity.shadergraph/Editor/Data/Util/SpaceTransformUtil.cs create mode 100644 com.unity.shadergraph/Editor/Data/Util/SpaceTransformUtil.cs.meta diff --git a/com.unity.shadergraph/Editor/Data/Util/SpaceTransformUtil.cs b/com.unity.shadergraph/Editor/Data/Util/SpaceTransformUtil.cs new file mode 100644 index 00000000000..5342af82568 --- /dev/null +++ b/com.unity.shadergraph/Editor/Data/Util/SpaceTransformUtil.cs @@ -0,0 +1,241 @@ +// using System; +using UnityEditor.ShaderGraph.Internal; + +namespace UnityEditor.ShaderGraph +{ + static class SpaceTransformUtil + { + public const int kLatestVersion = 1; + + public struct SpaceTransform + { + public CoordinateSpace from; + public CoordinateSpace to; + public ConversionType type; + // public bool normalize; + }; + + delegate void TransformFunction(SpaceTransform xform, string inputValue, string outputVariable, ShaderStringBuilder sb, int version = kLatestVersion); + + public static string GenerateTangentTransform(ShaderStringBuilder sb, CoordinateSpace tangentTransformSpace) + { + sb.AppendLine("$precision3x3 tangentTransform = $precision3x3(IN.", tangentTransformSpace, "SpaceTangent, IN.", tangentTransformSpace, "SpaceBiTangent, IN.", tangentTransformSpace, "SpaceNormal);"); + return "tangentTransform"; + } + + public static string GenerateTransposeTangentTransform(ShaderStringBuilder sb, CoordinateSpace tangentTransformSpace = CoordinateSpace.World) + { + var tangentTransform = GenerateTangentTransform(sb, tangentTransformSpace); + sb.AppendLine("$precision3x3 transposeTangentTransform = transpose(tangentTransform);"); + return "transposeTangentTransform"; + } + + public static void Identity(SpaceTransform xform, string inputValue, string outputVariable, ShaderStringBuilder sb, int version = kLatestVersion) + { + // if (xform.normalize && (xform.type != ConversionType.Position)) + // sb.AppendLine(outputVariable, " = SafeNormalize(", inputValue, ");"); + // else + sb.AppendLine(outputVariable, " = ", inputValue, ";"); + } + + private static void ViaWorld(SpaceTransform xform, string inputValue, string outputVariable, ShaderStringBuilder sb, int version = kLatestVersion) + { + // should never be calling this if one of the spaces is already world space (silly, and could lead to infinite recursions) + if ((xform.from == CoordinateSpace.World) || (xform.to == CoordinateSpace.World)) + return; + + // this breaks the transform into two parts: (from->world) and (world->to) + var fromToWorld = new SpaceTransform() + { + from = xform.from, + to = CoordinateSpace.World, + type = xform.type + }; + + var worldToTo = new SpaceTransform() + { + from = CoordinateSpace.World, + to = xform.to, + type = xform.type + }; + + using (sb.BlockScope()) + { + sb.AppendLine("// Converting ", xform.from, " to ", xform.to, " via world space"); + sb.AppendLine("float3 world;"); + GenerateTransformCodeStatement(fromToWorld, inputValue, "world", sb, version); + GenerateTransformCodeStatement(worldToTo, "world", outputVariable, sb, version); + } + } + + public static void WorldToObject(SpaceTransform xform, string inputValue, string outputVariable, ShaderStringBuilder sb, int version = kLatestVersion) + { + switch (xform.type) + { + case ConversionType.Position: + sb.AppendLine(outputVariable, " = TransformWorldToObject(", inputValue, ");"); + break; + case ConversionType.Direction: + // float3 TransformWorldToObjectDir(float3 dirWS, bool doNormalize = true) + sb.AppendLine(outputVariable, " = TransformWorldToObjectDir(", inputValue, ");"); + break; + } + } + + public static void WorldToTangent(SpaceTransform xform, string inputValue, string outputVariable, ShaderStringBuilder sb, int version = kLatestVersion) + { + using (sb.BlockScope()) + { + string tangentTransform = GenerateTangentTransform(sb, xform.from); + // TransformWorldToTangent ALWAYS normalizes + sb.AppendLine(outputVariable, " = TransformWorldToTangent(", inputValue, ", ", tangentTransform, ")"); + // NOTE ^ this is a direction transform ONLY... but probably have to version it to make it transform position correctly.. + } + } + + public static void WorldToView(SpaceTransform xform, string inputValue, string outputVariable, ShaderStringBuilder sb, int version = kLatestVersion) + { + switch (xform.type) + { + case ConversionType.Position: + sb.AppendLine(outputVariable, " = TransformWorldToView(", inputValue, ");"); + break; + case ConversionType.Direction: + // real3 TransformWorldToViewDir(real3 dirWS, bool doNormalize = false) + sb.AppendLine(outputVariable, " = TransformWorldToViewDir(", inputValue, ");"); + break; + } + } + + public static void WorldToAbsoluteWorld(SpaceTransform xform, string inputValue, string outputVariable, ShaderStringBuilder sb, int version = kLatestVersion) + { + switch (xform.type) + { + case ConversionType.Position: + sb.AppendLine(outputVariable, " = GetAbsolutePositionWS(", inputValue, ");"); + break; + case ConversionType.Direction: // BEHAVIOR CHANGE -- VERSION NEEDED? + // both normal and direction are unchanged + sb.AppendLine(outputVariable, " = ", inputValue, ";"); + break; + } + } + + public static void ObjectToWorld(SpaceTransform xform, string inputValue, string outputVariable, ShaderStringBuilder sb, int version = kLatestVersion) + { + switch (xform.type) + { + case ConversionType.Position: + sb.AppendLine(outputVariable, " = TransformObjectToWorld(", inputValue, ");"); + break; + case ConversionType.Direction: + // float3 TransformObjectToWorldDir(float3 dirOS, bool doNormalize = true) + sb.AppendLine(outputVariable, " = TransformObjectToWorldDir(", inputValue, ");"); + break; + } + } + + public static void ObjectToAbsoluteWorld(SpaceTransform xform, string inputValue, string outputVariable, ShaderStringBuilder sb, int version = kLatestVersion) + { + switch (xform.type) + { + case ConversionType.Position: + ViaWorld(xform, inputValue, outputVariable, sb, version); + break; + case ConversionType.Direction: + // float3 TransformObjectToWorldDir(float3 dirOS, bool doNormalize = true) + sb.AppendLine(outputVariable, " = TransformObjectToWorldDir(", inputValue, ");"); + break; + } + } + + public static void TangentToWorld(SpaceTransform xform, string inputValue, string outputVariable, ShaderStringBuilder sb, int version = kLatestVersion) + { + using (sb.BlockScope()) + { + string transposeTangentTransform = GenerateTransposeTangentTransform(sb, xform.from); + switch (xform.type) + { + case ConversionType.Position: + sb.AppendLine(outputVariable, " = mul(", transposeTangentTransform, ", ", inputValue, ").xyz;"); + break; + case ConversionType.Direction: + sb.AppendLine(outputVariable, " = normalize(mul(", transposeTangentTransform, ", ", inputValue, ").xyz);"); + break; + } + } + } + + public static void ViewToWorld(SpaceTransform xform, string inputValue, string outputVariable, ShaderStringBuilder sb, int version = kLatestVersion) + { + switch (xform.type) + { + case ConversionType.Position: + sb.AppendLine(outputVariable, " = mul(UNITY_MATRIX_I_V, $precision4(", inputValue, ", 1)).xyz;"); + break; + case ConversionType.Direction: + sb.AppendLine(outputVariable, " = mul(UNITY_MATRIX_I_V, $precision4(", inputValue, ", 0)).xyz;"); + break; + } + } + + public static void AbsoluteWorldToWorld(SpaceTransform xform, string inputValue, string outputVariable, ShaderStringBuilder sb, int version = kLatestVersion) + { + switch (xform.type) + { + case ConversionType.Position: + sb.AppendLine(outputVariable, " = GetCameraRelativePositionWS(", inputValue, ");"); + break; + case ConversionType.Direction: // BEHAVIOR CHANGE -- VERSION NEEDED? + // both normal and direction are unchanged + sb.AppendLine(outputVariable, " = ", inputValue, ";"); + break; + } + } + + static readonly TransformFunction[,] k_TransformFunctions = new TransformFunction[5, 5] // [from, to] + { + { // from CoordinateSpace.Object + Identity, // to CoordinateSpace.Object + ViaWorld, // to CoordinateSpace.View + ObjectToWorld, // to CoordinateSpace.World + ViaWorld, // to CoordinateSpace.Tangent + ObjectToAbsoluteWorld, // to CoordinateSpace.AbsoluteWorld + }, + { // from CoordinateSpace.View + ViaWorld, // to CoordinateSpace.Object + Identity, // to CoordinateSpace.View + ViewToWorld, // to CoordinateSpace.World + ViaWorld, // to CoordinateSpace.Tangent + ViaWorld, // to CoordinateSpace.AbsoluteWorld + }, + { // from CoordinateSpace.World + WorldToObject, // to CoordinateSpace.Object + WorldToView, // to CoordinateSpace.View + Identity, // to CoordinateSpace.World + WorldToTangent, // to CoordinateSpace.Tangent + WorldToAbsoluteWorld, // to CoordinateSpace.AbsoluteWorld + }, + { // from CoordinateSpace.Tangent + ViaWorld, // to CoordinateSpace.Object + ViaWorld, // to CoordinateSpace.View + TangentToWorld, // to CoordinateSpace.World + Identity, // to CoordinateSpace.Tangent + ViaWorld, // to CoordinateSpace.AbsoluteWorld + }, + { // from CoordinateSpace.AbsoluteWorld + ViaWorld, // to CoordinateSpace.Object + ViaWorld, // to CoordinateSpace.View + AbsoluteWorldToWorld, // to CoordinateSpace.World + ViaWorld, // to CoordinateSpace.Tangent + Identity, // to CoordinateSpace.AbsoluteWorld + } + }; + + public static void GenerateTransformCodeStatement(SpaceTransform xform, string inputValue, string outputVariable, ShaderStringBuilder sb, int version = kLatestVersion) + { + var func = k_TransformFunctions[(int)xform.from, (int)xform.to]; + func(xform, inputValue, outputVariable, sb, version); + } + } +} diff --git a/com.unity.shadergraph/Editor/Data/Util/SpaceTransformUtil.cs.meta b/com.unity.shadergraph/Editor/Data/Util/SpaceTransformUtil.cs.meta new file mode 100644 index 00000000000..0da66c60117 --- /dev/null +++ b/com.unity.shadergraph/Editor/Data/Util/SpaceTransformUtil.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: cd2b12a40ed6b7d40bb34740b5b6728a +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: From d66b0c8156588488b4128f15a7a867e50c568e8c Mon Sep 17 00:00:00 2001 From: Chris Tchou Date: Wed, 22 Sep 2021 12:20:26 -0700 Subject: [PATCH 03/23] Adding ShaderStringBuilder helper functions --- .../Editor/Generation/Processors/ShaderStringBuilder.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/com.unity.shadergraph/Editor/Generation/Processors/ShaderStringBuilder.cs b/com.unity.shadergraph/Editor/Generation/Processors/ShaderStringBuilder.cs index b0e5dadce02..81b5a2ae6d0 100644 --- a/com.unity.shadergraph/Editor/Generation/Processors/ShaderStringBuilder.cs +++ b/com.unity.shadergraph/Editor/Generation/Processors/ShaderStringBuilder.cs @@ -89,6 +89,13 @@ public void AppendLine(string value) AppendNewLine(); } + public void AppendLine(string v0, string v1) { TryAppendIndentation(); Append(v0); Append(v1); AppendNewLine(); } + public void AppendLine(string v0, string v1, string v2) { TryAppendIndentation(); Append(v0); Append(v1); Append(v2); AppendNewLine(); } + public void AppendLine(string v0, string v1, string v2, string v3) { TryAppendIndentation(); Append(v0); Append(v1); Append(v2); Append(v3); AppendNewLine(); } + public void AppendLine(string v0, string v1, string v2, string v3, string v4) { TryAppendIndentation(); Append(v0); Append(v1); Append(v2); Append(v3); Append(v4); AppendNewLine(); } + public void AppendLine(string v0, string v1, string v2, string v3, string v4, string v5) { TryAppendIndentation(); Append(v0); Append(v1); Append(v2); Append(v3); Append(v4); Append(v5); AppendNewLine(); } + public void AppendLine(string v0, string v1, string v2, string v3, string v4, string v5, string v6) { TryAppendIndentation(); Append(v0); Append(v1); Append(v2); Append(v3); Append(v4); Append(v5); Append(v6); AppendNewLine(); } + [StringFormatMethod("formatString")] public void AppendLine(string formatString, params object[] args) { From b5093dc590b36f6e00683d27a698766f4a8e252e Mon Sep 17 00:00:00 2001 From: Chris Tchou Date: Thu, 23 Sep 2021 11:28:46 -0700 Subject: [PATCH 04/23] Update Transform Node to use the shared Util, control normalize, use new v2 behavior --- .../ShaderLibrary/SpaceTransforms.hlsl | 8 +- .../Data/Nodes/Math/Vector/TransformNode.cs | 195 +++----------- .../Nodes/Math/Vector/TransformNode.cs.meta | 3 +- .../Editor/Data/Util/SpaceTransformUtil.cs | 238 +++++++++++++----- .../TransformNodePropertyDrawer.cs | 61 +++++ .../TransformNodePropertyDrawer.cs.meta | 11 + .../Processors/ShaderStringBuilder.cs | 14 +- 7 files changed, 297 insertions(+), 233 deletions(-) create mode 100644 com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/TransformNodePropertyDrawer.cs create mode 100644 com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/TransformNodePropertyDrawer.cs.meta diff --git a/com.unity.render-pipelines.core/ShaderLibrary/SpaceTransforms.hlsl b/com.unity.render-pipelines.core/ShaderLibrary/SpaceTransforms.hlsl index 101ab023c97..1b79eb6eac5 100644 --- a/com.unity.render-pipelines.core/ShaderLibrary/SpaceTransforms.hlsl +++ b/com.unity.render-pipelines.core/ShaderLibrary/SpaceTransforms.hlsl @@ -209,7 +209,7 @@ real3 TransformTangentToWorld(real3 dirTS, real3x3 tangentToWorld) // This function does the exact inverse of TransformTangentToWorld() and is // also decribed within comments in mikktspace.h and it follows implicitly // from the scalar triple product (google it). -real3 TransformWorldToTangent(real3 dirWS, real3x3 tangentToWorld) +real3 TransformWorldToTangent(real3 dirWS, real3x3 tangentToWorld, bool doNormalize = true) { // Note matrix is in row major convention with left multiplication as it is build on the fly float3 row0 = tangentToWorld[0]; @@ -228,8 +228,10 @@ real3 TransformWorldToTangent(real3 dirWS, real3x3 tangentToWorld) // Will remove transpose part by using matrix as the first arg in the mul() below // this makes it the exact inverse of what TransformTangentToWorld() does. real3x3 matTBN_I_T = real3x3(col0, col1, col2); - - return SafeNormalize( sgn * mul(matTBN_I_T, dirWS) ); + real3 result = sgn * mul(matTBN_I_T, dirWS); + if (doNormalize) + return SafeNormalize(result); + return result; } real3 TransformTangentToObject(real3 dirTS, real3x3 tangentToWorld) diff --git a/com.unity.shadergraph/Editor/Data/Nodes/Math/Vector/TransformNode.cs b/com.unity.shadergraph/Editor/Data/Nodes/Math/Vector/TransformNode.cs index f038fc041b2..146728c294a 100644 --- a/com.unity.shadergraph/Editor/Data/Nodes/Math/Vector/TransformNode.cs +++ b/com.unity.shadergraph/Editor/Data/Nodes/Math/Vector/TransformNode.cs @@ -38,9 +38,9 @@ Enum IEnumConversion.to } [Title("Math", "Vector", "Transform")] - class TransformNode : AbstractMaterialNode, IGeneratesBodyCode, IMayRequireTangent, IMayRequireBitangent, IMayRequireNormal, IMayRequireTransform + class TransformNode : AbstractMaterialNode, IGeneratesBodyCode, IMayRequireTangent, IMayRequireBitangent, IMayRequireNormal, IMayRequireTransform, IMayRequirePosition { - public override int latestVersion => 1; + public override int latestVersion => 2; private const int InputSlotId = 0; private const int OutputSlotId = 1; @@ -86,6 +86,20 @@ public ConversionType conversionType } } + [SerializeField] + bool m_Normalize = false; + public bool normalize + { + get { return m_Normalize; } + set + { + if (Equals(m_Normalize, value)) + return; + m_Normalize = value; + Dirty(ModificationScope.Graph); + } + } + public override bool hasPreview { get { return true; } @@ -101,165 +115,16 @@ public sealed override void UpdateNodeAfterDeserialization() public void GenerateNodeCode(ShaderStringBuilder sb, GenerationMode generationMode) { NodeUtils.SlotConfigurationExceptionIfBadConfiguration(this, new[] { InputSlotId }, new[] { OutputSlotId }); - string inputValue = string.Format("{0}.xyz", GetSlotValue(InputSlotId, generationMode)); - string targetTransformString = GetVariableNameForNode() + "_tangentTransform_" + conversion.from.ToString(); - string transposeTargetTransformString = GetVariableNameForNode() + "_transposeTangent"; - string transformString = ""; - string tangentTransformSpace = conversion.from.ToString(); - bool requiresTangentTransform = false; - bool requiresTransposeTangentTransform = false; - if (conversion.from == CoordinateSpace.World) - { - if (conversion.to == CoordinateSpace.World) - { - transformString = inputValue; - } - else if (conversion.to == CoordinateSpace.Object) - { - transformString = string.Format(conversionType == ConversionType.Direction ? "TransformWorldToObjectDir({0})" : "TransformWorldToObject({0})", inputValue); - } - else if (conversion.to == CoordinateSpace.Tangent) - { - requiresTangentTransform = true; - transformString = string.Format("TransformWorldToTangent({0}, {1})", inputValue, targetTransformString); - } - else if (conversion.to == CoordinateSpace.View) - { - transformString = string.Format(conversionType == ConversionType.Direction ? "TransformWorldToViewDir({0})" : "TransformWorldToView({0})", inputValue); - } - else if (conversion.to == CoordinateSpace.AbsoluteWorld) - { - transformString = string.Format("GetAbsolutePositionWS({0})", inputValue); - } - } - else if (conversion.from == CoordinateSpace.Object) - { - if (conversion.to == CoordinateSpace.World) - { - transformString = string.Format(conversionType == ConversionType.Direction ? "TransformObjectToWorldDir({0})" : "TransformObjectToWorld({0})", inputValue); - } - else if (conversion.to == CoordinateSpace.Object) - { - transformString = inputValue; - } - else if (conversion.to == CoordinateSpace.Tangent) - { - requiresTangentTransform = true; - tangentTransformSpace = CoordinateSpace.World.ToString(); - transformString = string.Format(conversionType == ConversionType.Direction ? "TransformWorldToTangent(TransformObjectToWorldDir({0}), {1})" : "TransformWorldToTangent(TransformObjectToWorld({0}), {1})", inputValue, targetTransformString); - } - else if (conversion.to == CoordinateSpace.View) - { - transformString = string.Format(conversionType == ConversionType.Direction ? "TransformWorldToViewDir(TransformObjectToWorldDir({0}))" : "TransformWorldToView(TransformObjectToWorld({0}))", inputValue); - } - if (conversion.to == CoordinateSpace.AbsoluteWorld) - { - transformString = string.Format(conversionType == ConversionType.Direction ? "TransformObjectToWorldDir({0})" : "GetAbsolutePositionWS(TransformObjectToWorld({0}))", inputValue); - } - } - else if (conversion.from == CoordinateSpace.Tangent) - { - if (conversion.to == CoordinateSpace.World) - { - requiresTransposeTangentTransform = true; - transformString = string.Format(conversionType == ConversionType.Direction ? "normalize(mul({0}, {1}).xyz)" : "mul({0}, {1}).xyz", transposeTargetTransformString, inputValue); - } - else if (conversion.to == CoordinateSpace.Object) - { - requiresTransposeTangentTransform = true; - transformString = string.Format(conversionType == ConversionType.Direction ? "TransformWorldToObjectDir(mul({0}, {1}).xyz)" : "TransformWorldToObject(mul({0}, {1}).xyz)", transposeTargetTransformString, inputValue); - } - else if (conversion.to == CoordinateSpace.Tangent) - { - transformString = inputValue; - } - else if (conversion.to == CoordinateSpace.View) - { - requiresTransposeTangentTransform = true; - transformString = string.Format(conversionType == ConversionType.Direction ? "TransformWorldToViewDir(mul({0}, {1}).xyz)" : "TransformWorldToView(mul({0}, {1}).xyz)", transposeTargetTransformString, inputValue); - } - if (conversion.to == CoordinateSpace.AbsoluteWorld) - { - requiresTransposeTangentTransform = true; - transformString = string.Format("GetAbsolutePositionWS(mul({0}, {1})).xyz", transposeTargetTransformString, inputValue); - } - } - else if (conversion.from == CoordinateSpace.View) - { - if (conversion.to == CoordinateSpace.World) - { - transformString = string.Format(conversionType == ConversionType.Direction ? - "mul(UNITY_MATRIX_I_V, $precision4({0}, 0)).xyz" : - "mul(UNITY_MATRIX_I_V, $precision4({0}, 1)).xyz", inputValue); - } - else if (conversion.to == CoordinateSpace.Object) - { - transformString = string.Format(conversionType == ConversionType.Direction ? - "TransformWorldToObjectDir(mul((float3x3)UNITY_MATRIX_I_V, {0}))" : - "TransformWorldToObject(mul(UNITY_MATRIX_I_V, $precision4({0}, 1) ).xyz)", inputValue); - } - else if (conversion.to == CoordinateSpace.Tangent) - { - requiresTangentTransform = true; - tangentTransformSpace = CoordinateSpace.World.ToString(); - transformString = string.Format("TransformWorldToTangent(mul(UNITY_MATRIX_I_V, $precision4({0}, 1) ).xyz, {1})", inputValue, targetTransformString); - } - else if (conversion.to == CoordinateSpace.View) - { - transformString = inputValue; - } - else if (conversion.to == CoordinateSpace.AbsoluteWorld) - { - transformString = string.Format("GetAbsolutePositionWS(mul(UNITY_MATRIX_I_V, $precision4({0}, 1))).xyz", inputValue); - } - } - else if (conversion.from == CoordinateSpace.AbsoluteWorld) - { - if (conversion.to == CoordinateSpace.World) - { - transformString = string.Format("GetCameraRelativePositionWS({0})", inputValue); - } - else if (conversion.to == CoordinateSpace.Object) - { - if (m_SGVersion == 0) - { - transformString = string.Format(conversionType == ConversionType.Direction ? "TransformWorldToObjectDir(GetCameraRelativePositionWS({0}))" : "TransformWorldToObject(GetCameraRelativePositionWS({0}))", inputValue); - } - else - { - transformString = string.Format(conversionType == ConversionType.Direction ? "TransformWorldToObjectDir({0})" : "TransformWorldToObject(GetCameraRelativePositionWS({0}))", inputValue); - } - } - else if (conversion.to == CoordinateSpace.Tangent) - { - requiresTangentTransform = true; - tangentTransformSpace = CoordinateSpace.World.ToString(); - transformString = string.Format("TransformWorldToTangent(GetCameraRelativePositionWS({0}), {1})", inputValue, targetTransformString); - } - else if (conversion.to == CoordinateSpace.View) - { - if (m_SGVersion == 0) - { - transformString = string.Format(conversionType == ConversionType.Direction ? "TransformWorldToViewDir(GetCameraRelativePositionWS({0}))" : "TransformWorldToView(GetCameraRelativePositionWS({0}))", inputValue); - } - else - { - transformString = string.Format(conversionType == ConversionType.Direction ? "TransformWorldToViewDir({0})" : "TransformWorldToView(GetCameraRelativePositionWS({0}))", inputValue); - } - } - else if (conversion.to == CoordinateSpace.AbsoluteWorld) - { - transformString = inputValue; - } - } - if (requiresTransposeTangentTransform) - sb.AppendLine(string.Format("$precision3x3 {0} = transpose($precision3x3(IN.{1}SpaceTangent, IN.{1}SpaceBiTangent, IN.{1}SpaceNormal));", transposeTargetTransformString, CoordinateSpace.World.ToString())); - else if (requiresTangentTransform) - sb.AppendLine(string.Format("$precision3x3 {0} = $precision3x3(IN.{1}SpaceTangent, IN.{1}SpaceBiTangent, IN.{1}SpaceNormal);", targetTransformString, tangentTransformSpace)); - sb.AppendLine("{0} {1} = {2};", FindOutputSlot(OutputSlotId).concreteValueType.ToShaderString(), - GetVariableNameForSlot(OutputSlotId), - transformString); + var xform = new SpaceTransform(conversion.from, conversion.to, conversionType, normalize, sgVersion); + + string inputValue = $"{GetSlotValue(InputSlotId, generationMode)}.xyz"; + string outputVariable = GetVariableNameForSlot(OutputSlotId); + string outputType = FindOutputSlot(OutputSlotId).concreteValueType.ToShaderString(); + + // declare output variable and fill it out + sb.AddLine(outputType, " ", outputVariable, ";"); + SpaceTransformUtil.GenerateTransformCodeStatement(xform, inputValue, outputVariable, sb); } bool RequiresWorldSpaceTangentTransform() @@ -301,5 +166,15 @@ public NeededTransform[] RequiresTransform(ShaderStageCapability stageCapability new NeededTransform(conversion.from.ToNeededCoordinateSpace(), conversion.to.ToNeededCoordinateSpace()) }; } + + NeededCoordinateSpace IMayRequirePosition.RequiresPosition(ShaderStageCapability stageCapability) + { + // tangent space transforms need world position + if (sgVersion > 1) + if ((conversion.from == CoordinateSpace.Tangent) || (conversion.to == CoordinateSpace.Tangent)) + return NeededCoordinateSpace.World; + + return NeededCoordinateSpace.None; + } } } diff --git a/com.unity.shadergraph/Editor/Data/Nodes/Math/Vector/TransformNode.cs.meta b/com.unity.shadergraph/Editor/Data/Nodes/Math/Vector/TransformNode.cs.meta index 8871e2dbdb5..77767a717e4 100644 --- a/com.unity.shadergraph/Editor/Data/Nodes/Math/Vector/TransformNode.cs.meta +++ b/com.unity.shadergraph/Editor/Data/Nodes/Math/Vector/TransformNode.cs.meta @@ -1,8 +1,7 @@ fileFormatVersion: 2 guid: 1d252394349e74b278276a6e0857635e -timeCreated: 1490745697 -licenseType: Pro MonoImporter: + externalObjects: {} serializedVersion: 2 defaultReferences: [] executionOrder: 0 diff --git a/com.unity.shadergraph/Editor/Data/Util/SpaceTransformUtil.cs b/com.unity.shadergraph/Editor/Data/Util/SpaceTransformUtil.cs index 5342af82568..643cd36dceb 100644 --- a/com.unity.shadergraph/Editor/Data/Util/SpaceTransformUtil.cs +++ b/com.unity.shadergraph/Editor/Data/Util/SpaceTransformUtil.cs @@ -3,192 +3,306 @@ namespace UnityEditor.ShaderGraph { - static class SpaceTransformUtil + internal struct SpaceTransform { - public const int kLatestVersion = 1; + public CoordinateSpace from; + public CoordinateSpace to; + public ConversionType type; + public bool normalize; + public int version; + + public const int kLatestVersion = 2; - public struct SpaceTransform + public SpaceTransform(CoordinateSpace from, CoordinateSpace to, ConversionType type, bool normalize = false, int version = kLatestVersion) { - public CoordinateSpace from; - public CoordinateSpace to; - public ConversionType type; - // public bool normalize; - }; + this.from = from; + this.to = to; + this.type = type; + this.normalize = normalize; + this.version = version; + } - delegate void TransformFunction(SpaceTransform xform, string inputValue, string outputVariable, ShaderStringBuilder sb, int version = kLatestVersion); + internal string NormalizeString() + { + return normalize ? "true" : "false"; + } + }; + + static class SpaceTransformUtil + { + delegate void TransformFunction(SpaceTransform xform, string inputValue, string outputVariable, ShaderStringBuilder sb); public static string GenerateTangentTransform(ShaderStringBuilder sb, CoordinateSpace tangentTransformSpace) { - sb.AppendLine("$precision3x3 tangentTransform = $precision3x3(IN.", tangentTransformSpace, "SpaceTangent, IN.", tangentTransformSpace, "SpaceBiTangent, IN.", tangentTransformSpace, "SpaceNormal);"); + sb.AddLine("$precision3x3 tangentTransform = $precision3x3(IN.", + tangentTransformSpace.ToString(), "SpaceTangent, IN.", + tangentTransformSpace.ToString(), "SpaceBiTangent, IN.", + tangentTransformSpace.ToString(), "SpaceNormal);"); return "tangentTransform"; } public static string GenerateTransposeTangentTransform(ShaderStringBuilder sb, CoordinateSpace tangentTransformSpace = CoordinateSpace.World) { var tangentTransform = GenerateTangentTransform(sb, tangentTransformSpace); - sb.AppendLine("$precision3x3 transposeTangentTransform = transpose(tangentTransform);"); + sb.AddLine("$precision3x3 transposeTangentTransform = transpose(tangentTransform);"); return "transposeTangentTransform"; } - public static void Identity(SpaceTransform xform, string inputValue, string outputVariable, ShaderStringBuilder sb, int version = kLatestVersion) + public static void Identity(SpaceTransform xform, string inputValue, string outputVariable, ShaderStringBuilder sb) { - // if (xform.normalize && (xform.type != ConversionType.Position)) - // sb.AppendLine(outputVariable, " = SafeNormalize(", inputValue, ");"); - // else - sb.AppendLine(outputVariable, " = ", inputValue, ";"); + // identity didn't normalize before version 2 + if ((xform.version > 1) && xform.normalize && (xform.type != ConversionType.Position)) + sb.AddLine(outputVariable, " = SafeNormalize(", inputValue, ");"); + else + sb.AddLine(outputVariable, " = ", inputValue, ";"); } - private static void ViaWorld(SpaceTransform xform, string inputValue, string outputVariable, ShaderStringBuilder sb, int version = kLatestVersion) + private static void ViaWorld(SpaceTransform xform, string inputValue, string outputVariable, ShaderStringBuilder sb) { // should never be calling this if one of the spaces is already world space (silly, and could lead to infinite recursions) if ((xform.from == CoordinateSpace.World) || (xform.to == CoordinateSpace.World)) return; // this breaks the transform into two parts: (from->world) and (world->to) - var fromToWorld = new SpaceTransform() + var toWorld = new SpaceTransform() { from = xform.from, to = CoordinateSpace.World, - type = xform.type + type = xform.type, + normalize = false, + version = xform.version }; - var worldToTo = new SpaceTransform() + var fromWorld = new SpaceTransform() { from = CoordinateSpace.World, to = xform.to, - type = xform.type + type = xform.type, + normalize = xform.normalize, + version = xform.version }; + // Apply Versioning Hacks to match old (incorrect) versions + if (xform.version <= 1) + { + if (xform.type == ConversionType.Direction) + { + switch (xform.from) + { + case CoordinateSpace.Object: + if (xform.to == CoordinateSpace.Tangent) + { + } + break; + case CoordinateSpace.AbsoluteWorld: + if ((xform.to == CoordinateSpace.Object) || (xform.to == CoordinateSpace.View)) + { + // these transforms were wrong in v0, but correct in v1, so here we + // pretend it is a later version to disable the v1 versioning in the AbsWorldToWorld transform + if (xform.version == 1) + toWorld.version = 2; + } + break; + case CoordinateSpace.View: + if ((xform.to == CoordinateSpace.Tangent) || (xform.to == CoordinateSpace.AbsoluteWorld)) + { + // these transforms erroneously used the position view-to-world transform + toWorld.type = ConversionType.Position; + } + break; + case CoordinateSpace.Tangent: + if ((xform.to == CoordinateSpace.Object) || (xform.to == CoordinateSpace.View) || (xform.to == CoordinateSpace.AbsoluteWorld)) + { + // disable the versioning on toWorld transform to remove normalization + toWorld.version = 2; + } + break; + } + } + else if (xform.type == ConversionType.Position) + { + } + } + using (sb.BlockScope()) { - sb.AppendLine("// Converting ", xform.from, " to ", xform.to, " via world space"); - sb.AppendLine("float3 world;"); - GenerateTransformCodeStatement(fromToWorld, inputValue, "world", sb, version); - GenerateTransformCodeStatement(worldToTo, "world", outputVariable, sb, version); + sb.AddLine("// Converting ", xform.type.ToString(), " from ", xform.from.ToString(), " to ", xform.to.ToString(), " via world space"); + sb.AddLine("float3 world;"); + GenerateTransformCodeStatement(toWorld, inputValue, "world", sb); + GenerateTransformCodeStatement(fromWorld, "world", outputVariable, sb); } } - public static void WorldToObject(SpaceTransform xform, string inputValue, string outputVariable, ShaderStringBuilder sb, int version = kLatestVersion) + public static void WorldToObject(SpaceTransform xform, string inputValue, string outputVariable, ShaderStringBuilder sb) { switch (xform.type) { case ConversionType.Position: - sb.AppendLine(outputVariable, " = TransformWorldToObject(", inputValue, ");"); + sb.AddLine(outputVariable, " = TransformWorldToObject(", inputValue, ");"); break; case ConversionType.Direction: - // float3 TransformWorldToObjectDir(float3 dirWS, bool doNormalize = true) - sb.AppendLine(outputVariable, " = TransformWorldToObjectDir(", inputValue, ");"); + if (xform.version <= 1) + xform.normalize = true; + sb.AddLine(outputVariable, " = TransformWorldToObjectDir(", inputValue, ", ", xform.NormalizeString(), ");"); break; } } - public static void WorldToTangent(SpaceTransform xform, string inputValue, string outputVariable, ShaderStringBuilder sb, int version = kLatestVersion) + public static void WorldToTangent(SpaceTransform xform, string inputValue, string outputVariable, ShaderStringBuilder sb) { + if (xform.version <= 1) + { + // prior to version 2, all transform were normalized, and position transform actually did direction transform + xform.normalize = true; + xform.type = ConversionType.Direction; + } + using (sb.BlockScope()) { string tangentTransform = GenerateTangentTransform(sb, xform.from); - // TransformWorldToTangent ALWAYS normalizes - sb.AppendLine(outputVariable, " = TransformWorldToTangent(", inputValue, ", ", tangentTransform, ")"); - // NOTE ^ this is a direction transform ONLY... but probably have to version it to make it transform position correctly.. + + switch (xform.type) + { + case ConversionType.Position: + sb.AddLine(outputVariable, " = TransformWorldToTangent(", inputValue, " - IN.WorldSpacePosition, ", tangentTransform, ", false);"); + break; + case ConversionType.Direction: + sb.AddLine(outputVariable, " = TransformWorldToTangent(", inputValue, ", ", tangentTransform, ", ", xform.NormalizeString(), ");"); + break; + } } } - public static void WorldToView(SpaceTransform xform, string inputValue, string outputVariable, ShaderStringBuilder sb, int version = kLatestVersion) + public static void WorldToView(SpaceTransform xform, string inputValue, string outputVariable, ShaderStringBuilder sb) { switch (xform.type) { case ConversionType.Position: - sb.AppendLine(outputVariable, " = TransformWorldToView(", inputValue, ");"); + sb.AddLine(outputVariable, " = TransformWorldToView(", inputValue, ");"); break; case ConversionType.Direction: - // real3 TransformWorldToViewDir(real3 dirWS, bool doNormalize = false) - sb.AppendLine(outputVariable, " = TransformWorldToViewDir(", inputValue, ");"); + if (xform.version <= 1) + xform.normalize = false; + sb.AddLine(outputVariable, " = TransformWorldToViewDir(", inputValue, ", ", xform.NormalizeString(), ");"); break; } } - public static void WorldToAbsoluteWorld(SpaceTransform xform, string inputValue, string outputVariable, ShaderStringBuilder sb, int version = kLatestVersion) + public static void WorldToAbsoluteWorld(SpaceTransform xform, string inputValue, string outputVariable, ShaderStringBuilder sb) { + // prior to version 2 always used Position transform + if (xform.version <= 1) + xform.type = ConversionType.Position; + switch (xform.type) { case ConversionType.Position: - sb.AppendLine(outputVariable, " = GetAbsolutePositionWS(", inputValue, ");"); + sb.AddLine(outputVariable, " = GetAbsolutePositionWS(", inputValue, ");"); break; - case ConversionType.Direction: // BEHAVIOR CHANGE -- VERSION NEEDED? + case ConversionType.Direction: // both normal and direction are unchanged - sb.AppendLine(outputVariable, " = ", inputValue, ";"); + if (xform.normalize) + sb.AddLine(outputVariable, " = SafeNormalize(", inputValue, ");"); + else + sb.AddLine(outputVariable, " = ", inputValue, ";"); break; } } - public static void ObjectToWorld(SpaceTransform xform, string inputValue, string outputVariable, ShaderStringBuilder sb, int version = kLatestVersion) + public static void ObjectToWorld(SpaceTransform xform, string inputValue, string outputVariable, ShaderStringBuilder sb) { switch (xform.type) { case ConversionType.Position: - sb.AppendLine(outputVariable, " = TransformObjectToWorld(", inputValue, ");"); + sb.AddLine(outputVariable, " = TransformObjectToWorld(", inputValue, ");"); break; case ConversionType.Direction: - // float3 TransformObjectToWorldDir(float3 dirOS, bool doNormalize = true) - sb.AppendLine(outputVariable, " = TransformObjectToWorldDir(", inputValue, ");"); + if (xform.version <= 1) + xform.normalize = true; + sb.AddLine(outputVariable, " = TransformObjectToWorldDir(", inputValue, ", ", xform.NormalizeString(), ");"); break; } } - public static void ObjectToAbsoluteWorld(SpaceTransform xform, string inputValue, string outputVariable, ShaderStringBuilder sb, int version = kLatestVersion) + public static void ObjectToAbsoluteWorld(SpaceTransform xform, string inputValue, string outputVariable, ShaderStringBuilder sb) { switch (xform.type) { case ConversionType.Position: - ViaWorld(xform, inputValue, outputVariable, sb, version); + ViaWorld(xform, inputValue, outputVariable, sb); break; case ConversionType.Direction: - // float3 TransformObjectToWorldDir(float3 dirOS, bool doNormalize = true) - sb.AppendLine(outputVariable, " = TransformObjectToWorldDir(", inputValue, ");"); + if (xform.version <= 1) + xform.normalize = true; + sb.AddLine(outputVariable, " = TransformObjectToWorldDir(", inputValue, ", ", xform.NormalizeString(), ");"); break; } } - public static void TangentToWorld(SpaceTransform xform, string inputValue, string outputVariable, ShaderStringBuilder sb, int version = kLatestVersion) + public static void TangentToWorld(SpaceTransform xform, string inputValue, string outputVariable, ShaderStringBuilder sb) { + // all tangent to world before version 2 are doing Direction transformations only + if (xform.version <= 1) + { + if (xform.type == ConversionType.Position) + xform.type = ConversionType.Direction; + else + xform.normalize = true; + } + using (sb.BlockScope()) { - string transposeTangentTransform = GenerateTransposeTangentTransform(sb, xform.from); + string transposeTangentTransform = GenerateTransposeTangentTransform(sb, CoordinateSpace.World); switch (xform.type) { case ConversionType.Position: - sb.AppendLine(outputVariable, " = mul(", transposeTangentTransform, ", ", inputValue, ").xyz;"); + sb.AddLine(outputVariable, " = mul(", transposeTangentTransform, ", ", inputValue, ").xyz + IN.WorldSpacePosition;"); break; case ConversionType.Direction: - sb.AppendLine(outputVariable, " = normalize(mul(", transposeTangentTransform, ", ", inputValue, ").xyz);"); + if (xform.normalize) + sb.AddLine(outputVariable, " = SafeNormalize(mul(", transposeTangentTransform, ", ", inputValue, ").xyz);"); + else + sb.AddLine(outputVariable, " = mul(", transposeTangentTransform, ", ", inputValue, ").xyz;"); break; } } } - public static void ViewToWorld(SpaceTransform xform, string inputValue, string outputVariable, ShaderStringBuilder sb, int version = kLatestVersion) + public static void ViewToWorld(SpaceTransform xform, string inputValue, string outputVariable, ShaderStringBuilder sb) { switch (xform.type) { case ConversionType.Position: - sb.AppendLine(outputVariable, " = mul(UNITY_MATRIX_I_V, $precision4(", inputValue, ", 1)).xyz;"); + sb.AddLine(outputVariable, " = mul(UNITY_MATRIX_I_V, $precision4(", inputValue, ", 1)).xyz;"); break; case ConversionType.Direction: - sb.AppendLine(outputVariable, " = mul(UNITY_MATRIX_I_V, $precision4(", inputValue, ", 0)).xyz;"); + if (xform.version <= 1) + xform.normalize = false; + if (xform.normalize) + sb.AddLine(outputVariable, " = SafeNormalize(mul((float3x3) UNITY_MATRIX_I_V, ", inputValue, "));"); + else + sb.AddLine(outputVariable, " = mul((float3x3) UNITY_MATRIX_I_V, ", inputValue, ");"); break; } } - public static void AbsoluteWorldToWorld(SpaceTransform xform, string inputValue, string outputVariable, ShaderStringBuilder sb, int version = kLatestVersion) + public static void AbsoluteWorldToWorld(SpaceTransform xform, string inputValue, string outputVariable, ShaderStringBuilder sb) { + // prior to version 2, always used position transform + if (xform.version <= 1) + xform.type = ConversionType.Position; + switch (xform.type) { case ConversionType.Position: - sb.AppendLine(outputVariable, " = GetCameraRelativePositionWS(", inputValue, ");"); + sb.AddLine(outputVariable, " = GetCameraRelativePositionWS(", inputValue, ");"); break; - case ConversionType.Direction: // BEHAVIOR CHANGE -- VERSION NEEDED? + case ConversionType.Direction: // both normal and direction are unchanged - sb.AppendLine(outputVariable, " = ", inputValue, ";"); + if (xform.normalize) + sb.AddLine(outputVariable, " = SafeNormalize(", inputValue, ");"); + else + sb.AddLine(outputVariable, " = ", inputValue, ";"); break; } } @@ -232,10 +346,10 @@ public static void AbsoluteWorldToWorld(SpaceTransform xform, string inputValue, } }; - public static void GenerateTransformCodeStatement(SpaceTransform xform, string inputValue, string outputVariable, ShaderStringBuilder sb, int version = kLatestVersion) + public static void GenerateTransformCodeStatement(SpaceTransform xform, string inputValue, string outputVariable, ShaderStringBuilder sb) { var func = k_TransformFunctions[(int)xform.from, (int)xform.to]; - func(xform, inputValue, outputVariable, sb, version); + func(xform, inputValue, outputVariable, sb); } } } diff --git a/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/TransformNodePropertyDrawer.cs b/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/TransformNodePropertyDrawer.cs new file mode 100644 index 00000000000..0c18a3948b4 --- /dev/null +++ b/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/TransformNodePropertyDrawer.cs @@ -0,0 +1,61 @@ +using System; +using UnityEditor.UIElements; +using UnityEditor.Graphing; +using UnityEditor.Graphing.Util; +using UnityEngine.UIElements; +using UnityEditor.ShaderGraph.Internal; + +namespace UnityEditor.ShaderGraph.Drawing.Inspector.PropertyDrawers +{ + [SGPropertyDrawer(typeof(TransformNode))] + class TransformNodePropertyDrawer : AbstractMaterialNodePropertyDrawer + { + TransformNode node; + PropertyRow normalizePropRow; + + void UpdateVisibility() + { + normalizePropRow.visible = (node.conversionType != ConversionType.Position); + } + + internal override void AddCustomNodeProperties(VisualElement parentElement, AbstractMaterialNode nodeBase, Action setNodesAsDirtyCallback, Action updateNodeViewsCallback) + { + node = nodeBase as TransformNode; + + var normalizeControl = new Toggle(); + normalizeControl.value = node.normalize; + + normalizePropRow = new PropertyRow(new Label("Normalize Output")); + normalizePropRow.Add(normalizeControl, (field) => + { + field.RegisterValueChangedCallback(evt => + { + if (evt.newValue.Equals(node.normalize)) + return; + + setNodesAsDirtyCallback?.Invoke(); + node.owner.owner.RegisterCompleteObjectUndo("Change normalize"); + node.normalize = evt.newValue; + updateNodeViewsCallback?.Invoke(); + node.Dirty(ModificationScope.Graph); + }); + }); + parentElement.Add(normalizePropRow); + + UpdateVisibility(); + + node.RegisterCallback(OnNodeModified); + } + + // when node is modified we want to update the visibility + void OnNodeModified(AbstractMaterialNode node, ModificationScope scope) + { + UpdateVisibility(); + } + + internal override void DisposePropertyDrawer() + { + node.UnregisterCallback(OnNodeModified); + } + } +} diff --git a/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/TransformNodePropertyDrawer.cs.meta b/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/TransformNodePropertyDrawer.cs.meta new file mode 100644 index 00000000000..edbbe89c5c4 --- /dev/null +++ b/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/TransformNodePropertyDrawer.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 83fc180327d27574e82b361da1ea2d11 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.unity.shadergraph/Editor/Generation/Processors/ShaderStringBuilder.cs b/com.unity.shadergraph/Editor/Generation/Processors/ShaderStringBuilder.cs index 81b5a2ae6d0..8c090de80e1 100644 --- a/com.unity.shadergraph/Editor/Generation/Processors/ShaderStringBuilder.cs +++ b/com.unity.shadergraph/Editor/Generation/Processors/ShaderStringBuilder.cs @@ -89,12 +89,14 @@ public void AppendLine(string value) AppendNewLine(); } - public void AppendLine(string v0, string v1) { TryAppendIndentation(); Append(v0); Append(v1); AppendNewLine(); } - public void AppendLine(string v0, string v1, string v2) { TryAppendIndentation(); Append(v0); Append(v1); Append(v2); AppendNewLine(); } - public void AppendLine(string v0, string v1, string v2, string v3) { TryAppendIndentation(); Append(v0); Append(v1); Append(v2); Append(v3); AppendNewLine(); } - public void AppendLine(string v0, string v1, string v2, string v3, string v4) { TryAppendIndentation(); Append(v0); Append(v1); Append(v2); Append(v3); Append(v4); AppendNewLine(); } - public void AppendLine(string v0, string v1, string v2, string v3, string v4, string v5) { TryAppendIndentation(); Append(v0); Append(v1); Append(v2); Append(v3); Append(v4); Append(v5); AppendNewLine(); } - public void AppendLine(string v0, string v1, string v2, string v3, string v4, string v5, string v6) { TryAppendIndentation(); Append(v0); Append(v1); Append(v2); Append(v3); Append(v4); Append(v5); Append(v6); AppendNewLine(); } + public void AddLine(string v0) { TryAppendIndentation(); Append(v0); AppendNewLine(); } + public void AddLine(string v0, string v1) { TryAppendIndentation(); Append(v0); Append(v1); AppendNewLine(); } + public void AddLine(string v0, string v1, string v2) { TryAppendIndentation(); Append(v0); Append(v1); Append(v2); AppendNewLine(); } + public void AddLine(string v0, string v1, string v2, string v3) { TryAppendIndentation(); Append(v0); Append(v1); Append(v2); Append(v3); AppendNewLine(); } + public void AddLine(string v0, string v1, string v2, string v3, string v4) { TryAppendIndentation(); Append(v0); Append(v1); Append(v2); Append(v3); Append(v4); AppendNewLine(); } + public void AddLine(string v0, string v1, string v2, string v3, string v4, string v5) { TryAppendIndentation(); Append(v0); Append(v1); Append(v2); Append(v3); Append(v4); Append(v5); AppendNewLine(); } + public void AddLine(string v0, string v1, string v2, string v3, string v4, string v5, string v6) { TryAppendIndentation(); Append(v0); Append(v1); Append(v2); Append(v3); Append(v4); Append(v5); Append(v6); AppendNewLine(); } + public void AddLine(string v0, string v1, string v2, string v3, string v4, string v5, string v6, string v7) { TryAppendIndentation(); Append(v0); Append(v1); Append(v2); Append(v3); Append(v4); Append(v5); Append(v6); Append(v7); AppendNewLine(); } [StringFormatMethod("formatString")] public void AppendLine(string formatString, params object[] args) From 48937fe9f01e665e71d73ea94ff919b6969a9afa Mon Sep 17 00:00:00 2001 From: Chris Tchou Date: Thu, 23 Sep 2021 11:57:24 -0700 Subject: [PATCH 05/23] Add directional tangent space transforms --- .../ShaderLibrary/SpaceTransforms.hlsl | 52 +++++++++++++++++-- 1 file changed, 48 insertions(+), 4 deletions(-) diff --git a/com.unity.render-pipelines.core/ShaderLibrary/SpaceTransforms.hlsl b/com.unity.render-pipelines.core/ShaderLibrary/SpaceTransforms.hlsl index 1b79eb6eac5..d74b1371977 100644 --- a/com.unity.render-pipelines.core/ShaderLibrary/SpaceTransforms.hlsl +++ b/com.unity.render-pipelines.core/ShaderLibrary/SpaceTransforms.hlsl @@ -200,16 +200,21 @@ real3x3 CreateTangentToWorld(real3 normal, real3 tangent, real flipSign) return real3x3(tangent, bitangent, normal); } -real3 TransformTangentToWorld(real3 dirTS, real3x3 tangentToWorld) +// this function is intended to work on Normals (handles non-uniform scale) +real3 TransformTangentToWorld(real3 normalTS, real3x3 tangentToWorld, bool doNormalize = false) { // Note matrix is in row major convention with left multiplication as it is build on the fly - return mul(dirTS, tangentToWorld); + real3 result = mul(normalTS, tangentToWorld); + if (doNormalize) + return SafeNormalize(result); + return result; } +// this function is intended to work on Normals (handles non-uniform scale) // This function does the exact inverse of TransformTangentToWorld() and is // also decribed within comments in mikktspace.h and it follows implicitly // from the scalar triple product (google it). -real3 TransformWorldToTangent(real3 dirWS, real3x3 tangentToWorld, bool doNormalize = true) +real3 TransformWorldToTangent(real3 normalWS, real3x3 tangentToWorld, bool doNormalize = true) { // Note matrix is in row major convention with left multiplication as it is build on the fly float3 row0 = tangentToWorld[0]; @@ -228,7 +233,46 @@ real3 TransformWorldToTangent(real3 dirWS, real3x3 tangentToWorld, bool doNormal // Will remove transpose part by using matrix as the first arg in the mul() below // this makes it the exact inverse of what TransformTangentToWorld() does. real3x3 matTBN_I_T = real3x3(col0, col1, col2); - real3 result = sgn * mul(matTBN_I_T, dirWS); + real3 result = sgn * mul(matTBN_I_T, normalWS); + if (doNormalize) + return SafeNormalize(result); + return result; +} + +// this function is intended to work on Vectors/Directions +real3 TransformWorldToTangentDir(real3 dirWS, real3x3 tangentToWorld, bool doNormalize = false) +{ + // Note matrix is in row major convention with left multiplication as it is build on the fly + real3 result = mul(dirWS, transpose(tangentToWorld)); + if (doNormalize) + return SafeNormalize(result); + return result; +} + +// this function is intended to work on Vectors/Directions +// This function does the exact inverse of TransformTangentToWorld() and is +// also decribed within comments in mikktspace.h and it follows implicitly +// from the scalar triple product (google it). +real3 TransformTangentToWorldDir(real3 dirWS, real3x3 tangentToWorld, bool doNormalize = false) +{ + // Note matrix is in row major convention with left multiplication as it is build on the fly + float3 row0 = tangentToWorld[0]; + float3 row1 = tangentToWorld[1]; + float3 row2 = tangentToWorld[2]; + + // these are the columns of the inverse matrix but scaled by the determinant + float3 col0 = cross(row1, row2); + float3 col1 = cross(row2, row0); + float3 col2 = cross(row0, row1); + + float determinant = dot(row0, col0); + float sgn = determinant < 0.0 ? (-1.0) : 1.0; + + // inverse transposed but scaled by determinant + // Will remove transpose part by using matrix as the first arg in the mul() below + // this makes it the exact inverse of what TransformTangentToWorld() does. + real3x3 matTBN_I_T = real3x3(col0, col1, col2); + real3 result = sgn * mul(transpose(matTBN_I_T), dirWS); if (doNormalize) return SafeNormalize(result); return result; From 790944e6ce8c12f622983f34921f27c2c95a3332 Mon Sep 17 00:00:00 2001 From: Chris Tchou Date: Thu, 23 Sep 2021 12:01:26 -0700 Subject: [PATCH 06/23] Fixing comments --- .../ShaderLibrary/SpaceTransforms.hlsl | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/com.unity.render-pipelines.core/ShaderLibrary/SpaceTransforms.hlsl b/com.unity.render-pipelines.core/ShaderLibrary/SpaceTransforms.hlsl index d74b1371977..886650c5bcf 100644 --- a/com.unity.render-pipelines.core/ShaderLibrary/SpaceTransforms.hlsl +++ b/com.unity.render-pipelines.core/ShaderLibrary/SpaceTransforms.hlsl @@ -250,9 +250,7 @@ real3 TransformWorldToTangentDir(real3 dirWS, real3x3 tangentToWorld, bool doNor } // this function is intended to work on Vectors/Directions -// This function does the exact inverse of TransformTangentToWorld() and is -// also decribed within comments in mikktspace.h and it follows implicitly -// from the scalar triple product (google it). +// This function does the exact inverse of TransformWorldToTangentDir() real3 TransformTangentToWorldDir(real3 dirWS, real3x3 tangentToWorld, bool doNormalize = false) { // Note matrix is in row major convention with left multiplication as it is build on the fly From 507ff544402b9c6a1ff444502ff402c3ef881aef Mon Sep 17 00:00:00 2001 From: Chris Tchou Date: Thu, 23 Sep 2021 14:54:08 -0700 Subject: [PATCH 07/23] Adding "Normal" conversion type, fixing WorldToTangent to use the proper transforms --- .../ShaderLibrary/SpaceTransforms.hlsl | 38 ++++++++- .../Data/Nodes/Math/Vector/TransformNode.cs | 6 -- .../Editor/Data/Util/SpaceTransformUtil.cs | 77 +++++++++++-------- .../TransformNodePropertyDrawer.cs | 2 +- 4 files changed, 80 insertions(+), 43 deletions(-) diff --git a/com.unity.render-pipelines.core/ShaderLibrary/SpaceTransforms.hlsl b/com.unity.render-pipelines.core/ShaderLibrary/SpaceTransforms.hlsl index 886650c5bcf..47c008959a9 100644 --- a/com.unity.render-pipelines.core/ShaderLibrary/SpaceTransforms.hlsl +++ b/com.unity.render-pipelines.core/ShaderLibrary/SpaceTransforms.hlsl @@ -33,6 +33,11 @@ float4x4 GetWorldToViewMatrix() return UNITY_MATRIX_V; } +float4x4 GetViewToWorldMatrix() +{ + return UNITY_MATRIX_I_V; +} + // Transform to homogenous clip space float4x4 GetWorldToHClipMatrix() { @@ -94,6 +99,11 @@ float3 TransformWorldToView(float3 positionWS) return mul(GetWorldToViewMatrix(), float4(positionWS, 1.0)).xyz; } +float3 TransformViewToWorld(float3 positionVS) +{ + return mul(GetViewToWorldMatrix(), float4(positionVS, 1.0)).xyz; +} + // Transforms position from object space to homogenous space float4 TransformObjectToHClip(float3 positionOS) { @@ -151,6 +161,30 @@ real3 TransformWorldToViewDir(real3 dirWS, bool doNormalize = false) return dirVS; } +// Tranforms vector from view space to world space +real3 TransformViewToWorldDir(real3 dirVS, bool doNormalize = false) +{ + float3 dirWS = mul((real3x3)GetViewToWorldMatrix(), dirVS).xyz; + if (doNormalize) + return normalize(dirWS); + + return dirWS; +} + +// Tranforms normal from world space to view space +real3 TransformWorldToViewNormal(real3 normalWS, bool doNormalize = false) +{ + // assuming view matrix is not non-uniformly scaled, we can use direction transform + return TransformWorldToViewDir(normalWS, doNormalize); +} + +// Tranforms normal from view space to world space +real3 TransformViewToWorldNormal(real3 normalVS, bool doNormalize = false) +{ + // assuming view matrix is not non-uniformly scaled, we can use direction transform + return TransformViewToWorldDir(normalVS, doNormalize); +} + // Tranforms vector from world space to homogenous space real3 TransformWorldToHClipDir(real3 directionWS, bool doNormalize = false) { @@ -243,7 +277,7 @@ real3 TransformWorldToTangent(real3 normalWS, real3x3 tangentToWorld, bool doNor real3 TransformWorldToTangentDir(real3 dirWS, real3x3 tangentToWorld, bool doNormalize = false) { // Note matrix is in row major convention with left multiplication as it is build on the fly - real3 result = mul(dirWS, transpose(tangentToWorld)); + real3 result = mul(tangentToWorld, dirWS); if (doNormalize) return SafeNormalize(result); return result; @@ -270,7 +304,7 @@ real3 TransformTangentToWorldDir(real3 dirWS, real3x3 tangentToWorld, bool doNor // Will remove transpose part by using matrix as the first arg in the mul() below // this makes it the exact inverse of what TransformTangentToWorld() does. real3x3 matTBN_I_T = real3x3(col0, col1, col2); - real3 result = sgn * mul(transpose(matTBN_I_T), dirWS); + real3 result = sgn * mul(dirWS, matTBN_I_T); if (doNormalize) return SafeNormalize(result); return result; diff --git a/com.unity.shadergraph/Editor/Data/Nodes/Math/Vector/TransformNode.cs b/com.unity.shadergraph/Editor/Data/Nodes/Math/Vector/TransformNode.cs index 146728c294a..15b1fc96e0a 100644 --- a/com.unity.shadergraph/Editor/Data/Nodes/Math/Vector/TransformNode.cs +++ b/com.unity.shadergraph/Editor/Data/Nodes/Math/Vector/TransformNode.cs @@ -6,12 +6,6 @@ namespace UnityEditor.ShaderGraph { - enum ConversionType - { - Position, - Direction - } - [Serializable] struct CoordinateSpaceConversion : IEnumConversion { diff --git a/com.unity.shadergraph/Editor/Data/Util/SpaceTransformUtil.cs b/com.unity.shadergraph/Editor/Data/Util/SpaceTransformUtil.cs index 643cd36dceb..5c146ce7373 100644 --- a/com.unity.shadergraph/Editor/Data/Util/SpaceTransformUtil.cs +++ b/com.unity.shadergraph/Editor/Data/Util/SpaceTransformUtil.cs @@ -3,6 +3,13 @@ namespace UnityEditor.ShaderGraph { + enum ConversionType + { + Position, + Direction, + Normal + } + internal struct SpaceTransform { public CoordinateSpace from; @@ -41,13 +48,6 @@ public static string GenerateTangentTransform(ShaderStringBuilder sb, Coordinate return "tangentTransform"; } - public static string GenerateTransposeTangentTransform(ShaderStringBuilder sb, CoordinateSpace tangentTransformSpace = CoordinateSpace.World) - { - var tangentTransform = GenerateTangentTransform(sb, tangentTransformSpace); - sb.AddLine("$precision3x3 transposeTangentTransform = transpose(tangentTransform);"); - return "transposeTangentTransform"; - } - public static void Identity(SpaceTransform xform, string inputValue, string outputVariable, ShaderStringBuilder sb) { // identity didn't normalize before version 2 @@ -89,11 +89,6 @@ private static void ViaWorld(SpaceTransform xform, string inputValue, string out { switch (xform.from) { - case CoordinateSpace.Object: - if (xform.to == CoordinateSpace.Tangent) - { - } - break; case CoordinateSpace.AbsoluteWorld: if ((xform.to == CoordinateSpace.Object) || (xform.to == CoordinateSpace.View)) { @@ -113,15 +108,13 @@ private static void ViaWorld(SpaceTransform xform, string inputValue, string out case CoordinateSpace.Tangent: if ((xform.to == CoordinateSpace.Object) || (xform.to == CoordinateSpace.View) || (xform.to == CoordinateSpace.AbsoluteWorld)) { - // disable the versioning on toWorld transform to remove normalization + // manually version to 2, to remove normalization (while keeping Normal type) + toWorld.type = ConversionType.Normal; toWorld.version = 2; } break; } } - else if (xform.type == ConversionType.Position) - { - } } using (sb.BlockScope()) @@ -145,6 +138,9 @@ public static void WorldToObject(SpaceTransform xform, string inputValue, string xform.normalize = true; sb.AddLine(outputVariable, " = TransformWorldToObjectDir(", inputValue, ", ", xform.NormalizeString(), ");"); break; + case ConversionType.Normal: + sb.AddLine(outputVariable, " = TransformWorldToObjectNormal(", inputValue, ", ", xform.NormalizeString(), ");"); + break; } } @@ -152,9 +148,9 @@ public static void WorldToTangent(SpaceTransform xform, string inputValue, strin { if (xform.version <= 1) { - // prior to version 2, all transform were normalized, and position transform actually did direction transform + // prior to version 2, all transform were normalized, and all transforms were Normal transforms xform.normalize = true; - xform.type = ConversionType.Direction; + xform.type = ConversionType.Normal; } using (sb.BlockScope()) @@ -164,9 +160,12 @@ public static void WorldToTangent(SpaceTransform xform, string inputValue, strin switch (xform.type) { case ConversionType.Position: - sb.AddLine(outputVariable, " = TransformWorldToTangent(", inputValue, " - IN.WorldSpacePosition, ", tangentTransform, ", false);"); + sb.AddLine(outputVariable, " = TransformWorldToTangentDir(", inputValue, " - IN.WorldSpacePosition, ", tangentTransform, ", false);"); break; case ConversionType.Direction: + sb.AddLine(outputVariable, " = TransformWorldToTangentDir(", inputValue, ", ", tangentTransform, ", ", xform.NormalizeString(), ");"); + break; + case ConversionType.Normal: sb.AddLine(outputVariable, " = TransformWorldToTangent(", inputValue, ", ", tangentTransform, ", ", xform.NormalizeString(), ");"); break; } @@ -185,6 +184,9 @@ public static void WorldToView(SpaceTransform xform, string inputValue, string o xform.normalize = false; sb.AddLine(outputVariable, " = TransformWorldToViewDir(", inputValue, ", ", xform.NormalizeString(), ");"); break; + case ConversionType.Normal: + sb.AddLine(outputVariable, " = TransformWorldToViewNormal(", inputValue, ", ", xform.NormalizeString(), ");"); + break; } } @@ -200,6 +202,7 @@ public static void WorldToAbsoluteWorld(SpaceTransform xform, string inputValue, sb.AddLine(outputVariable, " = GetAbsolutePositionWS(", inputValue, ");"); break; case ConversionType.Direction: + case ConversionType.Normal: // both normal and direction are unchanged if (xform.normalize) sb.AddLine(outputVariable, " = SafeNormalize(", inputValue, ");"); @@ -221,6 +224,9 @@ public static void ObjectToWorld(SpaceTransform xform, string inputValue, string xform.normalize = true; sb.AddLine(outputVariable, " = TransformObjectToWorldDir(", inputValue, ", ", xform.NormalizeString(), ");"); break; + case ConversionType.Normal: + sb.AddLine(outputVariable, " = TransformObjectToWorldNormal(", inputValue, ", ", xform.NormalizeString(), ");"); + break; } } @@ -236,33 +242,35 @@ public static void ObjectToAbsoluteWorld(SpaceTransform xform, string inputValue xform.normalize = true; sb.AddLine(outputVariable, " = TransformObjectToWorldDir(", inputValue, ", ", xform.NormalizeString(), ");"); break; + case ConversionType.Normal: + sb.AddLine(outputVariable, " = TransformObjectToWorldNormal(", inputValue, ", ", xform.NormalizeString(), ");"); + break; } } public static void TangentToWorld(SpaceTransform xform, string inputValue, string outputVariable, ShaderStringBuilder sb) { - // all tangent to world before version 2 are doing Direction transformations only + // prior to version 2 all transforms were Normal, and directional transforms were normalized if (xform.version <= 1) { - if (xform.type == ConversionType.Position) - xform.type = ConversionType.Direction; - else + if (xform.type != ConversionType.Position) xform.normalize = true; + xform.type = ConversionType.Normal; } using (sb.BlockScope()) { - string transposeTangentTransform = GenerateTransposeTangentTransform(sb, CoordinateSpace.World); + string tangentTransform = GenerateTangentTransform(sb, CoordinateSpace.World); switch (xform.type) { case ConversionType.Position: - sb.AddLine(outputVariable, " = mul(", transposeTangentTransform, ", ", inputValue, ").xyz + IN.WorldSpacePosition;"); + sb.AddLine(outputVariable, " = TransformTangentToWorldDir(", inputValue, ", ", tangentTransform, ", false).xyz + IN.WorldSpacePosition;"); break; case ConversionType.Direction: - if (xform.normalize) - sb.AddLine(outputVariable, " = SafeNormalize(mul(", transposeTangentTransform, ", ", inputValue, ").xyz);"); - else - sb.AddLine(outputVariable, " = mul(", transposeTangentTransform, ", ", inputValue, ").xyz;"); + sb.AddLine(outputVariable, " = TransformTangentToWorldDir(", inputValue, ", ", tangentTransform, ", ", xform.NormalizeString(), ").xyz;"); + break; + case ConversionType.Normal: + sb.AddLine(outputVariable, " = TransformTangentToWorld(", inputValue, ", ", tangentTransform, ", ", xform.NormalizeString(), ");"); break; } } @@ -273,15 +281,15 @@ public static void ViewToWorld(SpaceTransform xform, string inputValue, string o switch (xform.type) { case ConversionType.Position: - sb.AddLine(outputVariable, " = mul(UNITY_MATRIX_I_V, $precision4(", inputValue, ", 1)).xyz;"); + sb.AddLine(outputVariable, " = TransformViewToWorld(", inputValue, ");"); break; case ConversionType.Direction: if (xform.version <= 1) xform.normalize = false; - if (xform.normalize) - sb.AddLine(outputVariable, " = SafeNormalize(mul((float3x3) UNITY_MATRIX_I_V, ", inputValue, "));"); - else - sb.AddLine(outputVariable, " = mul((float3x3) UNITY_MATRIX_I_V, ", inputValue, ");"); + sb.AddLine(outputVariable, " = TransformViewToWorldDir(", inputValue, ", ", xform.NormalizeString(), ");"); + break; + case ConversionType.Normal: + sb.AddLine(outputVariable, " = TransformViewToWorldNormal(", inputValue, ", ", xform.NormalizeString(), ");"); break; } } @@ -298,6 +306,7 @@ public static void AbsoluteWorldToWorld(SpaceTransform xform, string inputValue, sb.AddLine(outputVariable, " = GetCameraRelativePositionWS(", inputValue, ");"); break; case ConversionType.Direction: + case ConversionType.Normal: // both normal and direction are unchanged if (xform.normalize) sb.AddLine(outputVariable, " = SafeNormalize(", inputValue, ");"); diff --git a/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/TransformNodePropertyDrawer.cs b/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/TransformNodePropertyDrawer.cs index 0c18a3948b4..22f4c687c69 100644 --- a/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/TransformNodePropertyDrawer.cs +++ b/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/TransformNodePropertyDrawer.cs @@ -15,7 +15,7 @@ class TransformNodePropertyDrawer : AbstractMaterialNodePropertyDrawer void UpdateVisibility() { - normalizePropRow.visible = (node.conversionType != ConversionType.Position); + normalizePropRow.visible = (node.sgVersion >= 2) && (node.conversionType != ConversionType.Position); } internal override void AddCustomNodeProperties(VisualElement parentElement, AbstractMaterialNode nodeBase, Action setNodesAsDirtyCallback, Action updateNodeViewsCallback) From 2e09d30afb829849c5e2c256f34aa80562a22459 Mon Sep 17 00:00:00 2001 From: Chris Tchou Date: Thu, 23 Sep 2021 15:26:10 -0700 Subject: [PATCH 08/23] Adding changelog --- com.unity.shadergraph/CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/com.unity.shadergraph/CHANGELOG.md b/com.unity.shadergraph/CHANGELOG.md index a82b0195223..bfe78705f3f 100644 --- a/com.unity.shadergraph/CHANGELOG.md +++ b/com.unity.shadergraph/CHANGELOG.md @@ -25,6 +25,7 @@ The version number for this package has increased due to a version update of a r - Fixed the wrong scaling of the main preview window [1356719] (https://issuetracker.unity3d.com/product/unity/issues/guid/1356719/) - Fixed an issue where ShaderGraph "view shader" commands were opening in individual windows, and blocking Unity from closing [1367188] - Improved screenspace position accuracy in the fragment shader by using VPOS [1352662] (https://issuetracker.unity3d.com/issues/shadergraph-dither-node-results-in-artifacts-when-far-from-origin-caused-by-screen-position-breaking-down) + - Fixed errors in the ShaderGraph Transform node [1368082] ## [12.0.0] - 2021-01-11 @@ -59,6 +60,7 @@ The version number for this package has increased due to a version update of a r - Added visible errors for invalid stage capability connections to shader graph. - Added a ShaderGraph animated preview framerate throttle. - Added many node synonyms for the Create Node search so that it's easier to find nodes. + - Added normal transforms to the Transform node ### Changed - Properties and Keywords are no longer separated by type on the blackboard. Categories allow for any combination of properties and keywords to be grouped together as the user defines. From 8648c7a30011c0da024987a03149e04d487d4d23 Mon Sep 17 00:00:00 2001 From: Chris Tchou Date: Fri, 24 Sep 2021 16:46:32 -0700 Subject: [PATCH 09/23] Adding node tests for transform node --- .../Editor/DebugNodes/IntegerHashNode.cs | 129 ++ .../Editor/DebugNodes/IntegerHashNode.cs.meta | 11 + .../Editor/DebugNodes/OldTransformNode.cs | 274 +++ .../DebugNodes/OldTransformNode.cs.meta | 11 + .../Assets/CommonAssets/Editor/NodeTests.cs | 94 + .../CommonAssets/Editor/NodeTests.cs.meta | 11 + .../Editor/ShaderGraphTestRenderer.cs | 132 ++ .../Editor/ShaderGraphTestRenderer.cs.meta | 11 + .../Graphs/TransformGraph.shadergraph | 1653 +++++++++++++++++ .../Graphs/TransformGraph.shadergraph.meta | 10 + 10 files changed, 2336 insertions(+) create mode 100644 TestProjects/ShaderGraph/Assets/CommonAssets/Editor/DebugNodes/IntegerHashNode.cs create mode 100644 TestProjects/ShaderGraph/Assets/CommonAssets/Editor/DebugNodes/IntegerHashNode.cs.meta create mode 100644 TestProjects/ShaderGraph/Assets/CommonAssets/Editor/DebugNodes/OldTransformNode.cs create mode 100644 TestProjects/ShaderGraph/Assets/CommonAssets/Editor/DebugNodes/OldTransformNode.cs.meta create mode 100644 TestProjects/ShaderGraph/Assets/CommonAssets/Editor/NodeTests.cs create mode 100644 TestProjects/ShaderGraph/Assets/CommonAssets/Editor/NodeTests.cs.meta create mode 100644 TestProjects/ShaderGraph/Assets/CommonAssets/Editor/ShaderGraphTestRenderer.cs create mode 100644 TestProjects/ShaderGraph/Assets/CommonAssets/Editor/ShaderGraphTestRenderer.cs.meta create mode 100644 TestProjects/ShaderGraph/Assets/CommonAssets/Graphs/TransformGraph.shadergraph create mode 100644 TestProjects/ShaderGraph/Assets/CommonAssets/Graphs/TransformGraph.shadergraph.meta diff --git a/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/DebugNodes/IntegerHashNode.cs b/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/DebugNodes/IntegerHashNode.cs new file mode 100644 index 00000000000..264e836aea5 --- /dev/null +++ b/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/DebugNodes/IntegerHashNode.cs @@ -0,0 +1,129 @@ +using System.Reflection; +using UnityEditor.Graphing; +using UnityEditor.ShaderGraph.Drawing.Controls; +using UnityEngine; + +namespace UnityEditor.ShaderGraph +{ + [Title("Procedural", "Noise", "Integer Hash")] + class IntegerHashNode : AbstractMaterialNode, IGeneratesBodyCode, IGeneratesFunction + { + public IntegerHashNode() + { + name = "Integer Hash"; + UpdateNodeAfterDeserialization(); + } + + public override bool hasPreview { get { return true; } } + + // Input slots + private const int kInputSlotId = 1; + private const string kInputSlotName = "Coord"; + + // Output slots + private const int kOutputSlotId = 0; + private const string kOutputSlotName = "Hash"; + + // Local state + public enum HashType + { + Tchou_2_1, + Tchou_2_3, + Tchou_3_1, + Tchou_3_3, + }; + + struct Description + { + public string functionName; + public int inputDimension; + public int outputDimension; + public Description(string f, int i, int o) { functionName = f; inputDimension = i; outputDimension = o; } + }; + + static Description[] k_hashDescriptions = + { + new Description("Hash_Tchou_2_1_float", 2, 1), + new Description("Hash_Tchou_2_3_float", 2, 3), + new Description("Hash_Tchou_3_1_float", 3, 1), + new Description("Hash_Tchou_3_3_float", 3, 3), + }; + + [SerializeField] + private HashType m_HashType = HashType.Tchou_2_3; + + [EnumControl("Hash")] + public HashType hashType + { + get + { + return m_HashType; + } + set + { + if (m_HashType == value) + return; + + m_HashType = value; + Dirty(ModificationScope.Topological); + UpdateNodeAfterDeserialization(); + } + } + + Description hashDescription => ((int) hashType >= 0 && (int) hashType < k_hashDescriptions.Length) ? k_hashDescriptions[(int)hashType] : k_hashDescriptions[0]; + + public MaterialSlot CreateVectorSlot(int dimension, int id, string name, SlotType slotType, Vector4 value = default) + { + MaterialSlot slot = null; + switch (dimension) + { + case 1: + slot = new Vector1MaterialSlot(id, name, name, slotType, value.x); + break; + case 2: + slot = new Vector2MaterialSlot(id, name, name, slotType, value); + break; + case 3: + slot = new Vector3MaterialSlot(id, name, name, slotType, value); + break; + case 4: + slot = new Vector4MaterialSlot(id, name, name, slotType, value); + break; + } + return slot; + } + + public sealed override void UpdateNodeAfterDeserialization() + { + var desc = hashDescription; + + MaterialSlot inputSlot = CreateVectorSlot(desc.inputDimension, kInputSlotId, kInputSlotName, SlotType.Input); + AddSlot(inputSlot); + + MaterialSlot outputSlot = CreateVectorSlot(desc.outputDimension, kOutputSlotId, kOutputSlotName, SlotType.Output); + AddSlot(outputSlot); + + RemoveSlotsNameNotMatching(new[] + { + kInputSlotId, + kOutputSlotId + }); + } + + public void GenerateNodeFunction(FunctionRegistry registry, GenerationMode generationMode) + { + registry.RequiresIncludePath("Packages/com.unity.render-pipelines.core/ShaderLibrary/Hashes.hlsl"); + } + + public void GenerateNodeCode(ShaderStringBuilder sb, GenerationMode generationMode) + { + var desc = hashDescription; + + var outputVar = GetVariableNameForSlot(kOutputSlotId); + var input = GetSlotValue(kInputSlotId, generationMode); + + sb.AppendLine($"$precision{desc.outputDimension} {outputVar};"); + sb.AppendLine($"{desc.functionName}({input}, {outputVar});"); + } + } +} diff --git a/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/DebugNodes/IntegerHashNode.cs.meta b/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/DebugNodes/IntegerHashNode.cs.meta new file mode 100644 index 00000000000..7d8777ebb4f --- /dev/null +++ b/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/DebugNodes/IntegerHashNode.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 3e795eefbcbdb5a469a2f0aa1520fa9b +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/DebugNodes/OldTransformNode.cs b/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/DebugNodes/OldTransformNode.cs new file mode 100644 index 00000000000..7aa76dd5108 --- /dev/null +++ b/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/DebugNodes/OldTransformNode.cs @@ -0,0 +1,274 @@ +using System; +using UnityEditor.Graphing; +using UnityEditor.ShaderGraph.Drawing.Controls; +using UnityEditor.ShaderGraph.Internal; +using UnityEngine; + +namespace UnityEditor.ShaderGraph +{ + [Title("Math", "Vector", "OldTransform")] + class OldTransformNode : AbstractMaterialNode, IGeneratesBodyCode, IMayRequireTangent, IMayRequireBitangent, IMayRequireNormal, IMayRequireTransform + { + public override int latestVersion => 1; + + private const int InputSlotId = 0; + private const int OutputSlotId = 1; + private const string kInputSlotName = "In"; + private const string kOutputSlotName = "Out"; + + public OldTransformNode() + { + name = "OldTransform"; + synonyms = new string[] { "world", "tangent", "object", "view", "screen", "convert" }; + UpdateNodeAfterDeserialization(); + } + + [SerializeField] + CoordinateSpaceConversion m_Conversion = new CoordinateSpaceConversion(CoordinateSpace.Object, CoordinateSpace.World); + + [EnumConversionControl] + public CoordinateSpaceConversion conversion + { + get { return m_Conversion; } + set + { + if (Equals(m_Conversion, value)) + return; + m_Conversion = value; + Dirty(ModificationScope.Graph); + } + } + + [SerializeField] + public ConversionType m_ConversionType = ConversionType.Position; + + [EnumControl("Type")] + public ConversionType conversionType + { + get { return m_ConversionType; } + set + { + if (Equals(m_ConversionType, value)) + return; + m_ConversionType = value; + Dirty(ModificationScope.Graph); + } + } + + public override bool hasPreview + { + get { return true; } + } + + public sealed override void UpdateNodeAfterDeserialization() + { + AddSlot(new Vector3MaterialSlot(InputSlotId, kInputSlotName, kInputSlotName, SlotType.Input, Vector3.zero)); + AddSlot(new Vector3MaterialSlot(OutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, Vector3.zero)); + RemoveSlotsNameNotMatching(new[] { InputSlotId, OutputSlotId }); + } + + public void GenerateNodeCode(ShaderStringBuilder sb, GenerationMode generationMode) + { + NodeUtils.SlotConfigurationExceptionIfBadConfiguration(this, new[] { InputSlotId }, new[] { OutputSlotId }); + string inputValue = string.Format("{0}.xyz", GetSlotValue(InputSlotId, generationMode)); + string targetTransformString = GetVariableNameForNode() + "_tangentTransform_" + conversion.from.ToString(); + string transposeTargetTransformString = GetVariableNameForNode() + "_transposeTangent"; + string transformString = ""; + string tangentTransformSpace = conversion.from.ToString(); + bool requiresTangentTransform = false; + bool requiresTransposeTangentTransform = false; + + if (conversion.from == CoordinateSpace.World) + { + if (conversion.to == CoordinateSpace.World) + { + transformString = inputValue; + } + else if (conversion.to == CoordinateSpace.Object) + { + transformString = string.Format(conversionType == ConversionType.Direction ? "TransformWorldToObjectDir({0})" : "TransformWorldToObject({0})", inputValue); + } + else if (conversion.to == CoordinateSpace.Tangent) + { + requiresTangentTransform = true; + transformString = string.Format("TransformWorldToTangent({0}, {1})", inputValue, targetTransformString); + } + else if (conversion.to == CoordinateSpace.View) + { + transformString = string.Format(conversionType == ConversionType.Direction ? "TransformWorldToViewDir({0})" : "TransformWorldToView({0})", inputValue); + } + else if (conversion.to == CoordinateSpace.AbsoluteWorld) + { + transformString = string.Format("GetAbsolutePositionWS({0})", inputValue); + } + } + else if (conversion.from == CoordinateSpace.Object) + { + if (conversion.to == CoordinateSpace.World) + { + transformString = string.Format(conversionType == ConversionType.Direction ? "TransformObjectToWorldDir({0})" : "TransformObjectToWorld({0})", inputValue); + } + else if (conversion.to == CoordinateSpace.Object) + { + transformString = inputValue; + } + else if (conversion.to == CoordinateSpace.Tangent) + { + requiresTangentTransform = true; + tangentTransformSpace = CoordinateSpace.World.ToString(); + transformString = string.Format(conversionType == ConversionType.Direction ? "TransformWorldToTangent(TransformObjectToWorldDir({0}), {1})" : "TransformWorldToTangent(TransformObjectToWorld({0}), {1})", inputValue, targetTransformString); + } + else if (conversion.to == CoordinateSpace.View) + { + transformString = string.Format(conversionType == ConversionType.Direction ? "TransformWorldToViewDir(TransformObjectToWorldDir({0}))" : "TransformWorldToView(TransformObjectToWorld({0}))", inputValue); + } + if (conversion.to == CoordinateSpace.AbsoluteWorld) + { + transformString = string.Format(conversionType == ConversionType.Direction ? "TransformObjectToWorldDir({0})" : "GetAbsolutePositionWS(TransformObjectToWorld({0}))", inputValue); + } + } + else if (conversion.from == CoordinateSpace.Tangent) + { + if (conversion.to == CoordinateSpace.World) + { + requiresTransposeTangentTransform = true; + transformString = string.Format(conversionType == ConversionType.Direction ? "normalize(mul({0}, {1}).xyz)" : "mul({0}, {1}).xyz", transposeTargetTransformString, inputValue); + } + else if (conversion.to == CoordinateSpace.Object) + { + requiresTransposeTangentTransform = true; + transformString = string.Format(conversionType == ConversionType.Direction ? "TransformWorldToObjectDir(mul({0}, {1}).xyz)" : "TransformWorldToObject(mul({0}, {1}).xyz)", transposeTargetTransformString, inputValue); + } + else if (conversion.to == CoordinateSpace.Tangent) + { + transformString = inputValue; + } + else if (conversion.to == CoordinateSpace.View) + { + requiresTransposeTangentTransform = true; + transformString = string.Format(conversionType == ConversionType.Direction ? "TransformWorldToViewDir(mul({0}, {1}).xyz)" : "TransformWorldToView(mul({0}, {1}).xyz)", transposeTargetTransformString, inputValue); + } + if (conversion.to == CoordinateSpace.AbsoluteWorld) + { + requiresTransposeTangentTransform = true; + transformString = string.Format("GetAbsolutePositionWS(mul({0}, {1})).xyz", transposeTargetTransformString, inputValue); + } + } + else if (conversion.from == CoordinateSpace.View) + { + if (conversion.to == CoordinateSpace.World) + { + transformString = string.Format(conversionType == ConversionType.Direction ? + "mul(UNITY_MATRIX_I_V, $precision4({0}, 0)).xyz" : + "mul(UNITY_MATRIX_I_V, $precision4({0}, 1)).xyz", inputValue); + } + else if (conversion.to == CoordinateSpace.Object) + { + transformString = string.Format(conversionType == ConversionType.Direction ? + "TransformWorldToObjectDir(mul((float3x3)UNITY_MATRIX_I_V, {0}))" : + "TransformWorldToObject(mul(UNITY_MATRIX_I_V, $precision4({0}, 1) ).xyz)", inputValue); + } + else if (conversion.to == CoordinateSpace.Tangent) + { + requiresTangentTransform = true; + tangentTransformSpace = CoordinateSpace.World.ToString(); + transformString = string.Format("TransformWorldToTangent(mul(UNITY_MATRIX_I_V, $precision4({0}, 1) ).xyz, {1})", inputValue, targetTransformString); + } + else if (conversion.to == CoordinateSpace.View) + { + transformString = inputValue; + } + else if (conversion.to == CoordinateSpace.AbsoluteWorld) + { + transformString = string.Format("GetAbsolutePositionWS(mul(UNITY_MATRIX_I_V, $precision4({0}, 1))).xyz", inputValue); + } + } + else if (conversion.from == CoordinateSpace.AbsoluteWorld) + { + if (conversion.to == CoordinateSpace.World) + { + transformString = string.Format("GetCameraRelativePositionWS({0})", inputValue); + } + else if (conversion.to == CoordinateSpace.Object) + { + if (m_SGVersion == 0) + { + transformString = string.Format(conversionType == ConversionType.Direction ? "TransformWorldToObjectDir(GetCameraRelativePositionWS({0}))" : "TransformWorldToObject(GetCameraRelativePositionWS({0}))", inputValue); + } + else + { + transformString = string.Format(conversionType == ConversionType.Direction ? "TransformWorldToObjectDir({0})" : "TransformWorldToObject(GetCameraRelativePositionWS({0}))", inputValue); + } + } + else if (conversion.to == CoordinateSpace.Tangent) + { + requiresTangentTransform = true; + tangentTransformSpace = CoordinateSpace.World.ToString(); + transformString = string.Format("TransformWorldToTangent(GetCameraRelativePositionWS({0}), {1})", inputValue, targetTransformString); + } + else if (conversion.to == CoordinateSpace.View) + { + if (m_SGVersion == 0) + { + transformString = string.Format(conversionType == ConversionType.Direction ? "TransformWorldToViewDir(GetCameraRelativePositionWS({0}))" : "TransformWorldToView(GetCameraRelativePositionWS({0}))", inputValue); + } + else + { + transformString = string.Format(conversionType == ConversionType.Direction ? "TransformWorldToViewDir({0})" : "TransformWorldToView(GetCameraRelativePositionWS({0}))", inputValue); + } + } + else if (conversion.to == CoordinateSpace.AbsoluteWorld) + { + transformString = inputValue; + } + } + if (requiresTransposeTangentTransform) + sb.AppendLine(string.Format("$precision3x3 {0} = transpose($precision3x3(IN.{1}SpaceTangent, IN.{1}SpaceBiTangent, IN.{1}SpaceNormal));", transposeTargetTransformString, CoordinateSpace.World.ToString())); + else if (requiresTangentTransform) + sb.AppendLine(string.Format("$precision3x3 {0} = $precision3x3(IN.{1}SpaceTangent, IN.{1}SpaceBiTangent, IN.{1}SpaceNormal);", targetTransformString, tangentTransformSpace)); + sb.AppendLine("{0} {1} = {2};", FindOutputSlot(OutputSlotId).concreteValueType.ToShaderString(), + GetVariableNameForSlot(OutputSlotId), + transformString); + } + + bool RequiresWorldSpaceTangentTransform() + { + if (conversion.from == CoordinateSpace.View && conversion.to == CoordinateSpace.Tangent + || conversion.from == CoordinateSpace.AbsoluteWorld + || conversion.from == CoordinateSpace.Object && conversion.to == CoordinateSpace.Tangent + || conversion.from == CoordinateSpace.Tangent) + return true; + else + return false; + } + + public NeededCoordinateSpace RequiresTangent(ShaderStageCapability stageCapability) + { + if (RequiresWorldSpaceTangentTransform()) + return NeededCoordinateSpace.World; + return conversion.from.ToNeededCoordinateSpace(); + } + + public NeededCoordinateSpace RequiresBitangent(ShaderStageCapability stageCapability) + { + if (RequiresWorldSpaceTangentTransform()) + return NeededCoordinateSpace.World; + return conversion.from.ToNeededCoordinateSpace(); + } + + public NeededCoordinateSpace RequiresNormal(ShaderStageCapability stageCapability) + { + if (RequiresWorldSpaceTangentTransform()) + return NeededCoordinateSpace.World; + return conversion.from.ToNeededCoordinateSpace(); + } + + public NeededTransform[] RequiresTransform(ShaderStageCapability stageCapability) + { + return new[] + { + new NeededTransform(conversion.from.ToNeededCoordinateSpace(), conversion.to.ToNeededCoordinateSpace()) + }; + } + } +} diff --git a/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/DebugNodes/OldTransformNode.cs.meta b/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/DebugNodes/OldTransformNode.cs.meta new file mode 100644 index 00000000000..f9c4c3654d2 --- /dev/null +++ b/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/DebugNodes/OldTransformNode.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: cd41c312c74a0ac43b5dad99f9b98a9f +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/NodeTests.cs b/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/NodeTests.cs new file mode 100644 index 00000000000..d68d73a9baf --- /dev/null +++ b/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/NodeTests.cs @@ -0,0 +1,94 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using NUnit.Framework; +using UnityEditor.ShaderGraph; +using UnityEditor.ShaderGraph.Internal; +using UnityEngine; +using UnityEngine.TestTools; +using UnityEngine.Experimental.Rendering; + +namespace UnityEditor.ShaderGraph.UnitTests +{ + class NodeTests + { + [UnityTest] + public IEnumerator TransformV1MatchesOldTransform() + { + string kGraphName = "Assets/CommonAssets/Graphs/TransformGraph.shadergraph"; + + List lti; + var assetCollection = new AssetCollection(); + ShaderGraphImporter.GetShaderText(kGraphName, out lti, assetCollection, out var graph); + Assert.NotNull(graph, $"Invalid graph data found for {kGraphName}"); + graph.OnEnable(); + graph.ValidateGraph(); + + var renderer = new ShaderGraphTestRenderer(); + + // first check that it renders red in the initial state, to check that the test works + // (graph is initially set up with non-matching transforms) + { + RenderTextureDescriptor descriptor = new RenderTextureDescriptor(128, 128, GraphicsFormat.R8G8B8A8_SRGB, depthBufferBits: 32); + var target = RenderTexture.GetTemporary(descriptor); + + // use a non-standard transform, so that view, object, etc. transforms are non trivial + renderer.RenderQuadPreview(graph, target, new Vector3(1.24699998f, 1.51900005f, 0.328999996f), new Quaternion(-0.164710045f, -0.0826543793f, -0.220811233f, 0.957748055f), useSRP: true); + + int incorrectPixels = ShaderGraphTestRenderer.CountPixelsNotEqual(target, new Color32(0, 255, 0, 255), false); + Assert.AreEqual(128*128, incorrectPixels, "Number of incorrect pixels was not zero: initial state"); + + //if (incorrectPixels != 0) + // TestUtils.SaveToPNG(target, "Assets/CommonAssets/Graphs/TransformGraph.png"); + + RenderTexture.ReleaseTemporary(target); + yield return null; + } + + var xform = graph.GetNodes().First(); + var old = graph.GetNodes().First(); + + // now check all possible settings + var oldConversionTypes = new ConversionType[] { ConversionType.Position, ConversionType.Direction }; + foreach (ConversionType conversionType in oldConversionTypes) + { + foreach (CoordinateSpace source in Enum.GetValues(typeof(CoordinateSpace))) + { + foreach (CoordinateSpace dest in Enum.GetValues(typeof(CoordinateSpace))) + { + // setup transform(v1) node + xform.conversion = new CoordinateSpaceConversion(source, dest); + xform.conversionType = conversionType; + xform.normalize = false; + + // setup old transform node + old.conversion = new CoordinateSpaceConversion(source, dest); + old.conversionType = conversionType; + + RenderTextureDescriptor descriptor = new RenderTextureDescriptor(128, 128, GraphicsFormat.R8G8B8A8_SRGB, depthBufferBits: 32); + var target = RenderTexture.GetTemporary(descriptor); + + // Debug.Log($"Tested: {source} to {dest} ({conversionType})"); + + // use a non-standard transform, so that view, object, etc. transforms are non trivial + renderer.RenderQuadPreview(graph, target, new Vector3(1.24699998f, 1.51900005f, 4.328999996f), new Quaternion(-0.164710045f, -0.0826543793f, -0.220811233f, 0.957748055f), useSRP: true); + + int incorrectPixels = ShaderGraphTestRenderer.CountPixelsNotEqual(target, new Color32(0, 255, 0, 255), false); + Assert.AreEqual(0, incorrectPixels, $"Number of incorrect pixels was not zero: {source} to {dest} ({conversionType})"); + + //if (incorrectPixels != 0) + // TestUtils.SaveToPNG(target, "Assets/CommonAssets/Graphs/TransformGraph.png"); + + RenderTexture.ReleaseTemporary(target); + } + + // have to yield to let a frame pass + // unity only releases some resources at the end of a frame + // and if you do too many renders in a frame it will run out + yield return null; + } + } + } + } +} diff --git a/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/NodeTests.cs.meta b/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/NodeTests.cs.meta new file mode 100644 index 00000000000..08aa4edfd50 --- /dev/null +++ b/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/NodeTests.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: dae135db9c4e0e74da33ca86214bbab8 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/ShaderGraphTestRenderer.cs b/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/ShaderGraphTestRenderer.cs new file mode 100644 index 00000000000..405fd6c5dd1 --- /dev/null +++ b/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/ShaderGraphTestRenderer.cs @@ -0,0 +1,132 @@ + +using System.IO; +using UnityEngine; +using UnityEditor; +using UnityEngine.Experimental.Rendering; +using UnityEngine.Rendering; +using UnityEditor.ShaderGraph; +using UnityEditor.ShaderGraph.Drawing; + +public class ShaderGraphTestRenderer +{ + PreviewSceneResources previewScene = new PreviewSceneResources(); + + internal static Shader BuildShaderGraph(GraphData graph, string name, bool hide = true) + { + var generator = new Generator(graph, graph.outputNode, GenerationMode.ForReals, "TransformGraph", null); + string shaderString = generator.generatedShader; + + var shader = ShaderUtil.CreateShaderAsset(shaderString, false); + if (hide) + shader.hideFlags = HideFlags.HideAndDontSave; + + return shader; + } + + internal static void RenderMeshWithMaterial(Camera cam, Mesh mesh, Matrix4x4 transform, Material mat, RenderTexture target, bool useSRP = true) + { + // Force async compile OFF + var wasAsyncAllowed = ShaderUtil.allowAsyncCompilation; + ShaderUtil.allowAsyncCompilation = false; + + var previousRenderTexture = RenderTexture.active; + RenderTexture.active = target; + + GL.Clear(true, true, Color.black); + + cam.targetTexture = target; + Graphics.DrawMesh( + mesh: mesh, + matrix: transform, + material: mat, + layer: 1, + camera: cam, + submeshIndex: 0, + properties: null, + castShadows: ShadowCastingMode.Off, + receiveShadows: false, + probeAnchor: null, + useLightProbes: false); + + var previousUseSRP = Unsupported.useScriptableRenderPipeline; + Unsupported.useScriptableRenderPipeline = useSRP; + cam.Render(); + Unsupported.useScriptableRenderPipeline = previousUseSRP; + + RenderTexture.active = previousRenderTexture; + ShaderUtil.allowAsyncCompilation = wasAsyncAllowed; + } + + internal static void SaveToPNG(RenderTexture target, string path) + { + Texture2D temp = new Texture2D(target.width, target.height, TextureFormat.RGBA32, mipChain: false, linear: false); + + var previousRenderTexture = RenderTexture.active; + RenderTexture.active = target; + temp.ReadPixels(new Rect(0, 0, target.width, target.height), 0, 0); + RenderTexture.active = previousRenderTexture; + + var pngData = temp.EncodeToPNG(); + if (pngData != null) + { + File.WriteAllBytes(path, pngData); + } + UnityEngine.Object.DestroyImmediate(temp); + } + + internal static int CountPixelsNotEqual(RenderTexture target, Color32 value, bool compareAlpha) + { + Texture2D temp = new Texture2D(target.width, target.height, TextureFormat.RGBA32, mipChain: false, linear: false); + + var previousRenderTexture = RenderTexture.active; + RenderTexture.active = target; + temp.ReadPixels(new Rect(0, 0, target.width, target.height), 0, 0); + RenderTexture.active = previousRenderTexture; + + int mismatchCount = 0; + var pixels = temp.GetPixels32(0); + foreach (var pixel in pixels) + { + if ((pixel.r != value.r) || + (pixel.g != value.g) || + (pixel.b != value.b) || + (compareAlpha && (pixel.a != value.a))) + { + mismatchCount++; + } + } + + UnityEngine.Object.DestroyImmediate(temp); + return mismatchCount; + } + + // scenePosition/Rotation is applied to both the camera and the quad. Useful for testing position-sensitive behaviors + internal void RenderQuadPreview(GraphData graph, RenderTexture target, bool useSRP = false) + { + RenderQuadPreview(graph, target, Vector3.zero, Quaternion.identity, useSRP); + } + + internal void RenderQuadPreview(GraphData graph, RenderTexture target, Vector3 scenePosition, Quaternion sceneRotation, bool useSRP = false) + { + var camXform = previewScene.camera.transform; + + // setup 2D quad render + camXform.position = -Vector3.forward * 2 + scenePosition; + camXform.rotation = sceneRotation; + previewScene.camera.orthographicSize = 0.5f; + previewScene.camera.orthographic = true; + + // EditorUtility.SetCameraAnimateMaterialsTime(sceneResources.camera, 7.3542f); + + graph.ValidateGraph(); + + // build the shader + var shader = BuildShaderGraph(graph, "Test Shader"); + var mat = new Material(shader) { hideFlags = HideFlags.HideAndDontSave }; + + var quadMatrix = Matrix4x4.TRS(camXform.position + camXform.forward * 2, camXform.rotation, Vector3.one); + + // render with it + RenderMeshWithMaterial(previewScene.camera, previewScene.quad, quadMatrix, mat, target, useSRP); + } +} diff --git a/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/ShaderGraphTestRenderer.cs.meta b/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/ShaderGraphTestRenderer.cs.meta new file mode 100644 index 00000000000..cd7a679ccfe --- /dev/null +++ b/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/ShaderGraphTestRenderer.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: b12b457ea0f15344394a0a574e276043 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/TestProjects/ShaderGraph/Assets/CommonAssets/Graphs/TransformGraph.shadergraph b/TestProjects/ShaderGraph/Assets/CommonAssets/Graphs/TransformGraph.shadergraph new file mode 100644 index 00000000000..2df09b9086e --- /dev/null +++ b/TestProjects/ShaderGraph/Assets/CommonAssets/Graphs/TransformGraph.shadergraph @@ -0,0 +1,1653 @@ +{ + "m_SGVersion": 3, + "m_Type": "UnityEditor.ShaderGraph.GraphData", + "m_ObjectId": "d3a578d5f6c048d989f4fc22763a096c", + "m_Properties": [], + "m_Keywords": [], + "m_Dropdowns": [], + "m_CategoryData": [ + { + "m_Id": "82645ecd662c4d88a7de4083a8e5b53c" + } + ], + "m_Nodes": [ + { + "m_Id": "fc28a5ef65284ed0967870ff69516ffe" + }, + { + "m_Id": "970cbadefd8f4fcca05f884246b4ad3e" + }, + { + "m_Id": "3ec2632bb2694b7699d26c257e2879ea" + }, + { + "m_Id": "65611bc2ea7845359ab31d44dd0816ab" + }, + { + "m_Id": "d7fc69d9fbd84fe5b18d4361e39b39b9" + }, + { + "m_Id": "997e733a37a141d4b698281397e00d14" + }, + { + "m_Id": "d5c0ffaecc9d45f986de4d8925bc0051" + }, + { + "m_Id": "df18f46740a84dab99307b542e7e9102" + }, + { + "m_Id": "de1092b024884fdf9e8a5171a48ef13e" + }, + { + "m_Id": "fa72769f37e54f599d367774a779d845" + }, + { + "m_Id": "cd74f48ac90a40f49890cd16fbf6660a" + }, + { + "m_Id": "213cc9f9f0b74151975715b4fdbcf045" + }, + { + "m_Id": "afd6fed3d8e8461c9ac141b19e55e04d" + }, + { + "m_Id": "1746ecad396f45c2808181de7c16ab2d" + } + ], + "m_GroupDatas": [], + "m_StickyNoteDatas": [], + "m_Edges": [ + { + "m_OutputSlot": { + "m_Node": { + "m_Id": "1746ecad396f45c2808181de7c16ab2d" + }, + "m_SlotId": 1 + }, + "m_InputSlot": { + "m_Node": { + "m_Id": "afd6fed3d8e8461c9ac141b19e55e04d" + }, + "m_SlotId": 2 + } + }, + { + "m_OutputSlot": { + "m_Node": { + "m_Id": "213cc9f9f0b74151975715b4fdbcf045" + }, + "m_SlotId": 2 + }, + "m_InputSlot": { + "m_Node": { + "m_Id": "d7fc69d9fbd84fe5b18d4361e39b39b9" + }, + "m_SlotId": 1 + } + }, + { + "m_OutputSlot": { + "m_Node": { + "m_Id": "997e733a37a141d4b698281397e00d14" + }, + "m_SlotId": 0 + }, + "m_InputSlot": { + "m_Node": { + "m_Id": "213cc9f9f0b74151975715b4fdbcf045" + }, + "m_SlotId": 0 + } + }, + { + "m_OutputSlot": { + "m_Node": { + "m_Id": "afd6fed3d8e8461c9ac141b19e55e04d" + }, + "m_SlotId": 3 + }, + "m_InputSlot": { + "m_Node": { + "m_Id": "65611bc2ea7845359ab31d44dd0816ab" + }, + "m_SlotId": 0 + } + }, + { + "m_OutputSlot": { + "m_Node": { + "m_Id": "cd74f48ac90a40f49890cd16fbf6660a" + }, + "m_SlotId": 2 + }, + "m_InputSlot": { + "m_Node": { + "m_Id": "1746ecad396f45c2808181de7c16ab2d" + }, + "m_SlotId": 0 + } + }, + { + "m_OutputSlot": { + "m_Node": { + "m_Id": "d5c0ffaecc9d45f986de4d8925bc0051" + }, + "m_SlotId": 2 + }, + "m_InputSlot": { + "m_Node": { + "m_Id": "fa72769f37e54f599d367774a779d845" + }, + "m_SlotId": 0 + } + }, + { + "m_OutputSlot": { + "m_Node": { + "m_Id": "d7fc69d9fbd84fe5b18d4361e39b39b9" + }, + "m_SlotId": 0 + }, + "m_InputSlot": { + "m_Node": { + "m_Id": "de1092b024884fdf9e8a5171a48ef13e" + }, + "m_SlotId": 0 + } + }, + { + "m_OutputSlot": { + "m_Node": { + "m_Id": "d7fc69d9fbd84fe5b18d4361e39b39b9" + }, + "m_SlotId": 0 + }, + "m_InputSlot": { + "m_Node": { + "m_Id": "df18f46740a84dab99307b542e7e9102" + }, + "m_SlotId": 0 + } + }, + { + "m_OutputSlot": { + "m_Node": { + "m_Id": "de1092b024884fdf9e8a5171a48ef13e" + }, + "m_SlotId": 1 + }, + "m_InputSlot": { + "m_Node": { + "m_Id": "d5c0ffaecc9d45f986de4d8925bc0051" + }, + "m_SlotId": 1 + } + }, + { + "m_OutputSlot": { + "m_Node": { + "m_Id": "df18f46740a84dab99307b542e7e9102" + }, + "m_SlotId": 1 + }, + "m_InputSlot": { + "m_Node": { + "m_Id": "d5c0ffaecc9d45f986de4d8925bc0051" + }, + "m_SlotId": 0 + } + }, + { + "m_OutputSlot": { + "m_Node": { + "m_Id": "fa72769f37e54f599d367774a779d845" + }, + "m_SlotId": 1 + }, + "m_InputSlot": { + "m_Node": { + "m_Id": "cd74f48ac90a40f49890cd16fbf6660a" + }, + "m_SlotId": 0 + } + } + ], + "m_VertexContext": { + "m_Position": { + "x": -150.0001220703125, + "y": -286.99993896484377 + }, + "m_Blocks": [ + { + "m_Id": "fc28a5ef65284ed0967870ff69516ffe" + }, + { + "m_Id": "970cbadefd8f4fcca05f884246b4ad3e" + }, + { + "m_Id": "3ec2632bb2694b7699d26c257e2879ea" + } + ] + }, + "m_FragmentContext": { + "m_Position": { + "x": -150.0001220703125, + "y": -86.9999771118164 + }, + "m_Blocks": [ + { + "m_Id": "65611bc2ea7845359ab31d44dd0816ab" + } + ] + }, + "m_PreviewData": { + "serializedMesh": { + "m_SerializedMesh": "{\"mesh\":{\"instanceID\":0}}", + "m_Guid": "" + }, + "preventRotation": false + }, + "m_Path": "Shader Graphs", + "m_GraphPrecision": 1, + "m_PreviewMode": 2, + "m_OutputNode": { + "m_Id": "" + }, + "m_ActiveTargets": [ + { + "m_Id": "1e17856cccb848638b5a1829dd00d4f8" + } + ] +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.SaturateNode", + "m_ObjectId": "1746ecad396f45c2808181de7c16ab2d", + "m_Group": { + "m_Id": "" + }, + "m_Name": "Saturate", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": -688.0, + "y": 2.0, + "width": 208.0, + "height": 278.0 + } + }, + "m_Slots": [ + { + "m_Id": "691ae26bade44166941282be4b9e5582" + }, + { + "m_Id": "b20bd24cda5545cba5f1e7f3fdb7868d" + } + ], + "synonyms": [ + "clamp" + ], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + } +} + +{ + "m_SGVersion": 1, + "m_Type": "UnityEditor.Rendering.Universal.ShaderGraph.UniversalTarget", + "m_ObjectId": "1e17856cccb848638b5a1829dd00d4f8", + "m_ActiveSubTarget": { + "m_Id": "416b95b32d794f768b76ab713d607602" + }, + "m_AllowMaterialOverride": false, + "m_SurfaceType": 0, + "m_ZTestMode": 4, + "m_ZWriteControl": 0, + "m_AlphaMode": 0, + "m_RenderFace": 2, + "m_AlphaClip": false, + "m_CastShadows": true, + "m_ReceiveShadows": true, + "m_CustomEditorGUI": "", + "m_SupportVFX": false +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.Vector2MaterialSlot", + "m_ObjectId": "21393da4eb4d423a8f0b10e2ec444b34", + "m_Id": 1, + "m_DisplayName": "Coord", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "Coord", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0 + }, + "m_Labels": [] +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.MultiplyNode", + "m_ObjectId": "213cc9f9f0b74151975715b4fdbcf045", + "m_Group": { + "m_Id": "" + }, + "m_Name": "Multiply", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": -2094.0, + "y": 3.0000247955322267, + "width": 207.9998779296875, + "height": 302.0 + } + }, + "m_Slots": [ + { + "m_Id": "b20ad9a9abab4ca7b92963d52bb19e94" + }, + { + "m_Id": "db571653035448e0990b13330fa88f31" + }, + { + "m_Id": "b9264fc783d44451961ace0b6ffac2b2" + } + ], + "synonyms": [ + "multiplication", + "times", + "x" + ], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "38d77b7f78e54e4e952af3311791ccd4", + "m_Id": 2, + "m_DisplayName": "Out", + "m_SlotType": 1, + "m_Hidden": false, + "m_ShaderOutputName": "Out", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.ColorRGBMaterialSlot", + "m_ObjectId": "3b6e685d10224984b1ec689fc2168cf2", + "m_Id": 0, + "m_DisplayName": "Base Color", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "BaseColor", + "m_StageCapability": 2, + "m_Value": { + "x": 0.5, + "y": 0.5, + "z": 0.5 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_Labels": [], + "m_ColorMode": 0, + "m_DefaultColor": { + "r": 0.5, + "g": 0.5, + "b": 0.5, + "a": 1.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.BlockNode", + "m_ObjectId": "3ec2632bb2694b7699d26c257e2879ea", + "m_Group": { + "m_Id": "" + }, + "m_Name": "VertexDescription.Tangent", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": 0.0, + "y": 0.0, + "width": 0.0, + "height": 0.0 + } + }, + "m_Slots": [ + { + "m_Id": "628ef29e9b5d447e9caa4531bcbe6b10" + } + ], + "synonyms": [], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + }, + "m_SerializedDescriptor": "VertexDescription.Tangent" +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.Rendering.Universal.ShaderGraph.UniversalUnlitSubTarget", + "m_ObjectId": "416b95b32d794f768b76ab713d607602" +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "44ff4c8e37d149f0a0ea59d40128711c", + "m_Id": 2, + "m_DisplayName": "T", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "T", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "54f4946a07ec470ab8eec9a158a27258", + "m_Id": 3, + "m_DisplayName": "Out", + "m_SlotType": 1, + "m_Hidden": false, + "m_ShaderOutputName": "Out", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "5773db1af68243e0b9bd3ef7d7e70faa", + "m_Id": 0, + "m_DisplayName": "A", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "A", + "m_StageCapability": 3, + "m_Value": { + "x": 1.0, + "y": 1.0, + "z": 1.0, + "w": 1.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "6286951a44ca42e8adf651ceec17a756", + "m_Id": 1, + "m_DisplayName": "Out", + "m_SlotType": 1, + "m_Hidden": false, + "m_ShaderOutputName": "Out", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.TangentMaterialSlot", + "m_ObjectId": "628ef29e9b5d447e9caa4531bcbe6b10", + "m_Id": 0, + "m_DisplayName": "Tangent", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "Tangent", + "m_StageCapability": 1, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_Labels": [], + "m_Space": 0 +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.BlockNode", + "m_ObjectId": "65611bc2ea7845359ab31d44dd0816ab", + "m_Group": { + "m_Id": "" + }, + "m_Name": "SurfaceDescription.BaseColor", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": 0.0, + "y": 0.0, + "width": 0.0, + "height": 0.0 + } + }, + "m_Slots": [ + { + "m_Id": "3b6e685d10224984b1ec689fc2168cf2" + } + ], + "synonyms": [], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + }, + "m_SerializedDescriptor": "SurfaceDescription.BaseColor" +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "691ae26bade44166941282be4b9e5582", + "m_Id": 0, + "m_DisplayName": "In", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "In", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "6a253040a6fd42dcbf025ac7ff33aa6c", + "m_Id": 1, + "m_DisplayName": "B", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "B", + "m_StageCapability": 3, + "m_Value": { + "x": 1.0, + "y": 1.0, + "z": 1.0, + "w": 1.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.Vector3MaterialSlot", + "m_ObjectId": "6bb1519686984d74ab200c925b9a3676", + "m_Id": 1, + "m_DisplayName": "Out", + "m_SlotType": 1, + "m_Hidden": false, + "m_ShaderOutputName": "Out", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_Labels": [] +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "76d15710128b4ba5a42566d71f242c7e", + "m_Id": 0, + "m_DisplayName": "In", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "In", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicValueMaterialSlot", + "m_ObjectId": "78abf71b291948a891e8fa2a931cac62", + "m_Id": 0, + "m_DisplayName": "A", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "A", + "m_StageCapability": 3, + "m_Value": { + "e00": 200.0, + "e01": 0.0, + "e02": 0.0, + "e03": 0.0, + "e10": 0.0, + "e11": 0.0, + "e12": 0.0, + "e13": 0.0, + "e20": 0.0, + "e21": 0.0, + "e22": 0.0, + "e23": 0.0, + "e30": 0.0, + "e31": 0.0, + "e32": 0.0, + "e33": 0.0 + }, + "m_DefaultValue": { + "e00": 1.0, + "e01": 0.0, + "e02": 0.0, + "e03": 0.0, + "e10": 0.0, + "e11": 1.0, + "e12": 0.0, + "e13": 0.0, + "e20": 0.0, + "e21": 0.0, + "e22": 1.0, + "e23": 0.0, + "e30": 0.0, + "e31": 0.0, + "e32": 0.0, + "e33": 1.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.CategoryData", + "m_ObjectId": "82645ecd662c4d88a7de4083a8e5b53c", + "m_Name": "", + "m_ChildObjectList": [] +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.Vector3MaterialSlot", + "m_ObjectId": "8a871f1b8d354b02b2dbcf3aed00bd1d", + "m_Id": 0, + "m_DisplayName": "Hash", + "m_SlotType": 1, + "m_Hidden": false, + "m_ShaderOutputName": "Hash", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_Labels": [] +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.BlockNode", + "m_ObjectId": "970cbadefd8f4fcca05f884246b4ad3e", + "m_Group": { + "m_Id": "" + }, + "m_Name": "VertexDescription.Normal", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": 0.0, + "y": 0.0, + "width": 0.0, + "height": 0.0 + } + }, + "m_Slots": [ + { + "m_Id": "d25d1af86a094ac7be2f0127f4634d7b" + } + ], + "synonyms": [], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + }, + "m_SerializedDescriptor": "VertexDescription.Normal" +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.ScreenPositionNode", + "m_ObjectId": "997e733a37a141d4b698281397e00d14", + "m_Group": { + "m_Id": "" + }, + "m_Name": "Screen Position", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": -2396.0, + "y": 3.0000007152557375, + "width": 208.0, + "height": 313.0 + } + }, + "m_Slots": [ + { + "m_Id": "ad89e0280e524d9999c12e31260bd0a2" + } + ], + "synonyms": [], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + }, + "m_ScreenSpaceType": 4 +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.Vector3MaterialSlot", + "m_ObjectId": "a0079a38ddea4edca79008d23399c5b1", + "m_Id": 1, + "m_DisplayName": "Out", + "m_SlotType": 1, + "m_Hidden": false, + "m_ShaderOutputName": "Out", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_Labels": [] +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicValueMaterialSlot", + "m_ObjectId": "a6ad0619b0ff4b35b9c068ac56819033", + "m_Id": 2, + "m_DisplayName": "Out", + "m_SlotType": 1, + "m_Hidden": false, + "m_ShaderOutputName": "Out", + "m_StageCapability": 3, + "m_Value": { + "e00": 0.0, + "e01": 0.0, + "e02": 0.0, + "e03": 0.0, + "e10": 0.0, + "e11": 0.0, + "e12": 0.0, + "e13": 0.0, + "e20": 0.0, + "e21": 0.0, + "e22": 0.0, + "e23": 0.0, + "e30": 0.0, + "e31": 0.0, + "e32": 0.0, + "e33": 0.0 + }, + "m_DefaultValue": { + "e00": 1.0, + "e01": 0.0, + "e02": 0.0, + "e03": 0.0, + "e10": 0.0, + "e11": 1.0, + "e12": 0.0, + "e13": 0.0, + "e20": 0.0, + "e21": 0.0, + "e22": 1.0, + "e23": 0.0, + "e30": 0.0, + "e31": 0.0, + "e32": 0.0, + "e33": 1.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.Vector4MaterialSlot", + "m_ObjectId": "ad89e0280e524d9999c12e31260bd0a2", + "m_Id": 0, + "m_DisplayName": "Out", + "m_SlotType": 1, + "m_Hidden": false, + "m_ShaderOutputName": "Out", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_Labels": [] +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.LerpNode", + "m_ObjectId": "afd6fed3d8e8461c9ac141b19e55e04d", + "m_Group": { + "m_Id": "" + }, + "m_Name": "Lerp", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": -404.0000305175781, + "y": -90.99991607666016, + "width": 207.9999237060547, + "height": 325.9999084472656 + } + }, + "m_Slots": [ + { + "m_Id": "d0bc4074e39847c09e25d45223ff7f12" + }, + { + "m_Id": "fefaeb0050de4b00a9a812607dec2e12" + }, + { + "m_Id": "44ff4c8e37d149f0a0ea59d40128711c" + }, + { + "m_Id": "54f4946a07ec470ab8eec9a158a27258" + } + ], + "synonyms": [ + "mix", + "blend", + "linear interpolate" + ], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicValueMaterialSlot", + "m_ObjectId": "b20ad9a9abab4ca7b92963d52bb19e94", + "m_Id": 0, + "m_DisplayName": "A", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "A", + "m_StageCapability": 3, + "m_Value": { + "e00": 0.0, + "e01": 0.0, + "e02": 0.0, + "e03": 0.0, + "e10": 0.0, + "e11": 0.0, + "e12": 0.0, + "e13": 0.0, + "e20": 0.0, + "e21": 0.0, + "e22": 0.0, + "e23": 0.0, + "e30": 0.0, + "e31": 0.0, + "e32": 0.0, + "e33": 0.0 + }, + "m_DefaultValue": { + "e00": 1.0, + "e01": 0.0, + "e02": 0.0, + "e03": 0.0, + "e10": 0.0, + "e11": 1.0, + "e12": 0.0, + "e13": 0.0, + "e20": 0.0, + "e21": 0.0, + "e22": 1.0, + "e23": 0.0, + "e30": 0.0, + "e31": 0.0, + "e32": 0.0, + "e33": 1.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "b20bd24cda5545cba5f1e7f3fdb7868d", + "m_Id": 1, + "m_DisplayName": "Out", + "m_SlotType": 1, + "m_Hidden": false, + "m_ShaderOutputName": "Out", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.Vector3MaterialSlot", + "m_ObjectId": "b8a878cba4724959b9edf1199fa01fd7", + "m_Id": 0, + "m_DisplayName": "In", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "In", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_Labels": [] +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicValueMaterialSlot", + "m_ObjectId": "b9264fc783d44451961ace0b6ffac2b2", + "m_Id": 2, + "m_DisplayName": "Out", + "m_SlotType": 1, + "m_Hidden": false, + "m_ShaderOutputName": "Out", + "m_StageCapability": 3, + "m_Value": { + "e00": 0.0, + "e01": 0.0, + "e02": 0.0, + "e03": 0.0, + "e10": 0.0, + "e11": 0.0, + "e12": 0.0, + "e13": 0.0, + "e20": 0.0, + "e21": 0.0, + "e22": 0.0, + "e23": 0.0, + "e30": 0.0, + "e31": 0.0, + "e32": 0.0, + "e33": 0.0 + }, + "m_DefaultValue": { + "e00": 1.0, + "e01": 0.0, + "e02": 0.0, + "e03": 0.0, + "e10": 0.0, + "e11": 1.0, + "e12": 0.0, + "e13": 0.0, + "e20": 0.0, + "e21": 0.0, + "e22": 1.0, + "e23": 0.0, + "e30": 0.0, + "e31": 0.0, + "e32": 0.0, + "e33": 1.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.MultiplyNode", + "m_ObjectId": "cd74f48ac90a40f49890cd16fbf6660a", + "m_Group": { + "m_Id": "" + }, + "m_Name": "Multiply", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": -896.0, + "y": 2.0, + "width": 208.0, + "height": 302.0 + } + }, + "m_Slots": [ + { + "m_Id": "78abf71b291948a891e8fa2a931cac62" + }, + { + "m_Id": "df63aca4443847ec96ffc346ffd297b7" + }, + { + "m_Id": "a6ad0619b0ff4b35b9c068ac56819033" + } + ], + "synonyms": [ + "multiplication", + "times", + "x" + ], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "d0bc4074e39847c09e25d45223ff7f12", + "m_Id": 0, + "m_DisplayName": "A", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "A", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 1.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.NormalMaterialSlot", + "m_ObjectId": "d25d1af86a094ac7be2f0127f4634d7b", + "m_Id": 0, + "m_DisplayName": "Normal", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "Normal", + "m_StageCapability": 1, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_Labels": [], + "m_Space": 0 +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.SubtractNode", + "m_ObjectId": "d5c0ffaecc9d45f986de4d8925bc0051", + "m_Group": { + "m_Id": "" + }, + "m_Name": "Subtract", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": -1312.0, + "y": 3.0000650882720949, + "width": 208.0, + "height": 302.0 + } + }, + "m_Slots": [ + { + "m_Id": "5773db1af68243e0b9bd3ef7d7e70faa" + }, + { + "m_Id": "6a253040a6fd42dcbf025ac7ff33aa6c" + }, + { + "m_Id": "38d77b7f78e54e4e952af3311791ccd4" + } + ], + "synonyms": [ + "subtraction", + "remove", + "minus", + "take away" + ], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.IntegerHashNode", + "m_ObjectId": "d7fc69d9fbd84fe5b18d4361e39b39b9", + "m_Group": { + "m_Id": "" + }, + "m_Name": "Integer Hash", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": -1847.0, + "y": 3.0000650882720949, + "width": 208.0, + "height": 313.0 + } + }, + "m_Slots": [ + { + "m_Id": "21393da4eb4d423a8f0b10e2ec444b34" + }, + { + "m_Id": "8a871f1b8d354b02b2dbcf3aed00bd1d" + } + ], + "synonyms": [], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + }, + "m_HashType": 1 +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicValueMaterialSlot", + "m_ObjectId": "db571653035448e0990b13330fa88f31", + "m_Id": 1, + "m_DisplayName": "B", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "B", + "m_StageCapability": 3, + "m_Value": { + "e00": 2.0, + "e01": 2.0, + "e02": 0.0, + "e03": 0.0, + "e10": 2.0, + "e11": 2.0, + "e12": 2.0, + "e13": 2.0, + "e20": 2.0, + "e21": 2.0, + "e22": 2.0, + "e23": 2.0, + "e30": 2.0, + "e31": 2.0, + "e32": 2.0, + "e33": 2.0 + }, + "m_DefaultValue": { + "e00": 1.0, + "e01": 0.0, + "e02": 0.0, + "e03": 0.0, + "e10": 0.0, + "e11": 1.0, + "e12": 0.0, + "e13": 0.0, + "e20": 0.0, + "e21": 0.0, + "e22": 1.0, + "e23": 0.0, + "e30": 0.0, + "e31": 0.0, + "e32": 0.0, + "e33": 1.0 + } +} + +{ + "m_SGVersion": 1, + "m_Type": "UnityEditor.ShaderGraph.TransformNode", + "m_ObjectId": "de1092b024884fdf9e8a5171a48ef13e", + "m_Group": { + "m_Id": "" + }, + "m_Name": "Transform", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": -1570.0, + "y": 180.00003051757813, + "width": 213.0, + "height": 340.9999084472656 + } + }, + "m_Slots": [ + { + "m_Id": "e52abb26e3ba40958f14752a649a892c" + }, + { + "m_Id": "6bb1519686984d74ab200c925b9a3676" + } + ], + "synonyms": [ + "world", + "tangent", + "object", + "view", + "screen", + "convert" + ], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + }, + "m_Conversion": { + "from": 2, + "to": 4 + }, + "m_ConversionType": 0, + "m_Normalize": false +} + +{ + "m_SGVersion": 1, + "m_Type": "UnityEditor.ShaderGraph.OldTransformNode", + "m_ObjectId": "df18f46740a84dab99307b542e7e9102", + "m_Group": { + "m_Id": "" + }, + "m_Name": "OldTransform", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": -1570.0, + "y": -160.99998474121095, + "width": 213.0, + "height": 341.0 + } + }, + "m_Slots": [ + { + "m_Id": "b8a878cba4724959b9edf1199fa01fd7" + }, + { + "m_Id": "a0079a38ddea4edca79008d23399c5b1" + } + ], + "synonyms": [ + "world", + "tangent", + "object", + "view", + "screen", + "convert" + ], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + }, + "m_Conversion": { + "from": 3, + "to": 0 + }, + "m_ConversionType": 0 +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicValueMaterialSlot", + "m_ObjectId": "df63aca4443847ec96ffc346ffd297b7", + "m_Id": 1, + "m_DisplayName": "B", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "B", + "m_StageCapability": 3, + "m_Value": { + "e00": 200.0, + "e01": 200.0, + "e02": 200.0, + "e03": 2.0, + "e10": 2.0, + "e11": 2.0, + "e12": 2.0, + "e13": 2.0, + "e20": 2.0, + "e21": 2.0, + "e22": 2.0, + "e23": 2.0, + "e30": 2.0, + "e31": 2.0, + "e32": 2.0, + "e33": 2.0 + }, + "m_DefaultValue": { + "e00": 1.0, + "e01": 0.0, + "e02": 0.0, + "e03": 0.0, + "e10": 0.0, + "e11": 1.0, + "e12": 0.0, + "e13": 0.0, + "e20": 0.0, + "e21": 0.0, + "e22": 1.0, + "e23": 0.0, + "e30": 0.0, + "e31": 0.0, + "e32": 0.0, + "e33": 1.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.Vector3MaterialSlot", + "m_ObjectId": "e52abb26e3ba40958f14752a649a892c", + "m_Id": 0, + "m_DisplayName": "In", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "In", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_Labels": [] +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.AbsoluteNode", + "m_ObjectId": "fa72769f37e54f599d367774a779d845", + "m_Group": { + "m_Id": "" + }, + "m_Name": "Absolute", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": -1104.0, + "y": 3.0000650882720949, + "width": 207.9998779296875, + "height": 278.0 + } + }, + "m_Slots": [ + { + "m_Id": "76d15710128b4ba5a42566d71f242c7e" + }, + { + "m_Id": "6286951a44ca42e8adf651ceec17a756" + } + ], + "synonyms": [ + "positive" + ], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.BlockNode", + "m_ObjectId": "fc28a5ef65284ed0967870ff69516ffe", + "m_Group": { + "m_Id": "" + }, + "m_Name": "VertexDescription.Position", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": 0.0, + "y": 0.0, + "width": 0.0, + "height": 0.0 + } + }, + "m_Slots": [ + { + "m_Id": "fc66c175daa9462fa1430c43a99d7698" + } + ], + "synonyms": [], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + }, + "m_SerializedDescriptor": "VertexDescription.Position" +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.PositionMaterialSlot", + "m_ObjectId": "fc66c175daa9462fa1430c43a99d7698", + "m_Id": 0, + "m_DisplayName": "Position", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "Position", + "m_StageCapability": 1, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_Labels": [], + "m_Space": 0 +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "fefaeb0050de4b00a9a812607dec2e12", + "m_Id": 1, + "m_DisplayName": "B", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "B", + "m_StageCapability": 3, + "m_Value": { + "x": 1.0, + "y": 0.0, + "z": 0.0, + "w": 1.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + diff --git a/TestProjects/ShaderGraph/Assets/CommonAssets/Graphs/TransformGraph.shadergraph.meta b/TestProjects/ShaderGraph/Assets/CommonAssets/Graphs/TransformGraph.shadergraph.meta new file mode 100644 index 00000000000..5ea92803467 --- /dev/null +++ b/TestProjects/ShaderGraph/Assets/CommonAssets/Graphs/TransformGraph.shadergraph.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 11db3ab64fa437d448ed346df5754a16 +ScriptedImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 2 + userData: + assetBundleName: + assetBundleVariant: + script: {fileID: 11500000, guid: 625f186215c104763be7675aa2d941aa, type: 3} From 78845c7342619597bbe837e1baed5ba5073c5b57 Mon Sep 17 00:00:00 2001 From: Chris Tchou Date: Mon, 27 Sep 2021 10:15:55 -0700 Subject: [PATCH 10/23] fix for HDRP compile --- .../Material/ShaderGraph/DiffusionProfilePropertyDrawer.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/DiffusionProfilePropertyDrawer.cs b/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/DiffusionProfilePropertyDrawer.cs index 9d47aab3edb..ede57af4505 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/DiffusionProfilePropertyDrawer.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/DiffusionProfilePropertyDrawer.cs @@ -49,6 +49,8 @@ public VisualElement DrawProperty(PropertyInfo propertyInfo, object actualObject attribute.labelName, out var propertyVisualElement); } + + void IPropertyDrawer.DisposePropertyDrawer() { } } [CustomPropertyDrawer(typeof(DiffusionProfileSettings))] From b6165a93bf8d0ba5f452d993f0350d54d61b4f32 Mon Sep 17 00:00:00 2001 From: Chris Tchou Date: Mon, 27 Sep 2021 11:49:56 -0700 Subject: [PATCH 11/23] adding image artifacts for failures --- .../Assets/CommonAssets/Editor/NodeTests.cs | 8 ++--- .../Editor/ShaderGraphTestRenderer.cs | 31 ++++++++++++++++++- 2 files changed, 34 insertions(+), 5 deletions(-) diff --git a/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/NodeTests.cs b/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/NodeTests.cs index d68d73a9baf..9fd43db53dc 100644 --- a/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/NodeTests.cs +++ b/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/NodeTests.cs @@ -39,8 +39,8 @@ public IEnumerator TransformV1MatchesOldTransform() int incorrectPixels = ShaderGraphTestRenderer.CountPixelsNotEqual(target, new Color32(0, 255, 0, 255), false); Assert.AreEqual(128*128, incorrectPixels, "Number of incorrect pixels was not zero: initial state"); - //if (incorrectPixels != 0) - // TestUtils.SaveToPNG(target, "Assets/CommonAssets/Graphs/TransformGraph.png"); + if (incorrectPixels != 128 * 123) + ShaderGraphTestRenderer.SaveToPNG(target, "test-results/NodeTests/TransformNodeOld_default.png"); RenderTexture.ReleaseTemporary(target); yield return null; @@ -77,8 +77,8 @@ public IEnumerator TransformV1MatchesOldTransform() int incorrectPixels = ShaderGraphTestRenderer.CountPixelsNotEqual(target, new Color32(0, 255, 0, 255), false); Assert.AreEqual(0, incorrectPixels, $"Number of incorrect pixels was not zero: {source} to {dest} ({conversionType})"); - //if (incorrectPixels != 0) - // TestUtils.SaveToPNG(target, "Assets/CommonAssets/Graphs/TransformGraph.png"); + if (incorrectPixels != 0) + ShaderGraphTestRenderer.SaveToPNG(target, $"test-results/NodeTests/TransformNodeOld_{source}_to_{dest}_{conversionType}.png"); RenderTexture.ReleaseTemporary(target); } diff --git a/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/ShaderGraphTestRenderer.cs b/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/ShaderGraphTestRenderer.cs index 405fd6c5dd1..32e8ad8d069 100644 --- a/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/ShaderGraphTestRenderer.cs +++ b/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/ShaderGraphTestRenderer.cs @@ -57,8 +57,37 @@ internal static void RenderMeshWithMaterial(Camera cam, Mesh mesh, Matrix4x4 tra ShaderUtil.allowAsyncCompilation = wasAsyncAllowed; } - internal static void SaveToPNG(RenderTexture target, string path) + internal static void CreateDirectoriesForFilePath(string systemFilePath) { + var dirPath = Path.GetDirectoryName(systemFilePath); + CreateDirectories(dirPath); + } + + internal static void CreateDirectories(string systemDirectoryPath) + { + //var systemDirectory = Application.dataPath + "/../" + directoryPath; + Directory.CreateDirectory(systemDirectoryPath); + /* + var dirs = directoryPath.Split('/'); + string curpath = string.Empty; + foreach (var dir in dirs) + { + var parentPath = curpath; + curpath = curpath + dir; + if (!UnityEditor.AssetDatabase.IsValidFolder(curpath)) + { + AssetDatabase.CreateFolder(parentPath, dir); + } + curpath = curpath + '/'; + } + */ + } + + internal static void SaveToPNG(RenderTexture target, string path, bool createDirectory = true) + { + if (createDirectory) + CreateDirectoriesForFilePath(path); + Texture2D temp = new Texture2D(target.width, target.height, TextureFormat.RGBA32, mipChain: false, linear: false); var previousRenderTexture = RenderTexture.active; From 04d7364243624b5d087cb225e5c8ef444c081ec2 Mon Sep 17 00:00:00 2001 From: Chris Tchou Date: Mon, 27 Sep 2021 12:39:50 -0700 Subject: [PATCH 12/23] Testing artifact generation --- .../Assets/CommonAssets/Editor/NodeTests.cs | 20 ++++++++++++------- .../Editor/ShaderGraphTestRenderer.cs | 1 + 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/NodeTests.cs b/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/NodeTests.cs index 9fd43db53dc..135809cd822 100644 --- a/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/NodeTests.cs +++ b/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/NodeTests.cs @@ -13,6 +13,8 @@ namespace UnityEditor.ShaderGraph.UnitTests { class NodeTests { + const int res = 128; + [UnityTest] public IEnumerator TransformV1MatchesOldTransform() { @@ -30,16 +32,18 @@ public IEnumerator TransformV1MatchesOldTransform() // first check that it renders red in the initial state, to check that the test works // (graph is initially set up with non-matching transforms) { - RenderTextureDescriptor descriptor = new RenderTextureDescriptor(128, 128, GraphicsFormat.R8G8B8A8_SRGB, depthBufferBits: 32); + RenderTextureDescriptor descriptor = new RenderTextureDescriptor(res, res, GraphicsFormat.R8G8B8A8_SRGB, depthBufferBits: 32); var target = RenderTexture.GetTemporary(descriptor); // use a non-standard transform, so that view, object, etc. transforms are non trivial renderer.RenderQuadPreview(graph, target, new Vector3(1.24699998f, 1.51900005f, 0.328999996f), new Quaternion(-0.164710045f, -0.0826543793f, -0.220811233f, 0.957748055f), useSRP: true); int incorrectPixels = ShaderGraphTestRenderer.CountPixelsNotEqual(target, new Color32(0, 255, 0, 255), false); - Assert.AreEqual(128*128, incorrectPixels, "Number of incorrect pixels was not zero: initial state"); + Debug.Log($"Initial state: {target.width}x{target.height} Failing pixels: {incorrectPixels}"); + + Assert.AreEqual(res * res, incorrectPixels, $"Initial state should have {res * res} failing pixels"); - if (incorrectPixels != 128 * 123) + if (incorrectPixels != res * res) ShaderGraphTestRenderer.SaveToPNG(target, "test-results/NodeTests/TransformNodeOld_default.png"); RenderTexture.ReleaseTemporary(target); @@ -66,7 +70,7 @@ public IEnumerator TransformV1MatchesOldTransform() old.conversion = new CoordinateSpaceConversion(source, dest); old.conversionType = conversionType; - RenderTextureDescriptor descriptor = new RenderTextureDescriptor(128, 128, GraphicsFormat.R8G8B8A8_SRGB, depthBufferBits: 32); + RenderTextureDescriptor descriptor = new RenderTextureDescriptor(res, res, GraphicsFormat.R8G8B8A8_SRGB, depthBufferBits: 32); var target = RenderTexture.GetTemporary(descriptor); // Debug.Log($"Tested: {source} to {dest} ({conversionType})"); @@ -75,10 +79,12 @@ public IEnumerator TransformV1MatchesOldTransform() renderer.RenderQuadPreview(graph, target, new Vector3(1.24699998f, 1.51900005f, 4.328999996f), new Quaternion(-0.164710045f, -0.0826543793f, -0.220811233f, 0.957748055f), useSRP: true); int incorrectPixels = ShaderGraphTestRenderer.CountPixelsNotEqual(target, new Color32(0, 255, 0, 255), false); - Assert.AreEqual(0, incorrectPixels, $"Number of incorrect pixels was not zero: {source} to {dest} ({conversionType})"); + Debug.Log($"{source} to {dest} ({conversionType}: {target.width}x{target.height} Failing pixels: {incorrectPixels}"); + + Assert.AreEqual(0, incorrectPixels, $"Incorrect pixels detected: {source} to {dest} ({conversionType})"); - if (incorrectPixels != 0) - ShaderGraphTestRenderer.SaveToPNG(target, $"test-results/NodeTests/TransformNodeOld_{source}_to_{dest}_{conversionType}.png"); + // if (incorrectPixels != 0) + ShaderGraphTestRenderer.SaveToPNG(target, $"test-results/NodeTests/TransformNodeOld_{source}_to_{dest}_{conversionType}.png"); RenderTexture.ReleaseTemporary(target); } diff --git a/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/ShaderGraphTestRenderer.cs b/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/ShaderGraphTestRenderer.cs index 32e8ad8d069..97eba70298c 100644 --- a/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/ShaderGraphTestRenderer.cs +++ b/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/ShaderGraphTestRenderer.cs @@ -114,6 +114,7 @@ internal static int CountPixelsNotEqual(RenderTexture target, Color32 value, boo int mismatchCount = 0; var pixels = temp.GetPixels32(0); + Debug.Log($"Checking {pixels.Length} pixels"); foreach (var pixel in pixels) { if ((pixel.r != value.r) || From a70b11777af15e28936c221a5caae59b5ea72813 Mon Sep 17 00:00:00 2001 From: Chris Tchou Date: Mon, 27 Sep 2021 14:15:52 -0700 Subject: [PATCH 13/23] Added expected and actual images --- .../Assets/CommonAssets/Editor/NodeTests.cs | 18 +- .../Editor/ShaderGraphTestRenderer.cs | 21 +- .../Graphs/TransformGraph.shadergraph | 741 ++++++++++++++++-- 3 files changed, 722 insertions(+), 58 deletions(-) diff --git a/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/NodeTests.cs b/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/NodeTests.cs index 135809cd822..8d461a29836 100644 --- a/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/NodeTests.cs +++ b/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/NodeTests.cs @@ -41,11 +41,11 @@ public IEnumerator TransformV1MatchesOldTransform() int incorrectPixels = ShaderGraphTestRenderer.CountPixelsNotEqual(target, new Color32(0, 255, 0, 255), false); Debug.Log($"Initial state: {target.width}x{target.height} Failing pixels: {incorrectPixels}"); - Assert.AreEqual(res * res, incorrectPixels, $"Initial state should have {res * res} failing pixels"); - if (incorrectPixels != res * res) ShaderGraphTestRenderer.SaveToPNG(target, "test-results/NodeTests/TransformNodeOld_default.png"); + Assert.AreEqual(res * res, incorrectPixels, $"Initial state should have {res * res} failing pixels"); + RenderTexture.ReleaseTemporary(target); yield return null; } @@ -81,10 +81,18 @@ public IEnumerator TransformV1MatchesOldTransform() int incorrectPixels = ShaderGraphTestRenderer.CountPixelsNotEqual(target, new Color32(0, 255, 0, 255), false); Debug.Log($"{source} to {dest} ({conversionType}: {target.width}x{target.height} Failing pixels: {incorrectPixels}"); - Assert.AreEqual(0, incorrectPixels, $"Incorrect pixels detected: {source} to {dest} ({conversionType})"); + if (incorrectPixels != 0) + { + ShaderGraphTestRenderer.SaveToPNG(target, $"test-results/NodeTests/TransformNodeOld_{source}_to_{dest}_{conversionType}.png"); + + renderer.RenderQuadPreview(graph, target, new Vector3(1.24699998f, 1.51900005f, 4.328999996f), new Quaternion(-0.164710045f, -0.0826543793f, -0.220811233f, 0.957748055f), useSRP: true, ShaderGraphTestRenderer.Mode.EXPECTED); + ShaderGraphTestRenderer.SaveToPNG(target, $"test-results/NodeTests/TransformNodeOld_{source}_to_{dest}_{conversionType}_EXPECTED.png"); - // if (incorrectPixels != 0) - ShaderGraphTestRenderer.SaveToPNG(target, $"test-results/NodeTests/TransformNodeOld_{source}_to_{dest}_{conversionType}.png"); + renderer.RenderQuadPreview(graph, target, new Vector3(1.24699998f, 1.51900005f, 4.328999996f), new Quaternion(-0.164710045f, -0.0826543793f, -0.220811233f, 0.957748055f), useSRP: true, ShaderGraphTestRenderer.Mode.ACTUAL); + ShaderGraphTestRenderer.SaveToPNG(target, $"test-results/NodeTests/TransformNodeOld_{source}_to_{dest}_{conversionType}_ACTUAL.png"); + } + + Assert.AreEqual(0, incorrectPixels, $"Incorrect pixels detected: {source} to {dest} ({conversionType})"); RenderTexture.ReleaseTemporary(target); } diff --git a/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/ShaderGraphTestRenderer.cs b/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/ShaderGraphTestRenderer.cs index 97eba70298c..9e8e225c298 100644 --- a/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/ShaderGraphTestRenderer.cs +++ b/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/ShaderGraphTestRenderer.cs @@ -136,7 +136,22 @@ internal void RenderQuadPreview(GraphData graph, RenderTexture target, bool useS RenderQuadPreview(graph, target, Vector3.zero, Quaternion.identity, useSRP); } - internal void RenderQuadPreview(GraphData graph, RenderTexture target, Vector3 scenePosition, Quaternion sceneRotation, bool useSRP = false) + internal enum Mode + { + COMPARE, + EXPECTED, + ACTUAL + } + + void SetKeyword(Material mat, string keyword, bool enabled) + { + if (enabled) + mat.EnableKeyword(keyword); + else + mat.DisableKeyword(keyword); + } + + internal void RenderQuadPreview(GraphData graph, RenderTexture target, Vector3 scenePosition, Quaternion sceneRotation, bool useSRP = false, Mode mode = Mode.COMPARE) { var camXform = previewScene.camera.transform; @@ -154,6 +169,10 @@ internal void RenderQuadPreview(GraphData graph, RenderTexture target, Vector3 s var shader = BuildShaderGraph(graph, "Test Shader"); var mat = new Material(shader) { hideFlags = HideFlags.HideAndDontSave }; + SetKeyword(mat, "_MODE_COMPARE", (mode == Mode.COMPARE)); + SetKeyword(mat, "_MODE_EXPECTED", (mode == Mode.EXPECTED)); + SetKeyword(mat, "_MODE_ACTUAL", (mode == Mode.ACTUAL)); + var quadMatrix = Matrix4x4.TRS(camXform.position + camXform.forward * 2, camXform.rotation, Vector3.one); // render with it diff --git a/TestProjects/ShaderGraph/Assets/CommonAssets/Graphs/TransformGraph.shadergraph b/TestProjects/ShaderGraph/Assets/CommonAssets/Graphs/TransformGraph.shadergraph index 2df09b9086e..2a66e87a8c8 100644 --- a/TestProjects/ShaderGraph/Assets/CommonAssets/Graphs/TransformGraph.shadergraph +++ b/TestProjects/ShaderGraph/Assets/CommonAssets/Graphs/TransformGraph.shadergraph @@ -3,7 +3,11 @@ "m_Type": "UnityEditor.ShaderGraph.GraphData", "m_ObjectId": "d3a578d5f6c048d989f4fc22763a096c", "m_Properties": [], - "m_Keywords": [], + "m_Keywords": [ + { + "m_Id": "1bd0bd2d8a644a369163cb727342c308" + } + ], "m_Dropdowns": [], "m_CategoryData": [ { @@ -52,6 +56,21 @@ }, { "m_Id": "1746ecad396f45c2808181de7c16ab2d" + }, + { + "m_Id": "907dd0a26f124143bbc87326f74c2f54" + }, + { + "m_Id": "54d1e21495064ae8982ce8365d45d873" + }, + { + "m_Id": "3f4fe83ebf4a492c8bd4bd8d039d4e4e" + }, + { + "m_Id": "ffde04b05e2c42f38093d4ddd027315b" + }, + { + "m_Id": "6dc28149a6e2450a9b06b18a139d8695" } ], "m_GroupDatas": [], @@ -85,6 +104,62 @@ "m_SlotId": 1 } }, + { + "m_OutputSlot": { + "m_Node": { + "m_Id": "3f4fe83ebf4a492c8bd4bd8d039d4e4e" + }, + "m_SlotId": 1 + }, + "m_InputSlot": { + "m_Node": { + "m_Id": "907dd0a26f124143bbc87326f74c2f54" + }, + "m_SlotId": 2 + } + }, + { + "m_OutputSlot": { + "m_Node": { + "m_Id": "54d1e21495064ae8982ce8365d45d873" + }, + "m_SlotId": 1 + }, + "m_InputSlot": { + "m_Node": { + "m_Id": "907dd0a26f124143bbc87326f74c2f54" + }, + "m_SlotId": 1 + } + }, + { + "m_OutputSlot": { + "m_Node": { + "m_Id": "6dc28149a6e2450a9b06b18a139d8695" + }, + "m_SlotId": 1 + }, + "m_InputSlot": { + "m_Node": { + "m_Id": "54d1e21495064ae8982ce8365d45d873" + }, + "m_SlotId": 0 + } + }, + { + "m_OutputSlot": { + "m_Node": { + "m_Id": "907dd0a26f124143bbc87326f74c2f54" + }, + "m_SlotId": 0 + }, + "m_InputSlot": { + "m_Node": { + "m_Id": "65611bc2ea7845359ab31d44dd0816ab" + }, + "m_SlotId": 0 + } + }, { "m_OutputSlot": { "m_Node": { @@ -108,9 +183,9 @@ }, "m_InputSlot": { "m_Node": { - "m_Id": "65611bc2ea7845359ab31d44dd0816ab" + "m_Id": "907dd0a26f124143bbc87326f74c2f54" }, - "m_SlotId": 0 + "m_SlotId": 4 } }, { @@ -183,6 +258,34 @@ "m_SlotId": 1 } }, + { + "m_OutputSlot": { + "m_Node": { + "m_Id": "de1092b024884fdf9e8a5171a48ef13e" + }, + "m_SlotId": 1 + }, + "m_InputSlot": { + "m_Node": { + "m_Id": "ffde04b05e2c42f38093d4ddd027315b" + }, + "m_SlotId": 0 + } + }, + { + "m_OutputSlot": { + "m_Node": { + "m_Id": "df18f46740a84dab99307b542e7e9102" + }, + "m_SlotId": 1 + }, + "m_InputSlot": { + "m_Node": { + "m_Id": "6dc28149a6e2450a9b06b18a139d8695" + }, + "m_SlotId": 0 + } + }, { "m_OutputSlot": { "m_Node": { @@ -210,12 +313,26 @@ }, "m_SlotId": 0 } + }, + { + "m_OutputSlot": { + "m_Node": { + "m_Id": "ffde04b05e2c42f38093d4ddd027315b" + }, + "m_SlotId": 1 + }, + "m_InputSlot": { + "m_Node": { + "m_Id": "3f4fe83ebf4a492c8bd4bd8d039d4e4e" + }, + "m_SlotId": 0 + } } ], "m_VertexContext": { "m_Position": { - "x": -150.0001220703125, - "y": -286.99993896484377 + "x": 362.00006103515627, + "y": -291.0 }, "m_Blocks": [ { @@ -231,8 +348,8 @@ }, "m_FragmentContext": { "m_Position": { - "x": -150.0001220703125, - "y": -86.9999771118164 + "x": 362.00006103515627, + "y": -91.0 }, "m_Blocks": [ { @@ -260,6 +377,54 @@ ] } +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "07748643054049eea2a69011501a6a15", + "m_Id": 1, + "m_DisplayName": "Out", + "m_SlotType": 1, + "m_Hidden": false, + "m_ShaderOutputName": "Out", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "0e02596103584467b3f08ceaeeea231e", + "m_Id": 4, + "m_DisplayName": "COMPARE", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "COMPARE", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + { "m_SGVersion": 0, "m_Type": "UnityEditor.ShaderGraph.SaturateNode", @@ -297,6 +462,70 @@ } } +{ + "m_SGVersion": 1, + "m_Type": "UnityEditor.ShaderGraph.ShaderKeyword", + "m_ObjectId": "1bd0bd2d8a644a369163cb727342c308", + "m_Guid": { + "m_GuidSerialized": "7a8918ce-9570-4947-b06a-6445703e6938" + }, + "m_Name": "MODE", + "m_DefaultRefNameVersion": 1, + "m_RefNameGeneratedByDisplayName": "MODE", + "m_DefaultReferenceName": "_MODE", + "m_OverrideReferenceName": "", + "m_GeneratePropertyBlock": true, + "m_UseCustomSlotLabel": false, + "m_CustomSlotLabel": "", + "m_KeywordType": 1, + "m_KeywordDefinition": 0, + "m_KeywordScope": 0, + "m_KeywordStages": 63, + "m_Entries": [ + { + "id": 4, + "displayName": "COMPARE", + "referenceName": "COMPARE" + }, + { + "id": 1, + "displayName": "EXPECTED", + "referenceName": "EXPECTED" + }, + { + "id": 2, + "displayName": "ACTUAL", + "referenceName": "ACTUAL" + } + ], + "m_Value": 0, + "m_IsEditable": true +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "1d11b6b53cef4b47869bbb766c74c0ea", + "m_Id": 0, + "m_DisplayName": "In", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "In", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + { "m_SGVersion": 1, "m_Type": "UnityEditor.Rendering.Universal.ShaderGraph.UniversalTarget", @@ -380,6 +609,30 @@ } } +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "34ee9d276de1426ea3815b3e26e80564", + "m_Id": 1, + "m_DisplayName": "", + "m_SlotType": 1, + "m_Hidden": false, + "m_ShaderOutputName": "", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + { "m_SGVersion": 0, "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", @@ -415,73 +668,219 @@ "m_ShaderOutputName": "BaseColor", "m_StageCapability": 2, "m_Value": { - "x": 0.5, - "y": 0.5, - "z": 0.5 + "x": 0.5, + "y": 0.5, + "z": 0.5 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_Labels": [], + "m_ColorMode": 0, + "m_DefaultColor": { + "r": 0.5, + "g": 0.5, + "b": 0.5, + "a": 1.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.BlockNode", + "m_ObjectId": "3ec2632bb2694b7699d26c257e2879ea", + "m_Group": { + "m_Id": "" + }, + "m_Name": "VertexDescription.Tangent", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": 0.0, + "y": 0.0, + "width": 0.0, + "height": 0.0 + } + }, + "m_Slots": [ + { + "m_Id": "628ef29e9b5d447e9caa4531bcbe6b10" + } + ], + "synonyms": [], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + }, + "m_SerializedDescriptor": "VertexDescription.Tangent" +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.AbsoluteNode", + "m_ObjectId": "3f4fe83ebf4a492c8bd4bd8d039d4e4e", + "m_Group": { + "m_Id": "" + }, + "m_Name": "Absolute", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": -113.00003051757813, + "y": 363.0000915527344, + "width": 132.0000457763672, + "height": 93.9998779296875 + } + }, + "m_Slots": [ + { + "m_Id": "1d11b6b53cef4b47869bbb766c74c0ea" + }, + { + "m_Id": "07748643054049eea2a69011501a6a15" + } + ], + "synonyms": [ + "positive" + ], + "m_Precision": 0, + "m_PreviewExpanded": false, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.Rendering.Universal.ShaderGraph.UniversalUnlitSubTarget", + "m_ObjectId": "416b95b32d794f768b76ab713d607602" +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "42ed096a23f0457eab55df8305100690", + "m_Id": 0, + "m_DisplayName": "Out", + "m_SlotType": 1, + "m_Hidden": false, + "m_ShaderOutputName": "Out", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "44ff4c8e37d149f0a0ea59d40128711c", + "m_Id": 2, + "m_DisplayName": "T", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "T", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "50f3802c0e1d464abca40855381706b0", + "m_Id": 1, + "m_DisplayName": "", + "m_SlotType": 1, + "m_Hidden": false, + "m_ShaderOutputName": "", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 }, "m_DefaultValue": { "x": 0.0, "y": 0.0, - "z": 0.0 - }, - "m_Labels": [], - "m_ColorMode": 0, - "m_DefaultColor": { - "r": 0.5, - "g": 0.5, - "b": 0.5, - "a": 1.0 + "z": 0.0, + "w": 0.0 } } { "m_SGVersion": 0, - "m_Type": "UnityEditor.ShaderGraph.BlockNode", - "m_ObjectId": "3ec2632bb2694b7699d26c257e2879ea", + "m_Type": "UnityEditor.ShaderGraph.AbsoluteNode", + "m_ObjectId": "54d1e21495064ae8982ce8365d45d873", "m_Group": { "m_Id": "" }, - "m_Name": "VertexDescription.Tangent", + "m_Name": "Absolute", "m_DrawState": { "m_Expanded": true, "m_Position": { "serializedVersion": "2", - "x": 0.0, - "y": 0.0, - "width": 0.0, - "height": 0.0 + "x": -113.00003051757813, + "y": -294.9999694824219, + "width": 132.0000457763672, + "height": 94.00001525878906 } }, "m_Slots": [ { - "m_Id": "628ef29e9b5d447e9caa4531bcbe6b10" + "m_Id": "c87f1f151ea74a4995743a525e3f011b" + }, + { + "m_Id": "8331dcbe952448e3b4cf2b6523349985" } ], - "synonyms": [], + "synonyms": [ + "positive" + ], "m_Precision": 0, - "m_PreviewExpanded": true, + "m_PreviewExpanded": false, "m_PreviewMode": 0, "m_CustomColors": { "m_SerializableColors": [] - }, - "m_SerializedDescriptor": "VertexDescription.Tangent" -} - -{ - "m_SGVersion": 0, - "m_Type": "UnityEditor.Rendering.Universal.ShaderGraph.UniversalUnlitSubTarget", - "m_ObjectId": "416b95b32d794f768b76ab713d607602" + } } { "m_SGVersion": 0, "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", - "m_ObjectId": "44ff4c8e37d149f0a0ea59d40128711c", - "m_Id": 2, - "m_DisplayName": "T", - "m_SlotType": 0, + "m_ObjectId": "54f4946a07ec470ab8eec9a158a27258", + "m_Id": 3, + "m_DisplayName": "Out", + "m_SlotType": 1, "m_Hidden": false, - "m_ShaderOutputName": "T", + "m_ShaderOutputName": "Out", "m_StageCapability": 3, "m_Value": { "x": 0.0, @@ -500,12 +899,12 @@ { "m_SGVersion": 0, "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", - "m_ObjectId": "54f4946a07ec470ab8eec9a158a27258", - "m_Id": 3, - "m_DisplayName": "Out", - "m_SlotType": 1, + "m_ObjectId": "5743e9b1804044f38daa56bd9f883145", + "m_Id": 0, + "m_DisplayName": "", + "m_SlotType": 0, "m_Hidden": false, - "m_ShaderOutputName": "Out", + "m_ShaderOutputName": "", "m_StageCapability": 3, "m_Value": { "x": 0.0, @@ -697,6 +1096,41 @@ "m_Labels": [] } +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.RedirectNodeData", + "m_ObjectId": "6dc28149a6e2450a9b06b18a139d8695", + "m_Group": { + "m_Id": "" + }, + "m_Name": "Redirect Node", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": -1312.0001220703125, + "y": -247.9999542236328, + "width": 56.0001220703125, + "height": 23.999984741210939 + } + }, + "m_Slots": [ + { + "m_Id": "5743e9b1804044f38daa56bd9f883145" + }, + { + "m_Id": "50f3802c0e1d464abca40855381706b0" + } + ], + "synonyms": [], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + } +} + { "m_SGVersion": 0, "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", @@ -774,7 +1208,35 @@ "m_Type": "UnityEditor.ShaderGraph.CategoryData", "m_ObjectId": "82645ecd662c4d88a7de4083a8e5b53c", "m_Name": "", - "m_ChildObjectList": [] + "m_ChildObjectList": [ + { + "m_Id": "1bd0bd2d8a644a369163cb727342c308" + } + ] +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "8331dcbe952448e3b4cf2b6523349985", + "m_Id": 1, + "m_DisplayName": "Out", + "m_SlotType": 1, + "m_Hidden": false, + "m_ShaderOutputName": "Out", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } } { @@ -800,6 +1262,50 @@ "m_Labels": [] } +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.KeywordNode", + "m_ObjectId": "907dd0a26f124143bbc87326f74c2f54", + "m_Group": { + "m_Id": "" + }, + "m_Name": "MODE", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": 126.99999237060547, + "y": -91.0, + "width": 208.00003051757813, + "height": 326.0 + } + }, + "m_Slots": [ + { + "m_Id": "42ed096a23f0457eab55df8305100690" + }, + { + "m_Id": "0e02596103584467b3f08ceaeeea231e" + }, + { + "m_Id": "aec17fc7875a44f38f7d9153cf74f50f" + }, + { + "m_Id": "994474eebdcf4c66a55e6ac3838b66ce" + } + ], + "synonyms": [], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + }, + "m_Keyword": { + "m_Id": "1bd0bd2d8a644a369163cb727342c308" + } +} + { "m_SGVersion": 0, "m_Type": "UnityEditor.ShaderGraph.BlockNode", @@ -833,6 +1339,30 @@ "m_SerializedDescriptor": "VertexDescription.Normal" } +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "994474eebdcf4c66a55e6ac3838b66ce", + "m_Id": 2, + "m_DisplayName": "ACTUAL", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "ACTUAL", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + { "m_SGVersion": 0, "m_Type": "UnityEditor.ShaderGraph.ScreenPositionNode", @@ -962,6 +1492,30 @@ "m_Labels": [] } +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "aec17fc7875a44f38f7d9153cf74f50f", + "m_Id": 1, + "m_DisplayName": "EXPECTED", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "EXPECTED", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + { "m_SGVersion": 0, "m_Type": "UnityEditor.ShaderGraph.LerpNode", @@ -974,10 +1528,10 @@ "m_Expanded": true, "m_Position": { "serializedVersion": "2", - "x": -404.0000305175781, - "y": -90.99991607666016, - "width": 207.9999237060547, - "height": 325.9999084472656 + "x": -321.0, + "y": -86.99998474121094, + "width": 207.99998474121095, + "height": 326.0 } }, "m_Slots": [ @@ -1150,6 +1704,30 @@ } } +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "c87f1f151ea74a4995743a525e3f011b", + "m_Id": 0, + "m_DisplayName": "In", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "In", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + { "m_SGVersion": 0, "m_Type": "UnityEditor.ShaderGraph.MultiplyNode", @@ -1533,6 +2111,30 @@ "m_Labels": [] } +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "e6aff6e4a9b14ff7827921e6353a87a3", + "m_Id": 0, + "m_DisplayName": "", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + { "m_SGVersion": 0, "m_Type": "UnityEditor.ShaderGraph.AbsoluteNode", @@ -1651,3 +2253,38 @@ } } +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.RedirectNodeData", + "m_ObjectId": "ffde04b05e2c42f38093d4ddd027315b", + "m_Group": { + "m_Id": "" + }, + "m_Name": "Redirect Node", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": -1286.0001220703125, + "y": 410.00006103515627, + "width": 56.0001220703125, + "height": 23.999969482421876 + } + }, + "m_Slots": [ + { + "m_Id": "e6aff6e4a9b14ff7827921e6353a87a3" + }, + { + "m_Id": "34ee9d276de1426ea3815b3e26e80564" + } + ], + "synonyms": [], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + } +} + From 2fe5f88b9261149dc9e85537a1362a47e4667f9f Mon Sep 17 00:00:00 2001 From: Chris Tchou Date: Tue, 28 Sep 2021 15:17:17 -0700 Subject: [PATCH 14/23] Always write all results so we can see what's happening on linux --- .../Assets/CommonAssets/Editor/NodeTests.cs | 15 +- .../Graphs/TransformGraph.shadergraph | 340 ++++++++---------- 2 files changed, 155 insertions(+), 200 deletions(-) diff --git a/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/NodeTests.cs b/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/NodeTests.cs index 8d461a29836..57936e49a86 100644 --- a/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/NodeTests.cs +++ b/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/NodeTests.cs @@ -15,6 +15,9 @@ class NodeTests { const int res = 128; + readonly Vector3 testPosition = new Vector3(0.24699998f, 0.51900005f, 0.328999996f); + readonly Quaternion testRotation = new Quaternion(-0.164710045f, -0.0826543793f, -0.220811233f, 0.957748055f); + [UnityTest] public IEnumerator TransformV1MatchesOldTransform() { @@ -36,7 +39,7 @@ public IEnumerator TransformV1MatchesOldTransform() var target = RenderTexture.GetTemporary(descriptor); // use a non-standard transform, so that view, object, etc. transforms are non trivial - renderer.RenderQuadPreview(graph, target, new Vector3(1.24699998f, 1.51900005f, 0.328999996f), new Quaternion(-0.164710045f, -0.0826543793f, -0.220811233f, 0.957748055f), useSRP: true); + renderer.RenderQuadPreview(graph, target, testPosition, testRotation, useSRP: true); int incorrectPixels = ShaderGraphTestRenderer.CountPixelsNotEqual(target, new Color32(0, 255, 0, 255), false); Debug.Log($"Initial state: {target.width}x{target.height} Failing pixels: {incorrectPixels}"); @@ -76,19 +79,19 @@ public IEnumerator TransformV1MatchesOldTransform() // Debug.Log($"Tested: {source} to {dest} ({conversionType})"); // use a non-standard transform, so that view, object, etc. transforms are non trivial - renderer.RenderQuadPreview(graph, target, new Vector3(1.24699998f, 1.51900005f, 4.328999996f), new Quaternion(-0.164710045f, -0.0826543793f, -0.220811233f, 0.957748055f), useSRP: true); + renderer.RenderQuadPreview(graph, target, testPosition, testRotation, useSRP: true); int incorrectPixels = ShaderGraphTestRenderer.CountPixelsNotEqual(target, new Color32(0, 255, 0, 255), false); Debug.Log($"{source} to {dest} ({conversionType}: {target.width}x{target.height} Failing pixels: {incorrectPixels}"); - if (incorrectPixels != 0) + // if (incorrectPixels != 0) { ShaderGraphTestRenderer.SaveToPNG(target, $"test-results/NodeTests/TransformNodeOld_{source}_to_{dest}_{conversionType}.png"); - renderer.RenderQuadPreview(graph, target, new Vector3(1.24699998f, 1.51900005f, 4.328999996f), new Quaternion(-0.164710045f, -0.0826543793f, -0.220811233f, 0.957748055f), useSRP: true, ShaderGraphTestRenderer.Mode.EXPECTED); + renderer.RenderQuadPreview(graph, target, testPosition, testRotation, useSRP: true, ShaderGraphTestRenderer.Mode.EXPECTED); ShaderGraphTestRenderer.SaveToPNG(target, $"test-results/NodeTests/TransformNodeOld_{source}_to_{dest}_{conversionType}_EXPECTED.png"); - renderer.RenderQuadPreview(graph, target, new Vector3(1.24699998f, 1.51900005f, 4.328999996f), new Quaternion(-0.164710045f, -0.0826543793f, -0.220811233f, 0.957748055f), useSRP: true, ShaderGraphTestRenderer.Mode.ACTUAL); + renderer.RenderQuadPreview(graph, target, testPosition, testRotation, useSRP: true, ShaderGraphTestRenderer.Mode.ACTUAL); ShaderGraphTestRenderer.SaveToPNG(target, $"test-results/NodeTests/TransformNodeOld_{source}_to_{dest}_{conversionType}_ACTUAL.png"); } @@ -99,7 +102,7 @@ public IEnumerator TransformV1MatchesOldTransform() // have to yield to let a frame pass // unity only releases some resources at the end of a frame - // and if you do too many renders in a frame it will run out + // and if you do too many renders in a frame it will run out yield return null; } } diff --git a/TestProjects/ShaderGraph/Assets/CommonAssets/Graphs/TransformGraph.shadergraph b/TestProjects/ShaderGraph/Assets/CommonAssets/Graphs/TransformGraph.shadergraph index 2a66e87a8c8..646424086d9 100644 --- a/TestProjects/ShaderGraph/Assets/CommonAssets/Graphs/TransformGraph.shadergraph +++ b/TestProjects/ShaderGraph/Assets/CommonAssets/Graphs/TransformGraph.shadergraph @@ -48,9 +48,6 @@ { "m_Id": "cd74f48ac90a40f49890cd16fbf6660a" }, - { - "m_Id": "213cc9f9f0b74151975715b4fdbcf045" - }, { "m_Id": "afd6fed3d8e8461c9ac141b19e55e04d" }, @@ -71,10 +68,17 @@ }, { "m_Id": "6dc28149a6e2450a9b06b18a139d8695" + }, + { + "m_Id": "49eb3060313949e8a29142442a4c029a" } ], "m_GroupDatas": [], - "m_StickyNoteDatas": [], + "m_StickyNoteDatas": [ + { + "m_Id": "ebeb58a811964ae1ae55c9969cd6e146" + } + ], "m_Edges": [ { "m_OutputSlot": { @@ -93,29 +97,29 @@ { "m_OutputSlot": { "m_Node": { - "m_Id": "213cc9f9f0b74151975715b4fdbcf045" + "m_Id": "3f4fe83ebf4a492c8bd4bd8d039d4e4e" }, - "m_SlotId": 2 + "m_SlotId": 1 }, "m_InputSlot": { "m_Node": { - "m_Id": "d7fc69d9fbd84fe5b18d4361e39b39b9" + "m_Id": "907dd0a26f124143bbc87326f74c2f54" }, - "m_SlotId": 1 + "m_SlotId": 2 } }, { "m_OutputSlot": { "m_Node": { - "m_Id": "3f4fe83ebf4a492c8bd4bd8d039d4e4e" + "m_Id": "49eb3060313949e8a29142442a4c029a" }, - "m_SlotId": 1 + "m_SlotId": 2 }, "m_InputSlot": { "m_Node": { - "m_Id": "907dd0a26f124143bbc87326f74c2f54" + "m_Id": "d7fc69d9fbd84fe5b18d4361e39b39b9" }, - "m_SlotId": 2 + "m_SlotId": 1 } }, { @@ -169,9 +173,9 @@ }, "m_InputSlot": { "m_Node": { - "m_Id": "213cc9f9f0b74151975715b4fdbcf045" + "m_Id": "49eb3060313949e8a29142442a4c029a" }, - "m_SlotId": 0 + "m_SlotId": 1 } }, { @@ -567,48 +571,6 @@ "m_Labels": [] } -{ - "m_SGVersion": 0, - "m_Type": "UnityEditor.ShaderGraph.MultiplyNode", - "m_ObjectId": "213cc9f9f0b74151975715b4fdbcf045", - "m_Group": { - "m_Id": "" - }, - "m_Name": "Multiply", - "m_DrawState": { - "m_Expanded": true, - "m_Position": { - "serializedVersion": "2", - "x": -2094.0, - "y": 3.0000247955322267, - "width": 207.9998779296875, - "height": 302.0 - } - }, - "m_Slots": [ - { - "m_Id": "b20ad9a9abab4ca7b92963d52bb19e94" - }, - { - "m_Id": "db571653035448e0990b13330fa88f31" - }, - { - "m_Id": "b9264fc783d44451961ace0b6ffac2b2" - } - ], - "synonyms": [ - "multiplication", - "times", - "x" - ], - "m_Precision": 0, - "m_PreviewExpanded": true, - "m_PreviewMode": 0, - "m_CustomColors": { - "m_SerializableColors": [] - } -} - { "m_SGVersion": 0, "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", @@ -811,6 +773,48 @@ } } +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.AddNode", + "m_ObjectId": "49eb3060313949e8a29142442a4c029a", + "m_Group": { + "m_Id": "" + }, + "m_Name": "Add", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": -2096.0, + "y": -41.99998474121094, + "width": 208.0, + "height": 303.00006103515627 + } + }, + "m_Slots": [ + { + "m_Id": "cee2261d7bcb4e288eb8e4171fa1e0b9" + }, + { + "m_Id": "c481840984234183a87b86bd85e4b13d" + }, + { + "m_Id": "6b856ac4f8634c3bae87e2ac66690f86" + } + ], + "synonyms": [ + "addition", + "sum", + "plus" + ], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + } +} + { "m_SGVersion": 0, "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", @@ -1073,6 +1077,30 @@ } } +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "6b856ac4f8634c3bae87e2ac66690f86", + "m_Id": 2, + "m_DisplayName": "Out", + "m_SlotType": 1, + "m_Hidden": false, + "m_ShaderOutputName": "Out", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + { "m_SGVersion": 0, "m_Type": "UnityEditor.ShaderGraph.Vector3MaterialSlot", @@ -1376,7 +1404,7 @@ "m_Position": { "serializedVersion": "2", "x": -2396.0, - "y": 3.0000007152557375, + "y": 24.000011444091798, "width": 208.0, "height": 313.0 } @@ -1561,54 +1589,6 @@ } } -{ - "m_SGVersion": 0, - "m_Type": "UnityEditor.ShaderGraph.DynamicValueMaterialSlot", - "m_ObjectId": "b20ad9a9abab4ca7b92963d52bb19e94", - "m_Id": 0, - "m_DisplayName": "A", - "m_SlotType": 0, - "m_Hidden": false, - "m_ShaderOutputName": "A", - "m_StageCapability": 3, - "m_Value": { - "e00": 0.0, - "e01": 0.0, - "e02": 0.0, - "e03": 0.0, - "e10": 0.0, - "e11": 0.0, - "e12": 0.0, - "e13": 0.0, - "e20": 0.0, - "e21": 0.0, - "e22": 0.0, - "e23": 0.0, - "e30": 0.0, - "e31": 0.0, - "e32": 0.0, - "e33": 0.0 - }, - "m_DefaultValue": { - "e00": 1.0, - "e01": 0.0, - "e02": 0.0, - "e03": 0.0, - "e10": 0.0, - "e11": 1.0, - "e12": 0.0, - "e13": 0.0, - "e20": 0.0, - "e21": 0.0, - "e22": 1.0, - "e23": 0.0, - "e30": 0.0, - "e31": 0.0, - "e32": 0.0, - "e33": 1.0 - } -} - { "m_SGVersion": 0, "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", @@ -1658,49 +1638,25 @@ { "m_SGVersion": 0, - "m_Type": "UnityEditor.ShaderGraph.DynamicValueMaterialSlot", - "m_ObjectId": "b9264fc783d44451961ace0b6ffac2b2", - "m_Id": 2, - "m_DisplayName": "Out", - "m_SlotType": 1, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "c481840984234183a87b86bd85e4b13d", + "m_Id": 1, + "m_DisplayName": "B", + "m_SlotType": 0, "m_Hidden": false, - "m_ShaderOutputName": "Out", + "m_ShaderOutputName": "B", "m_StageCapability": 3, "m_Value": { - "e00": 0.0, - "e01": 0.0, - "e02": 0.0, - "e03": 0.0, - "e10": 0.0, - "e11": 0.0, - "e12": 0.0, - "e13": 0.0, - "e20": 0.0, - "e21": 0.0, - "e22": 0.0, - "e23": 0.0, - "e30": 0.0, - "e31": 0.0, - "e32": 0.0, - "e33": 0.0 + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 }, "m_DefaultValue": { - "e00": 1.0, - "e01": 0.0, - "e02": 0.0, - "e03": 0.0, - "e10": 0.0, - "e11": 1.0, - "e12": 0.0, - "e13": 0.0, - "e20": 0.0, - "e21": 0.0, - "e22": 1.0, - "e23": 0.0, - "e30": 0.0, - "e31": 0.0, - "e32": 0.0, - "e33": 1.0 + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 } } @@ -1770,6 +1726,30 @@ } } +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "cee2261d7bcb4e288eb8e4171fa1e0b9", + "m_Id": 0, + "m_DisplayName": "A", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "A", + "m_StageCapability": 3, + "m_Value": { + "x": 0.5, + "y": 0.5, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + { "m_SGVersion": 0, "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", @@ -1873,9 +1853,9 @@ "m_Expanded": true, "m_Position": { "serializedVersion": "2", - "x": -1847.0, - "y": 3.0000650882720949, - "width": 208.0, + "x": -1847.0001220703125, + "y": 24.000011444091798, + "width": 208.0001220703125, "height": 313.0 } }, @@ -1897,54 +1877,6 @@ "m_HashType": 1 } -{ - "m_SGVersion": 0, - "m_Type": "UnityEditor.ShaderGraph.DynamicValueMaterialSlot", - "m_ObjectId": "db571653035448e0990b13330fa88f31", - "m_Id": 1, - "m_DisplayName": "B", - "m_SlotType": 0, - "m_Hidden": false, - "m_ShaderOutputName": "B", - "m_StageCapability": 3, - "m_Value": { - "e00": 2.0, - "e01": 2.0, - "e02": 0.0, - "e03": 0.0, - "e10": 2.0, - "e11": 2.0, - "e12": 2.0, - "e13": 2.0, - "e20": 2.0, - "e21": 2.0, - "e22": 2.0, - "e23": 2.0, - "e30": 2.0, - "e31": 2.0, - "e32": 2.0, - "e33": 2.0 - }, - "m_DefaultValue": { - "e00": 1.0, - "e01": 0.0, - "e02": 0.0, - "e03": 0.0, - "e10": 0.0, - "e11": 1.0, - "e12": 0.0, - "e13": 0.0, - "e20": 0.0, - "e21": 0.0, - "e22": 1.0, - "e23": 0.0, - "e30": 0.0, - "e31": 0.0, - "e32": 0.0, - "e33": 1.0 - } -} - { "m_SGVersion": 1, "m_Type": "UnityEditor.ShaderGraph.TransformNode", @@ -2135,6 +2067,26 @@ } } +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.StickyNoteData", + "m_ObjectId": "ebeb58a811964ae1ae55c9969cd6e146", + "m_Title": "Note", + "m_Content": "Since screen position is 0.5 centered, the round on the integer hash is sitting right on the boundary which is unstable.\nWe give it a bit of a push to one side to make sure it's deterministic.\n", + "m_TextSize": 0, + "m_Theme": 0, + "m_Position": { + "serializedVersion": "2", + "x": -2090.0, + "y": -217.0, + "width": 200.0, + "height": 172.0 + }, + "m_Group": { + "m_Id": "" + } +} + { "m_SGVersion": 0, "m_Type": "UnityEditor.ShaderGraph.AbsoluteNode", From 1136ada290b5ae6c1b58d3ffc3e8db27cd529a8c Mon Sep 17 00:00:00 2001 From: Chris Tchou Date: Tue, 28 Sep 2021 17:09:14 -0700 Subject: [PATCH 15/23] Removing debug code --- .../Assets/CommonAssets/Editor/NodeTests.cs | 19 ++++++++++++------- .../Editor/ShaderGraphTestRenderer.cs | 1 - 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/NodeTests.cs b/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/NodeTests.cs index 57936e49a86..dbd7280d6bd 100644 --- a/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/NodeTests.cs +++ b/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/NodeTests.cs @@ -42,7 +42,7 @@ public IEnumerator TransformV1MatchesOldTransform() renderer.RenderQuadPreview(graph, target, testPosition, testRotation, useSRP: true); int incorrectPixels = ShaderGraphTestRenderer.CountPixelsNotEqual(target, new Color32(0, 255, 0, 255), false); - Debug.Log($"Initial state: {target.width}x{target.height} Failing pixels: {incorrectPixels}"); + //Debug.Log($"Initial state: {target.width}x{target.height} Failing pixels: {incorrectPixels}"); if (incorrectPixels != res * res) ShaderGraphTestRenderer.SaveToPNG(target, "test-results/NodeTests/TransformNodeOld_default.png"); @@ -57,6 +57,9 @@ public IEnumerator TransformV1MatchesOldTransform() var old = graph.GetNodes().First(); // now check all possible settings + string assertString = null; + int assertIncorrectPixels = 0; + var oldConversionTypes = new ConversionType[] { ConversionType.Position, ConversionType.Direction }; foreach (ConversionType conversionType in oldConversionTypes) { @@ -76,16 +79,17 @@ public IEnumerator TransformV1MatchesOldTransform() RenderTextureDescriptor descriptor = new RenderTextureDescriptor(res, res, GraphicsFormat.R8G8B8A8_SRGB, depthBufferBits: 32); var target = RenderTexture.GetTemporary(descriptor); - // Debug.Log($"Tested: {source} to {dest} ({conversionType})"); - // use a non-standard transform, so that view, object, etc. transforms are non trivial renderer.RenderQuadPreview(graph, target, testPosition, testRotation, useSRP: true); int incorrectPixels = ShaderGraphTestRenderer.CountPixelsNotEqual(target, new Color32(0, 255, 0, 255), false); - Debug.Log($"{source} to {dest} ({conversionType}: {target.width}x{target.height} Failing pixels: {incorrectPixels}"); + // Debug.Log($"{source} to {dest} ({conversionType}: {target.width}x{target.height} Failing pixels: {incorrectPixels}"); - // if (incorrectPixels != 0) + if (incorrectPixels != 0) { + assertString = $"{incorrectPixels} incorrect pixels detected: {source} to {dest} ({conversionType})"; + assertIncorrectPixels = incorrectPixels; + ShaderGraphTestRenderer.SaveToPNG(target, $"test-results/NodeTests/TransformNodeOld_{source}_to_{dest}_{conversionType}.png"); renderer.RenderQuadPreview(graph, target, testPosition, testRotation, useSRP: true, ShaderGraphTestRenderer.Mode.EXPECTED); @@ -95,11 +99,12 @@ public IEnumerator TransformV1MatchesOldTransform() ShaderGraphTestRenderer.SaveToPNG(target, $"test-results/NodeTests/TransformNodeOld_{source}_to_{dest}_{conversionType}_ACTUAL.png"); } - Assert.AreEqual(0, incorrectPixels, $"Incorrect pixels detected: {source} to {dest} ({conversionType})"); - RenderTexture.ReleaseTemporary(target); } + // we assert at the end of the test, so we always produce all of the test results before asserting + Assert.AreEqual(0, assertIncorrectPixels, assertString); + // have to yield to let a frame pass // unity only releases some resources at the end of a frame // and if you do too many renders in a frame it will run out diff --git a/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/ShaderGraphTestRenderer.cs b/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/ShaderGraphTestRenderer.cs index 9e8e225c298..ce825c460ce 100644 --- a/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/ShaderGraphTestRenderer.cs +++ b/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/ShaderGraphTestRenderer.cs @@ -114,7 +114,6 @@ internal static int CountPixelsNotEqual(RenderTexture target, Color32 value, boo int mismatchCount = 0; var pixels = temp.GetPixels32(0); - Debug.Log($"Checking {pixels.Length} pixels"); foreach (var pixel in pixels) { if ((pixel.r != value.r) || From 1bddcb4d96592a0b587fe1364c2893450bb047fd Mon Sep 17 00:00:00 2001 From: Chris Tchou Date: Wed, 29 Sep 2021 14:14:33 -0700 Subject: [PATCH 16/23] Test reporting artifacts --- .../Assets/CommonAssets/Editor/NodeTests.cs | 15 +++++++++++---- .../Editor/ShaderGraphGraphicsTestsEditor.asmdef | 7 +++++-- .../Editor/ShaderGraphTestRenderer.cs | 7 +++++++ 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/NodeTests.cs b/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/NodeTests.cs index dbd7280d6bd..5dea5853a7a 100644 --- a/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/NodeTests.cs +++ b/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/NodeTests.cs @@ -83,7 +83,11 @@ public IEnumerator TransformV1MatchesOldTransform() renderer.RenderQuadPreview(graph, target, testPosition, testRotation, useSRP: true); int incorrectPixels = ShaderGraphTestRenderer.CountPixelsNotEqual(target, new Color32(0, 255, 0, 255), false); - // Debug.Log($"{source} to {dest} ({conversionType}: {target.width}x{target.height} Failing pixels: {incorrectPixels}"); + + // test failing some tests + if (UnityEngine.Random.value < 0.1f) + incorrectPixels = 42; + //Debug.Log($"{source} to {dest} ({conversionType}: {target.width}x{target.height} Failing pixels: {incorrectPixels}"); if (incorrectPixels != 0) { @@ -91,26 +95,29 @@ public IEnumerator TransformV1MatchesOldTransform() assertIncorrectPixels = incorrectPixels; ShaderGraphTestRenderer.SaveToPNG(target, $"test-results/NodeTests/TransformNodeOld_{source}_to_{dest}_{conversionType}.png"); + ShaderGraphTestRenderer.ReportArtifact($"test-results/NodeTests/TransformNodeOld_{source}_to_{dest}_{conversionType}.png"); renderer.RenderQuadPreview(graph, target, testPosition, testRotation, useSRP: true, ShaderGraphTestRenderer.Mode.EXPECTED); ShaderGraphTestRenderer.SaveToPNG(target, $"test-results/NodeTests/TransformNodeOld_{source}_to_{dest}_{conversionType}_EXPECTED.png"); + ShaderGraphTestRenderer.ReportArtifact($"test-results/NodeTests/TransformNodeOld_{source}_to_{dest}_{conversionType}.png"); renderer.RenderQuadPreview(graph, target, testPosition, testRotation, useSRP: true, ShaderGraphTestRenderer.Mode.ACTUAL); ShaderGraphTestRenderer.SaveToPNG(target, $"test-results/NodeTests/TransformNodeOld_{source}_to_{dest}_{conversionType}_ACTUAL.png"); + ShaderGraphTestRenderer.ReportArtifact($"test-results/NodeTests/TransformNodeOld_{source}_to_{dest}_{conversionType}.png"); } RenderTexture.ReleaseTemporary(target); } - // we assert at the end of the test, so we always produce all of the test results before asserting - Assert.AreEqual(0, assertIncorrectPixels, assertString); - // have to yield to let a frame pass // unity only releases some resources at the end of a frame // and if you do too many renders in a frame it will run out yield return null; } } + + // we assert at the end of the test, so we always produce all of the test results before asserting + Assert.AreEqual(0, assertIncorrectPixels, assertString); } } } diff --git a/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/ShaderGraphGraphicsTestsEditor.asmdef b/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/ShaderGraphGraphicsTestsEditor.asmdef index dd5069f1737..664d3580a6d 100644 --- a/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/ShaderGraphGraphicsTestsEditor.asmdef +++ b/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/ShaderGraphGraphicsTestsEditor.asmdef @@ -1,10 +1,12 @@ { "name": "Unity.ShaderGraph.Editor.GraphicsTests", + "rootNamespace": "", "references": [ "UnityEditor.TestTools.Graphics", "Unity.ShaderGraph.Editor", "UnityEngine.TestRunner", - "UnityEditor.TestRunner" + "UnityEditor.TestRunner", + "Unity.TestProtocol" ], "includePlatforms": [ "Editor" @@ -19,5 +21,6 @@ "defineConstraints": [ "UNITY_INCLUDE_TESTS" ], - "versionDefines": [] + "versionDefines": [], + "noEngineReferences": false } \ No newline at end of file diff --git a/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/ShaderGraphTestRenderer.cs b/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/ShaderGraphTestRenderer.cs index ce825c460ce..f918d6bb9d6 100644 --- a/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/ShaderGraphTestRenderer.cs +++ b/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/ShaderGraphTestRenderer.cs @@ -83,6 +83,13 @@ internal static void CreateDirectories(string systemDirectoryPath) */ } + internal static void ReportArtifact(string artifactPath) + { + var fullpath = Path.GetFullPath(artifactPath); + var message = Unity.TestProtocol.Messages.ArtifactPublishMessage.Create(fullpath); + Debug.Log(Unity.TestProtocol.UnityTestProtocolMessageBuilder.Serialize(message)); + } + internal static void SaveToPNG(RenderTexture target, string path, bool createDirectory = true) { if (createDirectory) From e5753dbdd00d7f05a46a3c60fc31873332f7c2c7 Mon Sep 17 00:00:00 2001 From: Chris Tchou Date: Wed, 29 Sep 2021 14:45:22 -0700 Subject: [PATCH 17/23] Can we get report image diffs to work? --- .../ShaderGraph/Assets/CommonAssets/Editor/NodeTests.cs | 9 +++------ .../CommonAssets/Editor/ShaderGraphTestRenderer.cs | 5 ++++- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/NodeTests.cs b/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/NodeTests.cs index 5dea5853a7a..2e73cc7c720 100644 --- a/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/NodeTests.cs +++ b/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/NodeTests.cs @@ -94,16 +94,13 @@ public IEnumerator TransformV1MatchesOldTransform() assertString = $"{incorrectPixels} incorrect pixels detected: {source} to {dest} ({conversionType})"; assertIncorrectPixels = incorrectPixels; - ShaderGraphTestRenderer.SaveToPNG(target, $"test-results/NodeTests/TransformNodeOld_{source}_to_{dest}_{conversionType}.png"); - ShaderGraphTestRenderer.ReportArtifact($"test-results/NodeTests/TransformNodeOld_{source}_to_{dest}_{conversionType}.png"); + ShaderGraphTestRenderer.SaveToPNG(target, $"test-results/NodeTests/TransformNodeOld_{source}_to_{dest}_{conversionType}.diff.png", reportArtifact: true); renderer.RenderQuadPreview(graph, target, testPosition, testRotation, useSRP: true, ShaderGraphTestRenderer.Mode.EXPECTED); - ShaderGraphTestRenderer.SaveToPNG(target, $"test-results/NodeTests/TransformNodeOld_{source}_to_{dest}_{conversionType}_EXPECTED.png"); - ShaderGraphTestRenderer.ReportArtifact($"test-results/NodeTests/TransformNodeOld_{source}_to_{dest}_{conversionType}.png"); + ShaderGraphTestRenderer.SaveToPNG(target, $"test-results/NodeTests/TransformNodeOld_{source}_to_{dest}_{conversionType}.expected.png", reportArtifact: true); renderer.RenderQuadPreview(graph, target, testPosition, testRotation, useSRP: true, ShaderGraphTestRenderer.Mode.ACTUAL); - ShaderGraphTestRenderer.SaveToPNG(target, $"test-results/NodeTests/TransformNodeOld_{source}_to_{dest}_{conversionType}_ACTUAL.png"); - ShaderGraphTestRenderer.ReportArtifact($"test-results/NodeTests/TransformNodeOld_{source}_to_{dest}_{conversionType}.png"); + ShaderGraphTestRenderer.SaveToPNG(target, $"test-results/NodeTests/TransformNodeOld_{source}_to_{dest}_{conversionType}.png", reportArtifact: true); } RenderTexture.ReleaseTemporary(target); diff --git a/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/ShaderGraphTestRenderer.cs b/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/ShaderGraphTestRenderer.cs index f918d6bb9d6..ffa9ce49a67 100644 --- a/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/ShaderGraphTestRenderer.cs +++ b/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/ShaderGraphTestRenderer.cs @@ -90,7 +90,7 @@ internal static void ReportArtifact(string artifactPath) Debug.Log(Unity.TestProtocol.UnityTestProtocolMessageBuilder.Serialize(message)); } - internal static void SaveToPNG(RenderTexture target, string path, bool createDirectory = true) + internal static void SaveToPNG(RenderTexture target, string path, bool createDirectory = true, bool reportArtifact = false) { if (createDirectory) CreateDirectoriesForFilePath(path); @@ -108,6 +108,9 @@ internal static void SaveToPNG(RenderTexture target, string path, bool createDir File.WriteAllBytes(path, pngData); } UnityEngine.Object.DestroyImmediate(temp); + + if (reportArtifact) + ShaderGraphTestRenderer.ReportArtifact(path); } internal static int CountPixelsNotEqual(RenderTexture target, Color32 value, bool compareAlpha) From 93501fcb1922808feb2deef91cbe4bf17e69ad29 Mon Sep 17 00:00:00 2001 From: Chris Tchou Date: Thu, 30 Sep 2021 12:04:19 -0700 Subject: [PATCH 18/23] Cleaning up code, adding more transform tests --- .../Assets/CommonAssets/Editor/NodeTests.cs | 202 +- .../Editor/ShaderGraphTestRenderer.cs | 97 +- .../Assets/CommonAssets/Graphs/NodeTests.meta | 8 + .../Graphs/NodeTests/NodeTestTest.shadergraph | 830 ++++++ .../NodeTests/NodeTestTest.shadergraph.meta | 10 + .../Graphs/NodeTests/TransformABC.shadergraph | 2377 +++++++++++++++++ .../NodeTests/TransformABC.shadergraph.meta | 10 + .../NodeTests/TransformInverses.shadergraph | 2366 ++++++++++++++++ .../TransformInverses.shadergraph.meta | 10 + .../NodeTests/TransformNormalize.shadergraph | 2366 ++++++++++++++++ .../TransformNormalize.shadergraph.meta | 10 + ...ransformV1MatchesOldTransform.shadergraph} | 81 +- ...ormV1MatchesOldTransform.shadergraph.meta} | 0 13 files changed, 8264 insertions(+), 103 deletions(-) create mode 100644 TestProjects/ShaderGraph/Assets/CommonAssets/Graphs/NodeTests.meta create mode 100644 TestProjects/ShaderGraph/Assets/CommonAssets/Graphs/NodeTests/NodeTestTest.shadergraph create mode 100644 TestProjects/ShaderGraph/Assets/CommonAssets/Graphs/NodeTests/NodeTestTest.shadergraph.meta create mode 100644 TestProjects/ShaderGraph/Assets/CommonAssets/Graphs/NodeTests/TransformABC.shadergraph create mode 100644 TestProjects/ShaderGraph/Assets/CommonAssets/Graphs/NodeTests/TransformABC.shadergraph.meta create mode 100644 TestProjects/ShaderGraph/Assets/CommonAssets/Graphs/NodeTests/TransformInverses.shadergraph create mode 100644 TestProjects/ShaderGraph/Assets/CommonAssets/Graphs/NodeTests/TransformInverses.shadergraph.meta create mode 100644 TestProjects/ShaderGraph/Assets/CommonAssets/Graphs/NodeTests/TransformNormalize.shadergraph create mode 100644 TestProjects/ShaderGraph/Assets/CommonAssets/Graphs/NodeTests/TransformNormalize.shadergraph.meta rename TestProjects/ShaderGraph/Assets/CommonAssets/Graphs/{TransformGraph.shadergraph => NodeTests/TransformV1MatchesOldTransform.shadergraph} (98%) rename TestProjects/ShaderGraph/Assets/CommonAssets/Graphs/{TransformGraph.shadergraph.meta => NodeTests/TransformV1MatchesOldTransform.shadergraph.meta} (100%) diff --git a/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/NodeTests.cs b/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/NodeTests.cs index 2e73cc7c720..45e623bccb1 100644 --- a/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/NodeTests.cs +++ b/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/NodeTests.cs @@ -11,55 +11,43 @@ namespace UnityEditor.ShaderGraph.UnitTests { - class NodeTests + class NodeTests : ShaderGraphTestRenderer { - const int res = 128; - - readonly Vector3 testPosition = new Vector3(0.24699998f, 0.51900005f, 0.328999996f); - readonly Quaternion testRotation = new Quaternion(-0.164710045f, -0.0826543793f, -0.220811233f, 0.957748055f); + [UnityTest] + public IEnumerator NodeTestTest() + { + string graphPath = "Assets/CommonAssets/Graphs/NodeTests/NodeTestTest.shadergraph"; + var graph = LoadGraph(graphPath); + ResetTestReporting(); + var colorStrings = new string[] { "_COLOR_RED", "_COLOR_GREEN", "_COLOR_BLUE" }; + var colors = new Color32[] { new Color32(255, 0, 0, 255), new Color32(0, 255, 0, 255), new Color32(0, 0, 255, 255) }; + for (int i = 0; i < 3; i++) + { + RunNodeTest(graph, $"NodeTestTest_{colorStrings[i]}", + expectedColor: colors[i], + setupMaterial: m => m.EnableKeyword(colorStrings[i])); + } + ReportTests(); + yield break; + } [UnityTest] public IEnumerator TransformV1MatchesOldTransform() { - string kGraphName = "Assets/CommonAssets/Graphs/TransformGraph.shadergraph"; - - List lti; - var assetCollection = new AssetCollection(); - ShaderGraphImporter.GetShaderText(kGraphName, out lti, assetCollection, out var graph); - Assert.NotNull(graph, $"Invalid graph data found for {kGraphName}"); - graph.OnEnable(); - graph.ValidateGraph(); - - var renderer = new ShaderGraphTestRenderer(); + string graphPath = "Assets/CommonAssets/Graphs/NodeTests/TransformV1MatchesOldTransform.shadergraph"; + var graph = LoadGraph(graphPath); // first check that it renders red in the initial state, to check that the test works // (graph is initially set up with non-matching transforms) - { - RenderTextureDescriptor descriptor = new RenderTextureDescriptor(res, res, GraphicsFormat.R8G8B8A8_SRGB, depthBufferBits: 32); - var target = RenderTexture.GetTemporary(descriptor); - - // use a non-standard transform, so that view, object, etc. transforms are non trivial - renderer.RenderQuadPreview(graph, target, testPosition, testRotation, useSRP: true); - - int incorrectPixels = ShaderGraphTestRenderer.CountPixelsNotEqual(target, new Color32(0, 255, 0, 255), false); - //Debug.Log($"Initial state: {target.width}x{target.height} Failing pixels: {incorrectPixels}"); - - if (incorrectPixels != res * res) - ShaderGraphTestRenderer.SaveToPNG(target, "test-results/NodeTests/TransformNodeOld_default.png"); - - Assert.AreEqual(res * res, incorrectPixels, $"Initial state should have {res * res} failing pixels"); - - RenderTexture.ReleaseTemporary(target); - yield return null; - } + ResetTestReporting(); + RunNodeTest(graph, $"TransformV1_default", expectedIncorrectPixels: defaultResolution * defaultResolution); + ReportTests(); + // now check all possible settings + ResetTestReporting(); var xform = graph.GetNodes().First(); var old = graph.GetNodes().First(); - // now check all possible settings - string assertString = null; - int assertIncorrectPixels = 0; - var oldConversionTypes = new ConversionType[] { ConversionType.Position, ConversionType.Direction }; foreach (ConversionType conversionType in oldConversionTypes) { @@ -76,45 +64,137 @@ public IEnumerator TransformV1MatchesOldTransform() old.conversion = new CoordinateSpaceConversion(source, dest); old.conversionType = conversionType; - RenderTextureDescriptor descriptor = new RenderTextureDescriptor(res, res, GraphicsFormat.R8G8B8A8_SRGB, depthBufferBits: 32); - var target = RenderTexture.GetTemporary(descriptor); + RunNodeTest(graph, $"TransformNodeOld_{source}_to_{dest}_{conversionType}"); + } - // use a non-standard transform, so that view, object, etc. transforms are non trivial - renderer.RenderQuadPreview(graph, target, testPosition, testRotation, useSRP: true); + // have to yield to let a frame pass or it will break + // (unity only releases some resources at the end of the frame) + yield return null; + } + } + ReportTests(); + } - int incorrectPixels = ShaderGraphTestRenderer.CountPixelsNotEqual(target, new Color32(0, 255, 0, 255), false); + [UnityTest] + public IEnumerator TransformInverses() + { + string graphPath = "Assets/CommonAssets/Graphs/NodeTests/TransformInverses.shadergraph"; + var graph = LoadGraph(graphPath); + ResetTestReporting(); + + // check all possible settings + var xforms = graph.GetNodes(); + var xform = xforms.First(); + var inv = xforms.Skip(1).First(); + foreach (ConversionType conversionType in Enum.GetValues(typeof(ConversionType))) + { + foreach (CoordinateSpace source in Enum.GetValues(typeof(CoordinateSpace))) + { + foreach (CoordinateSpace dest in Enum.GetValues(typeof(CoordinateSpace))) + { + // setup transform node + xform.conversion = new CoordinateSpaceConversion(source, dest); + xform.conversionType = conversionType; + xform.normalize = false; - // test failing some tests - if (UnityEngine.Random.value < 0.1f) - incorrectPixels = 42; - //Debug.Log($"{source} to {dest} ({conversionType}: {target.width}x{target.height} Failing pixels: {incorrectPixels}"); + // setup inverse transform node + inv.conversion = new CoordinateSpaceConversion(dest, source); + inv.conversionType = conversionType; + inv.normalize = false; - if (incorrectPixels != 0) + RunNodeTest(graph, $"TransformInverse_{source}_to_{dest}_{conversionType}"); + } + + // have to yield to let a frame pass or it will break + // (unity only releases some resources at the end of the frame) + yield return null; + } + } + ReportTests(); + } + + [UnityTest] + public IEnumerator TransformABC() + { + string graphPath = "Assets/CommonAssets/Graphs/NodeTests/TransformABC.shadergraph"; + var graph = LoadGraph(graphPath); + ResetTestReporting(); + + var xforms = graph.GetNodes(); + var A_to_C = xforms.FirstOrDefault(n => (n.conversion.from == CoordinateSpace.Object) && (n.conversion.to == CoordinateSpace.Tangent)); + var A_to_B = xforms.FirstOrDefault(n => (n.conversion.from == CoordinateSpace.Object) && (n.conversion.to == CoordinateSpace.View)); + var B_to_C = xforms.FirstOrDefault(n => (n.conversion.from == CoordinateSpace.View) && (n.conversion.to == CoordinateSpace.Tangent)); + + // check all possible settings + foreach (ConversionType conversionType in Enum.GetValues(typeof(ConversionType))) + { + foreach (CoordinateSpace A in Enum.GetValues(typeof(CoordinateSpace))) + { + foreach (CoordinateSpace B in Enum.GetValues(typeof(CoordinateSpace))) + { + foreach (CoordinateSpace C in Enum.GetValues(typeof(CoordinateSpace))) { - assertString = $"{incorrectPixels} incorrect pixels detected: {source} to {dest} ({conversionType})"; - assertIncorrectPixels = incorrectPixels; + // setup transforms + A_to_C.conversion = new CoordinateSpaceConversion(A, C); + A_to_C.conversionType = conversionType; + A_to_C.normalize = false; - ShaderGraphTestRenderer.SaveToPNG(target, $"test-results/NodeTests/TransformNodeOld_{source}_to_{dest}_{conversionType}.diff.png", reportArtifact: true); + A_to_B.conversion = new CoordinateSpaceConversion(A, B); + A_to_B.conversionType = conversionType; + A_to_B.normalize = false; - renderer.RenderQuadPreview(graph, target, testPosition, testRotation, useSRP: true, ShaderGraphTestRenderer.Mode.EXPECTED); - ShaderGraphTestRenderer.SaveToPNG(target, $"test-results/NodeTests/TransformNodeOld_{source}_to_{dest}_{conversionType}.expected.png", reportArtifact: true); + B_to_C.conversion = new CoordinateSpaceConversion(B, C); + B_to_C.conversionType = conversionType; + B_to_C.normalize = false; - renderer.RenderQuadPreview(graph, target, testPosition, testRotation, useSRP: true, ShaderGraphTestRenderer.Mode.ACTUAL); - ShaderGraphTestRenderer.SaveToPNG(target, $"test-results/NodeTests/TransformNodeOld_{source}_to_{dest}_{conversionType}.png", reportArtifact: true); + RunNodeTest(graph, $"TransformABC_{A}_{B}_{C}_{conversionType}"); } - RenderTexture.ReleaseTemporary(target); + // have to yield to let a frame pass or it will break + // (unity only releases some resources at the end of the frame) + yield return null; } + } + } + ReportTests(); + } - // have to yield to let a frame pass - // unity only releases some resources at the end of a frame - // and if you do too many renders in a frame it will run out + [UnityTest] + public IEnumerator TransformNormalize() + { + string graphPath = "Assets/CommonAssets/Graphs/NodeTests/TransformNormalize.shadergraph"; + var graph = LoadGraph(graphPath); + + // now check all possible settings + ResetTestReporting(); + var xforms = graph.GetNodes(); + var norm = xforms.FirstOrDefault(n => n.normalize); + var unnorm = xforms.FirstOrDefault(n => !n.normalize); + + var normalizeConversionTypes = new ConversionType[] { ConversionType.Direction, ConversionType.Normal }; + foreach (ConversionType conversionType in normalizeConversionTypes) + { + foreach (CoordinateSpace source in Enum.GetValues(typeof(CoordinateSpace))) + { + foreach (CoordinateSpace dest in Enum.GetValues(typeof(CoordinateSpace))) + { + // setup transform(v1) node + norm.conversion = new CoordinateSpaceConversion(source, dest); + norm.conversionType = conversionType; + + // setup old transform node + unnorm.conversion = new CoordinateSpaceConversion(source, dest); + unnorm.conversionType = conversionType; + + RunNodeTest(graph, $"TransformNormalize_{source}_to_{dest}_{conversionType}"); + } + + // have to yield to let a frame pass or it will break + // (unity only releases some resources at the end of the frame) yield return null; } } - - // we assert at the end of the test, so we always produce all of the test results before asserting - Assert.AreEqual(0, assertIncorrectPixels, assertString); + ReportTests(); } } } diff --git a/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/ShaderGraphTestRenderer.cs b/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/ShaderGraphTestRenderer.cs index ffa9ce49a67..98463f84437 100644 --- a/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/ShaderGraphTestRenderer.cs +++ b/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/ShaderGraphTestRenderer.cs @@ -1,15 +1,89 @@ - +using System; using System.IO; +using System.Collections.Generic; using UnityEngine; using UnityEditor; using UnityEngine.Experimental.Rendering; using UnityEngine.Rendering; using UnityEditor.ShaderGraph; using UnityEditor.ShaderGraph.Drawing; +using NUnit.Framework; public class ShaderGraphTestRenderer { - PreviewSceneResources previewScene = new PreviewSceneResources(); + internal const int defaultResolution = 128; + + internal PreviewSceneResources previewScene = new PreviewSceneResources(); + + internal delegate void SetupMaterialDelegate(Material m); + + internal int wrongImageCount; + internal int mostWrongPixels; + internal string mostWrongString; + internal void ResetTestReporting() + { + wrongImageCount = 0; + mostWrongPixels = 0; + mostWrongString = string.Empty; + } + internal void ReportTests() + { + if (wrongImageCount > 0) + { + Assert.That(false, $"{wrongImageCount} images failed, worst was: {mostWrongString}"); + } + } + + internal GraphData LoadGraph(string graphPath) + { + List lti; + var assetCollection = new AssetCollection(); + ShaderGraphImporter.GetShaderText(graphPath, out lti, assetCollection, out var graph); + Assert.NotNull(graph, $"Invalid graph data found for {graphPath}"); + graph.OnEnable(); + graph.ValidateGraph(); + return graph; + } + + // we apply a transform to the test setup, so that the transform matrices are non-trivial + internal Vector3 testPosition = new Vector3(0.24699998f, 0.51900005f, 0.328999996f); + internal Quaternion testRotation = new Quaternion(-0.164710045f, -0.0826543793f, -0.220811233f, 0.957748055f); + + internal int RunNodeTest(GraphData graph, string filePrefix, SetupMaterialDelegate setupMaterial = null, Color32? expectedColor = null, int expectedIncorrectPixels = 0) + { + RenderTextureDescriptor descriptor = new RenderTextureDescriptor(defaultResolution, defaultResolution, GraphicsFormat.R8G8B8A8_SRGB, depthBufferBits: 32); + var target = RenderTexture.GetTemporary(descriptor); + + // use a non-standard transform, so that view, object, etc. transforms are non trivial + RenderQuadPreview(graph, target, testPosition, testRotation, setupMaterial, Mode.DIFF, useSRP: true); + + int incorrectPixels = CountPixelsNotEqual(target, expectedColor ?? new Color32(0, 255, 0, 255), false); + //Debug.Log($"{filePrefix}: {target.width}x{target.height} Failing pixels: {incorrectPixels}"); + + if (incorrectPixels != expectedIncorrectPixels) + { + // report images + SaveToPNG(target, $"test-results/NodeTests/{filePrefix}.diff.png"); + + RenderQuadPreview(graph, target, testPosition, testRotation, setupMaterial, Mode.EXPECTED, useSRP: true); + SaveToPNG(target, $"test-results/NodeTests/{filePrefix}.expected.png"); + + RenderQuadPreview(graph, target, testPosition, testRotation, setupMaterial, Mode.ACTUAL, useSRP: true); + SaveToPNG(target, $"test-results/NodeTests/{filePrefix}.png"); + + // record failure + wrongImageCount++; + int wrongPixels = Math.Abs(incorrectPixels - expectedIncorrectPixels); + if (wrongPixels > mostWrongPixels) + { + mostWrongPixels = wrongPixels; + mostWrongString = $"{filePrefix} incorrect pixels expected: {expectedIncorrectPixels} actual: {incorrectPixels}"; + } + } + + RenderTexture.ReleaseTemporary(target); + return incorrectPixels; + } internal static Shader BuildShaderGraph(GraphData graph, string name, bool hide = true) { @@ -90,7 +164,7 @@ internal static void ReportArtifact(string artifactPath) Debug.Log(Unity.TestProtocol.UnityTestProtocolMessageBuilder.Serialize(message)); } - internal static void SaveToPNG(RenderTexture target, string path, bool createDirectory = true, bool reportArtifact = false) + internal static void SaveToPNG(RenderTexture target, string path, bool createDirectory = true, bool reportArtifact = true) { if (createDirectory) CreateDirectoriesForFilePath(path); @@ -139,20 +213,14 @@ internal static int CountPixelsNotEqual(RenderTexture target, Color32 value, boo return mismatchCount; } - // scenePosition/Rotation is applied to both the camera and the quad. Useful for testing position-sensitive behaviors - internal void RenderQuadPreview(GraphData graph, RenderTexture target, bool useSRP = false) - { - RenderQuadPreview(graph, target, Vector3.zero, Quaternion.identity, useSRP); - } - internal enum Mode { - COMPARE, + DIFF, EXPECTED, ACTUAL } - void SetKeyword(Material mat, string keyword, bool enabled) + internal void SetKeyword(Material mat, string keyword, bool enabled) { if (enabled) mat.EnableKeyword(keyword); @@ -160,7 +228,7 @@ void SetKeyword(Material mat, string keyword, bool enabled) mat.DisableKeyword(keyword); } - internal void RenderQuadPreview(GraphData graph, RenderTexture target, Vector3 scenePosition, Quaternion sceneRotation, bool useSRP = false, Mode mode = Mode.COMPARE) + internal void RenderQuadPreview(GraphData graph, RenderTexture target, Vector3 scenePosition, Quaternion sceneRotation, SetupMaterialDelegate setupMaterial = null, Mode mode = Mode.DIFF, bool useSRP = false) { var camXform = previewScene.camera.transform; @@ -178,10 +246,13 @@ internal void RenderQuadPreview(GraphData graph, RenderTexture target, Vector3 s var shader = BuildShaderGraph(graph, "Test Shader"); var mat = new Material(shader) { hideFlags = HideFlags.HideAndDontSave }; - SetKeyword(mat, "_MODE_COMPARE", (mode == Mode.COMPARE)); + SetKeyword(mat, "_MODE_DIFF", (mode == Mode.DIFF)); SetKeyword(mat, "_MODE_EXPECTED", (mode == Mode.EXPECTED)); SetKeyword(mat, "_MODE_ACTUAL", (mode == Mode.ACTUAL)); + if (setupMaterial != null) + setupMaterial(mat); + var quadMatrix = Matrix4x4.TRS(camXform.position + camXform.forward * 2, camXform.rotation, Vector3.one); // render with it diff --git a/TestProjects/ShaderGraph/Assets/CommonAssets/Graphs/NodeTests.meta b/TestProjects/ShaderGraph/Assets/CommonAssets/Graphs/NodeTests.meta new file mode 100644 index 00000000000..63febdb4f1f --- /dev/null +++ b/TestProjects/ShaderGraph/Assets/CommonAssets/Graphs/NodeTests.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c171d0a5c6937ae4eb59a6c70d8f9dfa +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/TestProjects/ShaderGraph/Assets/CommonAssets/Graphs/NodeTests/NodeTestTest.shadergraph b/TestProjects/ShaderGraph/Assets/CommonAssets/Graphs/NodeTests/NodeTestTest.shadergraph new file mode 100644 index 00000000000..2d9a19167c3 --- /dev/null +++ b/TestProjects/ShaderGraph/Assets/CommonAssets/Graphs/NodeTests/NodeTestTest.shadergraph @@ -0,0 +1,830 @@ +{ + "m_SGVersion": 3, + "m_Type": "UnityEditor.ShaderGraph.GraphData", + "m_ObjectId": "5794c0fc834944ae8236b510ae2a494b", + "m_Properties": [], + "m_Keywords": [ + { + "m_Id": "3f29a7a705cc4b98b260a52d4cac4af7" + } + ], + "m_Dropdowns": [], + "m_CategoryData": [ + { + "m_Id": "0536202d0f76420f9e81de7eb7f9bc18" + } + ], + "m_Nodes": [ + { + "m_Id": "fc6ab7c410284dbabb360fd37becc1b3" + }, + { + "m_Id": "b03c06b3044a456097aa4599d3f2b771" + }, + { + "m_Id": "762c16d3749a4bc8a7849d9806559663" + }, + { + "m_Id": "0894e62f5acb4df5952151568cc3eead" + }, + { + "m_Id": "4a0f6e07c11d4bf790182c317b7f78fa" + }, + { + "m_Id": "b9cd385803404e4384fa2c323c05bc68" + }, + { + "m_Id": "16c77226a6c149f5b2cf139a4ea31330" + }, + { + "m_Id": "1688de6865054174b0e7314a2faeaa12" + } + ], + "m_GroupDatas": [], + "m_StickyNoteDatas": [ + { + "m_Id": "0997847061d84fe6a39765a3069249ac" + } + ], + "m_Edges": [ + { + "m_OutputSlot": { + "m_Node": { + "m_Id": "1688de6865054174b0e7314a2faeaa12" + }, + "m_SlotId": 0 + }, + "m_InputSlot": { + "m_Node": { + "m_Id": "4a0f6e07c11d4bf790182c317b7f78fa" + }, + "m_SlotId": 2 + } + }, + { + "m_OutputSlot": { + "m_Node": { + "m_Id": "16c77226a6c149f5b2cf139a4ea31330" + }, + "m_SlotId": 0 + }, + "m_InputSlot": { + "m_Node": { + "m_Id": "4a0f6e07c11d4bf790182c317b7f78fa" + }, + "m_SlotId": 1 + } + }, + { + "m_OutputSlot": { + "m_Node": { + "m_Id": "4a0f6e07c11d4bf790182c317b7f78fa" + }, + "m_SlotId": 0 + }, + "m_InputSlot": { + "m_Node": { + "m_Id": "0894e62f5acb4df5952151568cc3eead" + }, + "m_SlotId": 0 + } + }, + { + "m_OutputSlot": { + "m_Node": { + "m_Id": "b9cd385803404e4384fa2c323c05bc68" + }, + "m_SlotId": 0 + }, + "m_InputSlot": { + "m_Node": { + "m_Id": "4a0f6e07c11d4bf790182c317b7f78fa" + }, + "m_SlotId": 4 + } + } + ], + "m_VertexContext": { + "m_Position": { + "x": 0.0, + "y": 0.0 + }, + "m_Blocks": [ + { + "m_Id": "fc6ab7c410284dbabb360fd37becc1b3" + }, + { + "m_Id": "b03c06b3044a456097aa4599d3f2b771" + }, + { + "m_Id": "762c16d3749a4bc8a7849d9806559663" + } + ] + }, + "m_FragmentContext": { + "m_Position": { + "x": 0.0, + "y": 200.0 + }, + "m_Blocks": [ + { + "m_Id": "0894e62f5acb4df5952151568cc3eead" + } + ] + }, + "m_PreviewData": { + "serializedMesh": { + "m_SerializedMesh": "{\"mesh\":{\"instanceID\":0}}", + "m_Guid": "" + }, + "preventRotation": false + }, + "m_Path": "Shader Graphs", + "m_GraphPrecision": 1, + "m_PreviewMode": 2, + "m_OutputNode": { + "m_Id": "" + }, + "m_ActiveTargets": [ + { + "m_Id": "a3dd56494f774c38ac7a624014242301" + } + ] +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.CategoryData", + "m_ObjectId": "0536202d0f76420f9e81de7eb7f9bc18", + "m_Name": "", + "m_ChildObjectList": [ + { + "m_Id": "3f29a7a705cc4b98b260a52d4cac4af7" + } + ] +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.BlockNode", + "m_ObjectId": "0894e62f5acb4df5952151568cc3eead", + "m_Group": { + "m_Id": "" + }, + "m_Name": "SurfaceDescription.BaseColor", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": 0.0, + "y": 0.0, + "width": 0.0, + "height": 0.0 + } + }, + "m_Slots": [ + { + "m_Id": "37070abbec4c450fbd50efa3c9becd7d" + } + ], + "synonyms": [], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + }, + "m_SerializedDescriptor": "SurfaceDescription.BaseColor" +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.StickyNoteData", + "m_ObjectId": "0997847061d84fe6a39765a3069249ac", + "m_Title": "Purpose", + "m_Content": "Basic test to see if the Node Test system is working and can detect color changes", + "m_TextSize": 0, + "m_Theme": 0, + "m_Position": { + "serializedVersion": "2", + "x": -375.1851806640625, + "y": -27.819337844848634, + "width": 200.0, + "height": 160.0 + }, + "m_Group": { + "m_Id": "" + } +} + +{ + "m_SGVersion": 1, + "m_Type": "UnityEditor.ShaderGraph.ColorNode", + "m_ObjectId": "1688de6865054174b0e7314a2faeaa12", + "m_Group": { + "m_Id": "" + }, + "m_Name": "Color", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": -652.0001220703125, + "y": 347.0000305175781, + "width": 208.00009155273438, + "height": 126.99996948242188 + } + }, + "m_Slots": [ + { + "m_Id": "7844ebe59bdd47868611e9ec611d89ef" + } + ], + "synonyms": [ + "rgba" + ], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + }, + "m_Color": { + "color": { + "r": 0.0, + "g": 0.0, + "b": 1.0, + "a": 0.0 + }, + "mode": 0 + } +} + +{ + "m_SGVersion": 1, + "m_Type": "UnityEditor.ShaderGraph.ColorNode", + "m_ObjectId": "16c77226a6c149f5b2cf139a4ea31330", + "m_Group": { + "m_Id": "" + }, + "m_Name": "Color", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": -652.0001220703125, + "y": 220.00001525878907, + "width": 208.00009155273438, + "height": 127.00001525878906 + } + }, + "m_Slots": [ + { + "m_Id": "53edcc79cf12413fb5d81493648d60d0" + } + ], + "synonyms": [ + "rgba" + ], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + }, + "m_Color": { + "color": { + "r": 0.0, + "g": 1.0, + "b": 0.0, + "a": 0.0 + }, + "mode": 0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.ColorRGBMaterialSlot", + "m_ObjectId": "37070abbec4c450fbd50efa3c9becd7d", + "m_Id": 0, + "m_DisplayName": "Base Color", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "BaseColor", + "m_StageCapability": 2, + "m_Value": { + "x": 0.5, + "y": 0.5, + "z": 0.5 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_Labels": [], + "m_ColorMode": 0, + "m_DefaultColor": { + "r": 0.5, + "g": 0.5, + "b": 0.5, + "a": 1.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.TangentMaterialSlot", + "m_ObjectId": "3f15dc9d2ca14343a82768f269898a8e", + "m_Id": 0, + "m_DisplayName": "Tangent", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "Tangent", + "m_StageCapability": 1, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_Labels": [], + "m_Space": 0 +} + +{ + "m_SGVersion": 1, + "m_Type": "UnityEditor.ShaderGraph.ShaderKeyword", + "m_ObjectId": "3f29a7a705cc4b98b260a52d4cac4af7", + "m_Guid": { + "m_GuidSerialized": "50819290-e62f-4c42-9b9e-f9c9fa25680e" + }, + "m_Name": "COLOR", + "m_DefaultRefNameVersion": 1, + "m_RefNameGeneratedByDisplayName": "COLOR", + "m_DefaultReferenceName": "_COLOR", + "m_OverrideReferenceName": "", + "m_GeneratePropertyBlock": true, + "m_UseCustomSlotLabel": false, + "m_CustomSlotLabel": "", + "m_KeywordType": 1, + "m_KeywordDefinition": 0, + "m_KeywordScope": 0, + "m_KeywordStages": 63, + "m_Entries": [ + { + "id": 4, + "displayName": "RED", + "referenceName": "RED" + }, + { + "id": 1, + "displayName": "GREEN", + "referenceName": "GREEN" + }, + { + "id": 2, + "displayName": "BLUE", + "referenceName": "BLUE" + } + ], + "m_Value": 2, + "m_IsEditable": true +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "402398862b46423d9eb671076a04d8fd", + "m_Id": 2, + "m_DisplayName": "BLUE", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "BLUE", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.KeywordNode", + "m_ObjectId": "4a0f6e07c11d4bf790182c317b7f78fa", + "m_Group": { + "m_Id": "" + }, + "m_Name": "COLOR", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": -323.0000915527344, + "y": 199.99998474121095, + "width": 208.00003051757813, + "height": 326.00006103515627 + } + }, + "m_Slots": [ + { + "m_Id": "72755c4a8d884deabd4da0e6da0d1ca6" + }, + { + "m_Id": "cf2f7f6f8d0f49da98b63f88d3be5c2f" + }, + { + "m_Id": "5e014be303dd4ab696d4af167c1bee45" + }, + { + "m_Id": "402398862b46423d9eb671076a04d8fd" + } + ], + "synonyms": [], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + }, + "m_Keyword": { + "m_Id": "3f29a7a705cc4b98b260a52d4cac4af7" + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.Vector4MaterialSlot", + "m_ObjectId": "53edcc79cf12413fb5d81493648d60d0", + "m_Id": 0, + "m_DisplayName": "Out", + "m_SlotType": 1, + "m_Hidden": false, + "m_ShaderOutputName": "Out", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_Labels": [] +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "5e014be303dd4ab696d4af167c1bee45", + "m_Id": 1, + "m_DisplayName": "GREEN", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "GREEN", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "72755c4a8d884deabd4da0e6da0d1ca6", + "m_Id": 0, + "m_DisplayName": "Out", + "m_SlotType": 1, + "m_Hidden": false, + "m_ShaderOutputName": "Out", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.BlockNode", + "m_ObjectId": "762c16d3749a4bc8a7849d9806559663", + "m_Group": { + "m_Id": "" + }, + "m_Name": "VertexDescription.Tangent", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": 0.0, + "y": 0.0, + "width": 0.0, + "height": 0.0 + } + }, + "m_Slots": [ + { + "m_Id": "3f15dc9d2ca14343a82768f269898a8e" + } + ], + "synonyms": [], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + }, + "m_SerializedDescriptor": "VertexDescription.Tangent" +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.Vector4MaterialSlot", + "m_ObjectId": "7844ebe59bdd47868611e9ec611d89ef", + "m_Id": 0, + "m_DisplayName": "Out", + "m_SlotType": 1, + "m_Hidden": false, + "m_ShaderOutputName": "Out", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_Labels": [] +} + +{ + "m_SGVersion": 1, + "m_Type": "UnityEditor.Rendering.Universal.ShaderGraph.UniversalTarget", + "m_ObjectId": "a3dd56494f774c38ac7a624014242301", + "m_ActiveSubTarget": { + "m_Id": "e0cce20dd89649ecac7f1c523d25be28" + }, + "m_AllowMaterialOverride": false, + "m_SurfaceType": 0, + "m_ZTestMode": 4, + "m_ZWriteControl": 0, + "m_AlphaMode": 0, + "m_RenderFace": 2, + "m_AlphaClip": false, + "m_CastShadows": true, + "m_ReceiveShadows": true, + "m_CustomEditorGUI": "", + "m_SupportVFX": false +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.BlockNode", + "m_ObjectId": "b03c06b3044a456097aa4599d3f2b771", + "m_Group": { + "m_Id": "" + }, + "m_Name": "VertexDescription.Normal", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": 0.0, + "y": 0.0, + "width": 0.0, + "height": 0.0 + } + }, + "m_Slots": [ + { + "m_Id": "d14653b74e3c4f2f89a767be40b699b0" + } + ], + "synonyms": [], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + }, + "m_SerializedDescriptor": "VertexDescription.Normal" +} + +{ + "m_SGVersion": 1, + "m_Type": "UnityEditor.ShaderGraph.ColorNode", + "m_ObjectId": "b9cd385803404e4384fa2c323c05bc68", + "m_Group": { + "m_Id": "" + }, + "m_Name": "Color", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": -652.0001220703125, + "y": 93.00000762939453, + "width": 208.00009155273438, + "height": 127.00000762939453 + } + }, + "m_Slots": [ + { + "m_Id": "f7165d0015a54bc9be941d6b8f74edd3" + } + ], + "synonyms": [ + "rgba" + ], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + }, + "m_Color": { + "color": { + "r": 1.0, + "g": 0.0, + "b": 0.0, + "a": 0.0 + }, + "mode": 0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "cf2f7f6f8d0f49da98b63f88d3be5c2f", + "m_Id": 4, + "m_DisplayName": "RED", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "RED", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.NormalMaterialSlot", + "m_ObjectId": "d14653b74e3c4f2f89a767be40b699b0", + "m_Id": 0, + "m_DisplayName": "Normal", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "Normal", + "m_StageCapability": 1, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_Labels": [], + "m_Space": 0 +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.Rendering.Universal.ShaderGraph.UniversalUnlitSubTarget", + "m_ObjectId": "e0cce20dd89649ecac7f1c523d25be28" +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.PositionMaterialSlot", + "m_ObjectId": "ed1ae7d21efb4c26beee46b999260313", + "m_Id": 0, + "m_DisplayName": "Position", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "Position", + "m_StageCapability": 1, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_Labels": [], + "m_Space": 0 +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.Vector4MaterialSlot", + "m_ObjectId": "f7165d0015a54bc9be941d6b8f74edd3", + "m_Id": 0, + "m_DisplayName": "Out", + "m_SlotType": 1, + "m_Hidden": false, + "m_ShaderOutputName": "Out", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_Labels": [] +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.BlockNode", + "m_ObjectId": "fc6ab7c410284dbabb360fd37becc1b3", + "m_Group": { + "m_Id": "" + }, + "m_Name": "VertexDescription.Position", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": 0.0, + "y": 0.0, + "width": 0.0, + "height": 0.0 + } + }, + "m_Slots": [ + { + "m_Id": "ed1ae7d21efb4c26beee46b999260313" + } + ], + "synonyms": [], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + }, + "m_SerializedDescriptor": "VertexDescription.Position" +} + diff --git a/TestProjects/ShaderGraph/Assets/CommonAssets/Graphs/NodeTests/NodeTestTest.shadergraph.meta b/TestProjects/ShaderGraph/Assets/CommonAssets/Graphs/NodeTests/NodeTestTest.shadergraph.meta new file mode 100644 index 00000000000..582e2c820da --- /dev/null +++ b/TestProjects/ShaderGraph/Assets/CommonAssets/Graphs/NodeTests/NodeTestTest.shadergraph.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 16fd65af5f24e5646b7cb9f8d16020c6 +ScriptedImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 2 + userData: + assetBundleName: + assetBundleVariant: + script: {fileID: 11500000, guid: 625f186215c104763be7675aa2d941aa, type: 3} diff --git a/TestProjects/ShaderGraph/Assets/CommonAssets/Graphs/NodeTests/TransformABC.shadergraph b/TestProjects/ShaderGraph/Assets/CommonAssets/Graphs/NodeTests/TransformABC.shadergraph new file mode 100644 index 00000000000..1dfc1371fae --- /dev/null +++ b/TestProjects/ShaderGraph/Assets/CommonAssets/Graphs/NodeTests/TransformABC.shadergraph @@ -0,0 +1,2377 @@ +{ + "m_SGVersion": 3, + "m_Type": "UnityEditor.ShaderGraph.GraphData", + "m_ObjectId": "d3a578d5f6c048d989f4fc22763a096c", + "m_Properties": [], + "m_Keywords": [ + { + "m_Id": "1bd0bd2d8a644a369163cb727342c308" + } + ], + "m_Dropdowns": [], + "m_CategoryData": [ + { + "m_Id": "82645ecd662c4d88a7de4083a8e5b53c" + } + ], + "m_Nodes": [ + { + "m_Id": "fc28a5ef65284ed0967870ff69516ffe" + }, + { + "m_Id": "970cbadefd8f4fcca05f884246b4ad3e" + }, + { + "m_Id": "3ec2632bb2694b7699d26c257e2879ea" + }, + { + "m_Id": "65611bc2ea7845359ab31d44dd0816ab" + }, + { + "m_Id": "d7fc69d9fbd84fe5b18d4361e39b39b9" + }, + { + "m_Id": "997e733a37a141d4b698281397e00d14" + }, + { + "m_Id": "d5c0ffaecc9d45f986de4d8925bc0051" + }, + { + "m_Id": "de1092b024884fdf9e8a5171a48ef13e" + }, + { + "m_Id": "fa72769f37e54f599d367774a779d845" + }, + { + "m_Id": "cd74f48ac90a40f49890cd16fbf6660a" + }, + { + "m_Id": "afd6fed3d8e8461c9ac141b19e55e04d" + }, + { + "m_Id": "1746ecad396f45c2808181de7c16ab2d" + }, + { + "m_Id": "907dd0a26f124143bbc87326f74c2f54" + }, + { + "m_Id": "54d1e21495064ae8982ce8365d45d873" + }, + { + "m_Id": "3f4fe83ebf4a492c8bd4bd8d039d4e4e" + }, + { + "m_Id": "ffde04b05e2c42f38093d4ddd027315b" + }, + { + "m_Id": "6dc28149a6e2450a9b06b18a139d8695" + }, + { + "m_Id": "49eb3060313949e8a29142442a4c029a" + }, + { + "m_Id": "11320eeb0d9f4e2aaf7c881af29e9d14" + }, + { + "m_Id": "9fa27d76367a4b37b0351f86e835a86e" + } + ], + "m_GroupDatas": [], + "m_StickyNoteDatas": [ + { + "m_Id": "ebeb58a811964ae1ae55c9969cd6e146" + }, + { + "m_Id": "6861d370b150463a8e84fb6bf7973bdc" + } + ], + "m_Edges": [ + { + "m_OutputSlot": { + "m_Node": { + "m_Id": "11320eeb0d9f4e2aaf7c881af29e9d14" + }, + "m_SlotId": 1 + }, + "m_InputSlot": { + "m_Node": { + "m_Id": "d5c0ffaecc9d45f986de4d8925bc0051" + }, + "m_SlotId": 1 + } + }, + { + "m_OutputSlot": { + "m_Node": { + "m_Id": "11320eeb0d9f4e2aaf7c881af29e9d14" + }, + "m_SlotId": 1 + }, + "m_InputSlot": { + "m_Node": { + "m_Id": "ffde04b05e2c42f38093d4ddd027315b" + }, + "m_SlotId": 0 + } + }, + { + "m_OutputSlot": { + "m_Node": { + "m_Id": "1746ecad396f45c2808181de7c16ab2d" + }, + "m_SlotId": 1 + }, + "m_InputSlot": { + "m_Node": { + "m_Id": "afd6fed3d8e8461c9ac141b19e55e04d" + }, + "m_SlotId": 2 + } + }, + { + "m_OutputSlot": { + "m_Node": { + "m_Id": "3f4fe83ebf4a492c8bd4bd8d039d4e4e" + }, + "m_SlotId": 1 + }, + "m_InputSlot": { + "m_Node": { + "m_Id": "907dd0a26f124143bbc87326f74c2f54" + }, + "m_SlotId": 2 + } + }, + { + "m_OutputSlot": { + "m_Node": { + "m_Id": "49eb3060313949e8a29142442a4c029a" + }, + "m_SlotId": 2 + }, + "m_InputSlot": { + "m_Node": { + "m_Id": "d7fc69d9fbd84fe5b18d4361e39b39b9" + }, + "m_SlotId": 1 + } + }, + { + "m_OutputSlot": { + "m_Node": { + "m_Id": "54d1e21495064ae8982ce8365d45d873" + }, + "m_SlotId": 1 + }, + "m_InputSlot": { + "m_Node": { + "m_Id": "907dd0a26f124143bbc87326f74c2f54" + }, + "m_SlotId": 1 + } + }, + { + "m_OutputSlot": { + "m_Node": { + "m_Id": "6dc28149a6e2450a9b06b18a139d8695" + }, + "m_SlotId": 1 + }, + "m_InputSlot": { + "m_Node": { + "m_Id": "54d1e21495064ae8982ce8365d45d873" + }, + "m_SlotId": 0 + } + }, + { + "m_OutputSlot": { + "m_Node": { + "m_Id": "907dd0a26f124143bbc87326f74c2f54" + }, + "m_SlotId": 0 + }, + "m_InputSlot": { + "m_Node": { + "m_Id": "65611bc2ea7845359ab31d44dd0816ab" + }, + "m_SlotId": 0 + } + }, + { + "m_OutputSlot": { + "m_Node": { + "m_Id": "997e733a37a141d4b698281397e00d14" + }, + "m_SlotId": 0 + }, + "m_InputSlot": { + "m_Node": { + "m_Id": "49eb3060313949e8a29142442a4c029a" + }, + "m_SlotId": 1 + } + }, + { + "m_OutputSlot": { + "m_Node": { + "m_Id": "9fa27d76367a4b37b0351f86e835a86e" + }, + "m_SlotId": 1 + }, + "m_InputSlot": { + "m_Node": { + "m_Id": "6dc28149a6e2450a9b06b18a139d8695" + }, + "m_SlotId": 0 + } + }, + { + "m_OutputSlot": { + "m_Node": { + "m_Id": "9fa27d76367a4b37b0351f86e835a86e" + }, + "m_SlotId": 1 + }, + "m_InputSlot": { + "m_Node": { + "m_Id": "d5c0ffaecc9d45f986de4d8925bc0051" + }, + "m_SlotId": 0 + } + }, + { + "m_OutputSlot": { + "m_Node": { + "m_Id": "afd6fed3d8e8461c9ac141b19e55e04d" + }, + "m_SlotId": 3 + }, + "m_InputSlot": { + "m_Node": { + "m_Id": "907dd0a26f124143bbc87326f74c2f54" + }, + "m_SlotId": 3 + } + }, + { + "m_OutputSlot": { + "m_Node": { + "m_Id": "cd74f48ac90a40f49890cd16fbf6660a" + }, + "m_SlotId": 2 + }, + "m_InputSlot": { + "m_Node": { + "m_Id": "1746ecad396f45c2808181de7c16ab2d" + }, + "m_SlotId": 0 + } + }, + { + "m_OutputSlot": { + "m_Node": { + "m_Id": "d5c0ffaecc9d45f986de4d8925bc0051" + }, + "m_SlotId": 2 + }, + "m_InputSlot": { + "m_Node": { + "m_Id": "fa72769f37e54f599d367774a779d845" + }, + "m_SlotId": 0 + } + }, + { + "m_OutputSlot": { + "m_Node": { + "m_Id": "d7fc69d9fbd84fe5b18d4361e39b39b9" + }, + "m_SlotId": 0 + }, + "m_InputSlot": { + "m_Node": { + "m_Id": "9fa27d76367a4b37b0351f86e835a86e" + }, + "m_SlotId": 0 + } + }, + { + "m_OutputSlot": { + "m_Node": { + "m_Id": "d7fc69d9fbd84fe5b18d4361e39b39b9" + }, + "m_SlotId": 0 + }, + "m_InputSlot": { + "m_Node": { + "m_Id": "de1092b024884fdf9e8a5171a48ef13e" + }, + "m_SlotId": 0 + } + }, + { + "m_OutputSlot": { + "m_Node": { + "m_Id": "de1092b024884fdf9e8a5171a48ef13e" + }, + "m_SlotId": 1 + }, + "m_InputSlot": { + "m_Node": { + "m_Id": "11320eeb0d9f4e2aaf7c881af29e9d14" + }, + "m_SlotId": 0 + } + }, + { + "m_OutputSlot": { + "m_Node": { + "m_Id": "fa72769f37e54f599d367774a779d845" + }, + "m_SlotId": 1 + }, + "m_InputSlot": { + "m_Node": { + "m_Id": "cd74f48ac90a40f49890cd16fbf6660a" + }, + "m_SlotId": 0 + } + }, + { + "m_OutputSlot": { + "m_Node": { + "m_Id": "ffde04b05e2c42f38093d4ddd027315b" + }, + "m_SlotId": 1 + }, + "m_InputSlot": { + "m_Node": { + "m_Id": "3f4fe83ebf4a492c8bd4bd8d039d4e4e" + }, + "m_SlotId": 0 + } + } + ], + "m_VertexContext": { + "m_Position": { + "x": 362.00006103515627, + "y": -291.0 + }, + "m_Blocks": [ + { + "m_Id": "fc28a5ef65284ed0967870ff69516ffe" + }, + { + "m_Id": "970cbadefd8f4fcca05f884246b4ad3e" + }, + { + "m_Id": "3ec2632bb2694b7699d26c257e2879ea" + } + ] + }, + "m_FragmentContext": { + "m_Position": { + "x": 362.00006103515627, + "y": -91.0 + }, + "m_Blocks": [ + { + "m_Id": "65611bc2ea7845359ab31d44dd0816ab" + } + ] + }, + "m_PreviewData": { + "serializedMesh": { + "m_SerializedMesh": "{\"mesh\":{\"instanceID\":0}}", + "m_Guid": "" + }, + "preventRotation": false + }, + "m_Path": "Shader Graphs", + "m_GraphPrecision": 1, + "m_PreviewMode": 2, + "m_OutputNode": { + "m_Id": "" + }, + "m_ActiveTargets": [ + { + "m_Id": "1e17856cccb848638b5a1829dd00d4f8" + } + ] +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.Vector3MaterialSlot", + "m_ObjectId": "008e372e323b4f7190fc81b4798c881c", + "m_Id": 0, + "m_DisplayName": "In", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "In", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_Labels": [] +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "07748643054049eea2a69011501a6a15", + "m_Id": 1, + "m_DisplayName": "Out", + "m_SlotType": 1, + "m_Hidden": false, + "m_ShaderOutputName": "Out", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 2, + "m_Type": "UnityEditor.ShaderGraph.TransformNode", + "m_ObjectId": "11320eeb0d9f4e2aaf7c881af29e9d14", + "m_Group": { + "m_Id": "" + }, + "m_Name": "Transform", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": -1783.0, + "y": 281.0, + "width": 213.0, + "height": 341.0 + } + }, + "m_Slots": [ + { + "m_Id": "008e372e323b4f7190fc81b4798c881c" + }, + { + "m_Id": "b773686d103b468db631276e1625c82c" + } + ], + "synonyms": [ + "world", + "tangent", + "object", + "view", + "screen", + "convert" + ], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + }, + "m_Conversion": { + "from": 1, + "to": 3 + }, + "m_ConversionType": 0, + "m_Normalize": false +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.SaturateNode", + "m_ObjectId": "1746ecad396f45c2808181de7c16ab2d", + "m_Group": { + "m_Id": "" + }, + "m_Name": "Saturate", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": -688.0, + "y": 2.0, + "width": 208.0, + "height": 278.0 + } + }, + "m_Slots": [ + { + "m_Id": "691ae26bade44166941282be4b9e5582" + }, + { + "m_Id": "b20bd24cda5545cba5f1e7f3fdb7868d" + } + ], + "synonyms": [ + "clamp" + ], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + } +} + +{ + "m_SGVersion": 1, + "m_Type": "UnityEditor.ShaderGraph.ShaderKeyword", + "m_ObjectId": "1bd0bd2d8a644a369163cb727342c308", + "m_Guid": { + "m_GuidSerialized": "7a8918ce-9570-4947-b06a-6445703e6938" + }, + "m_Name": "MODE", + "m_DefaultRefNameVersion": 1, + "m_RefNameGeneratedByDisplayName": "MODE", + "m_DefaultReferenceName": "_MODE", + "m_OverrideReferenceName": "", + "m_GeneratePropertyBlock": true, + "m_UseCustomSlotLabel": false, + "m_CustomSlotLabel": "", + "m_KeywordType": 1, + "m_KeywordDefinition": 0, + "m_KeywordScope": 0, + "m_KeywordStages": 63, + "m_Entries": [ + { + "id": 3, + "displayName": "DIFF", + "referenceName": "DIFF" + }, + { + "id": 1, + "displayName": "EXPECTED", + "referenceName": "EXPECTED" + }, + { + "id": 2, + "displayName": "ACTUAL", + "referenceName": "ACTUAL" + } + ], + "m_Value": 0, + "m_IsEditable": true +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "1d11b6b53cef4b47869bbb766c74c0ea", + "m_Id": 0, + "m_DisplayName": "In", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "In", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 1, + "m_Type": "UnityEditor.Rendering.Universal.ShaderGraph.UniversalTarget", + "m_ObjectId": "1e17856cccb848638b5a1829dd00d4f8", + "m_ActiveSubTarget": { + "m_Id": "416b95b32d794f768b76ab713d607602" + }, + "m_AllowMaterialOverride": false, + "m_SurfaceType": 0, + "m_ZTestMode": 4, + "m_ZWriteControl": 0, + "m_AlphaMode": 0, + "m_RenderFace": 2, + "m_AlphaClip": false, + "m_CastShadows": true, + "m_ReceiveShadows": true, + "m_CustomEditorGUI": "", + "m_SupportVFX": false +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.Vector2MaterialSlot", + "m_ObjectId": "21393da4eb4d423a8f0b10e2ec444b34", + "m_Id": 1, + "m_DisplayName": "Coord", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "Coord", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0 + }, + "m_Labels": [] +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "34ee9d276de1426ea3815b3e26e80564", + "m_Id": 1, + "m_DisplayName": "", + "m_SlotType": 1, + "m_Hidden": false, + "m_ShaderOutputName": "", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.Vector3MaterialSlot", + "m_ObjectId": "353328e353834293ac0840fb8eb6f2c8", + "m_Id": 1, + "m_DisplayName": "Out", + "m_SlotType": 1, + "m_Hidden": false, + "m_ShaderOutputName": "Out", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_Labels": [] +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "38d77b7f78e54e4e952af3311791ccd4", + "m_Id": 2, + "m_DisplayName": "Out", + "m_SlotType": 1, + "m_Hidden": false, + "m_ShaderOutputName": "Out", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.ColorRGBMaterialSlot", + "m_ObjectId": "3b6e685d10224984b1ec689fc2168cf2", + "m_Id": 0, + "m_DisplayName": "Base Color", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "BaseColor", + "m_StageCapability": 2, + "m_Value": { + "x": 0.5, + "y": 0.5, + "z": 0.5 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_Labels": [], + "m_ColorMode": 0, + "m_DefaultColor": { + "r": 0.5, + "g": 0.5, + "b": 0.5, + "a": 1.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.BlockNode", + "m_ObjectId": "3ec2632bb2694b7699d26c257e2879ea", + "m_Group": { + "m_Id": "" + }, + "m_Name": "VertexDescription.Tangent", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": 0.0, + "y": 0.0, + "width": 0.0, + "height": 0.0 + } + }, + "m_Slots": [ + { + "m_Id": "628ef29e9b5d447e9caa4531bcbe6b10" + } + ], + "synonyms": [], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + }, + "m_SerializedDescriptor": "VertexDescription.Tangent" +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.AbsoluteNode", + "m_ObjectId": "3f4fe83ebf4a492c8bd4bd8d039d4e4e", + "m_Group": { + "m_Id": "" + }, + "m_Name": "Absolute", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": -113.00003051757813, + "y": 363.0000915527344, + "width": 132.0000457763672, + "height": 93.9998779296875 + } + }, + "m_Slots": [ + { + "m_Id": "1d11b6b53cef4b47869bbb766c74c0ea" + }, + { + "m_Id": "07748643054049eea2a69011501a6a15" + } + ], + "synonyms": [ + "positive" + ], + "m_Precision": 0, + "m_PreviewExpanded": false, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.Rendering.Universal.ShaderGraph.UniversalUnlitSubTarget", + "m_ObjectId": "416b95b32d794f768b76ab713d607602" +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "42ed096a23f0457eab55df8305100690", + "m_Id": 0, + "m_DisplayName": "Out", + "m_SlotType": 1, + "m_Hidden": false, + "m_ShaderOutputName": "Out", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "44ff4c8e37d149f0a0ea59d40128711c", + "m_Id": 2, + "m_DisplayName": "T", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "T", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.AddNode", + "m_ObjectId": "49eb3060313949e8a29142442a4c029a", + "m_Group": { + "m_Id": "" + }, + "m_Name": "Add", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": -2635.999755859375, + "y": 41.00001907348633, + "width": 208.0, + "height": 302.9998779296875 + } + }, + "m_Slots": [ + { + "m_Id": "cee2261d7bcb4e288eb8e4171fa1e0b9" + }, + { + "m_Id": "c481840984234183a87b86bd85e4b13d" + }, + { + "m_Id": "6b856ac4f8634c3bae87e2ac66690f86" + } + ], + "synonyms": [ + "addition", + "sum", + "plus" + ], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.Vector3MaterialSlot", + "m_ObjectId": "4f283af276d64dac858d0947d1fdbaaa", + "m_Id": 0, + "m_DisplayName": "In", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "In", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_Labels": [] +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "50f3802c0e1d464abca40855381706b0", + "m_Id": 1, + "m_DisplayName": "", + "m_SlotType": 1, + "m_Hidden": false, + "m_ShaderOutputName": "", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.AbsoluteNode", + "m_ObjectId": "54d1e21495064ae8982ce8365d45d873", + "m_Group": { + "m_Id": "" + }, + "m_Name": "Absolute", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": -113.00003051757813, + "y": -294.9999694824219, + "width": 132.0000457763672, + "height": 94.00001525878906 + } + }, + "m_Slots": [ + { + "m_Id": "c87f1f151ea74a4995743a525e3f011b" + }, + { + "m_Id": "8331dcbe952448e3b4cf2b6523349985" + } + ], + "synonyms": [ + "positive" + ], + "m_Precision": 0, + "m_PreviewExpanded": false, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "54f4946a07ec470ab8eec9a158a27258", + "m_Id": 3, + "m_DisplayName": "Out", + "m_SlotType": 1, + "m_Hidden": false, + "m_ShaderOutputName": "Out", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "5743e9b1804044f38daa56bd9f883145", + "m_Id": 0, + "m_DisplayName": "", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "5773db1af68243e0b9bd3ef7d7e70faa", + "m_Id": 0, + "m_DisplayName": "A", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "A", + "m_StageCapability": 3, + "m_Value": { + "x": 1.0, + "y": 1.0, + "z": 1.0, + "w": 1.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "6286951a44ca42e8adf651ceec17a756", + "m_Id": 1, + "m_DisplayName": "Out", + "m_SlotType": 1, + "m_Hidden": false, + "m_ShaderOutputName": "Out", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.TangentMaterialSlot", + "m_ObjectId": "628ef29e9b5d447e9caa4531bcbe6b10", + "m_Id": 0, + "m_DisplayName": "Tangent", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "Tangent", + "m_StageCapability": 1, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_Labels": [], + "m_Space": 0 +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.BlockNode", + "m_ObjectId": "65611bc2ea7845359ab31d44dd0816ab", + "m_Group": { + "m_Id": "" + }, + "m_Name": "SurfaceDescription.BaseColor", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": 0.0, + "y": 0.0, + "width": 0.0, + "height": 0.0 + } + }, + "m_Slots": [ + { + "m_Id": "3b6e685d10224984b1ec689fc2168cf2" + } + ], + "synonyms": [], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + }, + "m_SerializedDescriptor": "SurfaceDescription.BaseColor" +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.StickyNoteData", + "m_ObjectId": "6861d370b150463a8e84fb6bf7973bdc", + "m_Title": "Purpose", + "m_Content": "Testing that a transform from space A -> space C is equivalent to a transform from space A -> space B, followed by a transfrom from space B -> space C.\n", + "m_TextSize": 0, + "m_Theme": 0, + "m_Position": { + "serializedVersion": "2", + "x": -1892.0, + "y": -407.0, + "width": 200.0, + "height": 160.0 + }, + "m_Group": { + "m_Id": "" + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "691ae26bade44166941282be4b9e5582", + "m_Id": 0, + "m_DisplayName": "In", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "In", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "6a253040a6fd42dcbf025ac7ff33aa6c", + "m_Id": 1, + "m_DisplayName": "B", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "B", + "m_StageCapability": 3, + "m_Value": { + "x": 1.0, + "y": 1.0, + "z": 1.0, + "w": 1.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "6b856ac4f8634c3bae87e2ac66690f86", + "m_Id": 2, + "m_DisplayName": "Out", + "m_SlotType": 1, + "m_Hidden": false, + "m_ShaderOutputName": "Out", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.Vector3MaterialSlot", + "m_ObjectId": "6bb1519686984d74ab200c925b9a3676", + "m_Id": 1, + "m_DisplayName": "Out", + "m_SlotType": 1, + "m_Hidden": false, + "m_ShaderOutputName": "Out", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_Labels": [] +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.RedirectNodeData", + "m_ObjectId": "6dc28149a6e2450a9b06b18a139d8695", + "m_Group": { + "m_Id": "" + }, + "m_Name": "Redirect Node", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": -1312.0001220703125, + "y": -247.9999542236328, + "width": 56.0001220703125, + "height": 23.999984741210939 + } + }, + "m_Slots": [ + { + "m_Id": "5743e9b1804044f38daa56bd9f883145" + }, + { + "m_Id": "50f3802c0e1d464abca40855381706b0" + } + ], + "synonyms": [], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "76d15710128b4ba5a42566d71f242c7e", + "m_Id": 0, + "m_DisplayName": "In", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "In", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicValueMaterialSlot", + "m_ObjectId": "78abf71b291948a891e8fa2a931cac62", + "m_Id": 0, + "m_DisplayName": "A", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "A", + "m_StageCapability": 3, + "m_Value": { + "e00": 200.0, + "e01": 0.0, + "e02": 0.0, + "e03": 0.0, + "e10": 0.0, + "e11": 0.0, + "e12": 0.0, + "e13": 0.0, + "e20": 0.0, + "e21": 0.0, + "e22": 0.0, + "e23": 0.0, + "e30": 0.0, + "e31": 0.0, + "e32": 0.0, + "e33": 0.0 + }, + "m_DefaultValue": { + "e00": 1.0, + "e01": 0.0, + "e02": 0.0, + "e03": 0.0, + "e10": 0.0, + "e11": 1.0, + "e12": 0.0, + "e13": 0.0, + "e20": 0.0, + "e21": 0.0, + "e22": 1.0, + "e23": 0.0, + "e30": 0.0, + "e31": 0.0, + "e32": 0.0, + "e33": 1.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "79c8bd704d2a4ce48efa862b75d36053", + "m_Id": 3, + "m_DisplayName": "DIFF", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "DIFF", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.CategoryData", + "m_ObjectId": "82645ecd662c4d88a7de4083a8e5b53c", + "m_Name": "", + "m_ChildObjectList": [ + { + "m_Id": "1bd0bd2d8a644a369163cb727342c308" + } + ] +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "8331dcbe952448e3b4cf2b6523349985", + "m_Id": 1, + "m_DisplayName": "Out", + "m_SlotType": 1, + "m_Hidden": false, + "m_ShaderOutputName": "Out", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.Vector3MaterialSlot", + "m_ObjectId": "8a871f1b8d354b02b2dbcf3aed00bd1d", + "m_Id": 0, + "m_DisplayName": "Hash", + "m_SlotType": 1, + "m_Hidden": false, + "m_ShaderOutputName": "Hash", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_Labels": [] +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.KeywordNode", + "m_ObjectId": "907dd0a26f124143bbc87326f74c2f54", + "m_Group": { + "m_Id": "" + }, + "m_Name": "MODE", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": 126.99999237060547, + "y": -91.0, + "width": 208.00003051757813, + "height": 326.0 + } + }, + "m_Slots": [ + { + "m_Id": "42ed096a23f0457eab55df8305100690" + }, + { + "m_Id": "79c8bd704d2a4ce48efa862b75d36053" + }, + { + "m_Id": "aec17fc7875a44f38f7d9153cf74f50f" + }, + { + "m_Id": "994474eebdcf4c66a55e6ac3838b66ce" + } + ], + "synonyms": [], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + }, + "m_Keyword": { + "m_Id": "1bd0bd2d8a644a369163cb727342c308" + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.BlockNode", + "m_ObjectId": "970cbadefd8f4fcca05f884246b4ad3e", + "m_Group": { + "m_Id": "" + }, + "m_Name": "VertexDescription.Normal", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": 0.0, + "y": 0.0, + "width": 0.0, + "height": 0.0 + } + }, + "m_Slots": [ + { + "m_Id": "d25d1af86a094ac7be2f0127f4634d7b" + } + ], + "synonyms": [], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + }, + "m_SerializedDescriptor": "VertexDescription.Normal" +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "994474eebdcf4c66a55e6ac3838b66ce", + "m_Id": 2, + "m_DisplayName": "ACTUAL", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "ACTUAL", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.ScreenPositionNode", + "m_ObjectId": "997e733a37a141d4b698281397e00d14", + "m_Group": { + "m_Id": "" + }, + "m_Name": "Screen Position", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": -2935.999755859375, + "y": 107.99995422363281, + "width": 208.0, + "height": 312.99993896484377 + } + }, + "m_Slots": [ + { + "m_Id": "ad89e0280e524d9999c12e31260bd0a2" + } + ], + "synonyms": [], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + }, + "m_ScreenSpaceType": 4 +} + +{ + "m_SGVersion": 2, + "m_Type": "UnityEditor.ShaderGraph.TransformNode", + "m_ObjectId": "9fa27d76367a4b37b0351f86e835a86e", + "m_Group": { + "m_Id": "" + }, + "m_Name": "Transform", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": -1889.0, + "y": -129.0, + "width": 213.0, + "height": 341.0000305175781 + } + }, + "m_Slots": [ + { + "m_Id": "4f283af276d64dac858d0947d1fdbaaa" + }, + { + "m_Id": "353328e353834293ac0840fb8eb6f2c8" + } + ], + "synonyms": [ + "world", + "tangent", + "object", + "view", + "screen", + "convert" + ], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + }, + "m_Conversion": { + "from": 0, + "to": 3 + }, + "m_ConversionType": 0, + "m_Normalize": false +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicValueMaterialSlot", + "m_ObjectId": "a6ad0619b0ff4b35b9c068ac56819033", + "m_Id": 2, + "m_DisplayName": "Out", + "m_SlotType": 1, + "m_Hidden": false, + "m_ShaderOutputName": "Out", + "m_StageCapability": 3, + "m_Value": { + "e00": 0.0, + "e01": 0.0, + "e02": 0.0, + "e03": 0.0, + "e10": 0.0, + "e11": 0.0, + "e12": 0.0, + "e13": 0.0, + "e20": 0.0, + "e21": 0.0, + "e22": 0.0, + "e23": 0.0, + "e30": 0.0, + "e31": 0.0, + "e32": 0.0, + "e33": 0.0 + }, + "m_DefaultValue": { + "e00": 1.0, + "e01": 0.0, + "e02": 0.0, + "e03": 0.0, + "e10": 0.0, + "e11": 1.0, + "e12": 0.0, + "e13": 0.0, + "e20": 0.0, + "e21": 0.0, + "e22": 1.0, + "e23": 0.0, + "e30": 0.0, + "e31": 0.0, + "e32": 0.0, + "e33": 1.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.Vector4MaterialSlot", + "m_ObjectId": "ad89e0280e524d9999c12e31260bd0a2", + "m_Id": 0, + "m_DisplayName": "Out", + "m_SlotType": 1, + "m_Hidden": false, + "m_ShaderOutputName": "Out", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_Labels": [] +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "aec17fc7875a44f38f7d9153cf74f50f", + "m_Id": 1, + "m_DisplayName": "EXPECTED", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "EXPECTED", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.LerpNode", + "m_ObjectId": "afd6fed3d8e8461c9ac141b19e55e04d", + "m_Group": { + "m_Id": "" + }, + "m_Name": "Lerp", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": -321.0, + "y": -86.99998474121094, + "width": 207.99998474121095, + "height": 326.0 + } + }, + "m_Slots": [ + { + "m_Id": "d0bc4074e39847c09e25d45223ff7f12" + }, + { + "m_Id": "fefaeb0050de4b00a9a812607dec2e12" + }, + { + "m_Id": "44ff4c8e37d149f0a0ea59d40128711c" + }, + { + "m_Id": "54f4946a07ec470ab8eec9a158a27258" + } + ], + "synonyms": [ + "mix", + "blend", + "linear interpolate" + ], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "b20bd24cda5545cba5f1e7f3fdb7868d", + "m_Id": 1, + "m_DisplayName": "Out", + "m_SlotType": 1, + "m_Hidden": false, + "m_ShaderOutputName": "Out", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.Vector3MaterialSlot", + "m_ObjectId": "b773686d103b468db631276e1625c82c", + "m_Id": 1, + "m_DisplayName": "Out", + "m_SlotType": 1, + "m_Hidden": false, + "m_ShaderOutputName": "Out", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_Labels": [] +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "c481840984234183a87b86bd85e4b13d", + "m_Id": 1, + "m_DisplayName": "B", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "B", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "c87f1f151ea74a4995743a525e3f011b", + "m_Id": 0, + "m_DisplayName": "In", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "In", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.MultiplyNode", + "m_ObjectId": "cd74f48ac90a40f49890cd16fbf6660a", + "m_Group": { + "m_Id": "" + }, + "m_Name": "Multiply", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": -896.0, + "y": 2.0, + "width": 208.0, + "height": 302.0 + } + }, + "m_Slots": [ + { + "m_Id": "78abf71b291948a891e8fa2a931cac62" + }, + { + "m_Id": "df63aca4443847ec96ffc346ffd297b7" + }, + { + "m_Id": "a6ad0619b0ff4b35b9c068ac56819033" + } + ], + "synonyms": [ + "multiplication", + "times", + "x" + ], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "cee2261d7bcb4e288eb8e4171fa1e0b9", + "m_Id": 0, + "m_DisplayName": "A", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "A", + "m_StageCapability": 3, + "m_Value": { + "x": 0.5, + "y": 0.5, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "d0bc4074e39847c09e25d45223ff7f12", + "m_Id": 0, + "m_DisplayName": "A", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "A", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 1.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.NormalMaterialSlot", + "m_ObjectId": "d25d1af86a094ac7be2f0127f4634d7b", + "m_Id": 0, + "m_DisplayName": "Normal", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "Normal", + "m_StageCapability": 1, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_Labels": [], + "m_Space": 0 +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.SubtractNode", + "m_ObjectId": "d5c0ffaecc9d45f986de4d8925bc0051", + "m_Group": { + "m_Id": "" + }, + "m_Name": "Subtract", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": -1312.0, + "y": 3.0000650882720949, + "width": 208.0, + "height": 302.0 + } + }, + "m_Slots": [ + { + "m_Id": "5773db1af68243e0b9bd3ef7d7e70faa" + }, + { + "m_Id": "6a253040a6fd42dcbf025ac7ff33aa6c" + }, + { + "m_Id": "38d77b7f78e54e4e952af3311791ccd4" + } + ], + "synonyms": [ + "subtraction", + "remove", + "minus", + "take away" + ], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.IntegerHashNode", + "m_ObjectId": "d7fc69d9fbd84fe5b18d4361e39b39b9", + "m_Group": { + "m_Id": "" + }, + "m_Name": "Integer Hash", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": -2386.999755859375, + "y": 107.99995422363281, + "width": 207.999755859375, + "height": 312.99993896484377 + } + }, + "m_Slots": [ + { + "m_Id": "21393da4eb4d423a8f0b10e2ec444b34" + }, + { + "m_Id": "8a871f1b8d354b02b2dbcf3aed00bd1d" + } + ], + "synonyms": [], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + }, + "m_HashType": 1 +} + +{ + "m_SGVersion": 2, + "m_Type": "UnityEditor.ShaderGraph.TransformNode", + "m_ObjectId": "de1092b024884fdf9e8a5171a48ef13e", + "m_Group": { + "m_Id": "" + }, + "m_Name": "Transform", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": -1996.0, + "y": 281.0, + "width": 213.0, + "height": 341.0 + } + }, + "m_Slots": [ + { + "m_Id": "e52abb26e3ba40958f14752a649a892c" + }, + { + "m_Id": "6bb1519686984d74ab200c925b9a3676" + } + ], + "synonyms": [ + "world", + "tangent", + "object", + "view", + "screen", + "convert" + ], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + }, + "m_Conversion": { + "from": 0, + "to": 1 + }, + "m_ConversionType": 0, + "m_Normalize": false +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicValueMaterialSlot", + "m_ObjectId": "df63aca4443847ec96ffc346ffd297b7", + "m_Id": 1, + "m_DisplayName": "B", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "B", + "m_StageCapability": 3, + "m_Value": { + "e00": 200.0, + "e01": 200.0, + "e02": 200.0, + "e03": 2.0, + "e10": 2.0, + "e11": 2.0, + "e12": 2.0, + "e13": 2.0, + "e20": 2.0, + "e21": 2.0, + "e22": 2.0, + "e23": 2.0, + "e30": 2.0, + "e31": 2.0, + "e32": 2.0, + "e33": 2.0 + }, + "m_DefaultValue": { + "e00": 1.0, + "e01": 0.0, + "e02": 0.0, + "e03": 0.0, + "e10": 0.0, + "e11": 1.0, + "e12": 0.0, + "e13": 0.0, + "e20": 0.0, + "e21": 0.0, + "e22": 1.0, + "e23": 0.0, + "e30": 0.0, + "e31": 0.0, + "e32": 0.0, + "e33": 1.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.Vector3MaterialSlot", + "m_ObjectId": "e52abb26e3ba40958f14752a649a892c", + "m_Id": 0, + "m_DisplayName": "In", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "In", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_Labels": [] +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "e6aff6e4a9b14ff7827921e6353a87a3", + "m_Id": 0, + "m_DisplayName": "", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.StickyNoteData", + "m_ObjectId": "ebeb58a811964ae1ae55c9969cd6e146", + "m_Title": "Note", + "m_Content": "Since screen position is 0.5 centered, the round on the integer hash is sitting right on the boundary which is unstable.\nWe give it a bit of a push to one side to make sure it's deterministic.\n", + "m_TextSize": 0, + "m_Theme": 0, + "m_Position": { + "serializedVersion": "2", + "x": -2630.0, + "y": -133.0, + "width": 200.0, + "height": 172.0 + }, + "m_Group": { + "m_Id": "" + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.AbsoluteNode", + "m_ObjectId": "fa72769f37e54f599d367774a779d845", + "m_Group": { + "m_Id": "" + }, + "m_Name": "Absolute", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": -1104.0, + "y": 3.0000650882720949, + "width": 207.9998779296875, + "height": 278.0 + } + }, + "m_Slots": [ + { + "m_Id": "76d15710128b4ba5a42566d71f242c7e" + }, + { + "m_Id": "6286951a44ca42e8adf651ceec17a756" + } + ], + "synonyms": [ + "positive" + ], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.BlockNode", + "m_ObjectId": "fc28a5ef65284ed0967870ff69516ffe", + "m_Group": { + "m_Id": "" + }, + "m_Name": "VertexDescription.Position", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": 0.0, + "y": 0.0, + "width": 0.0, + "height": 0.0 + } + }, + "m_Slots": [ + { + "m_Id": "fc66c175daa9462fa1430c43a99d7698" + } + ], + "synonyms": [], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + }, + "m_SerializedDescriptor": "VertexDescription.Position" +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.PositionMaterialSlot", + "m_ObjectId": "fc66c175daa9462fa1430c43a99d7698", + "m_Id": 0, + "m_DisplayName": "Position", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "Position", + "m_StageCapability": 1, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_Labels": [], + "m_Space": 0 +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "fefaeb0050de4b00a9a812607dec2e12", + "m_Id": 1, + "m_DisplayName": "B", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "B", + "m_StageCapability": 3, + "m_Value": { + "x": 1.0, + "y": 0.0, + "z": 0.0, + "w": 1.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.RedirectNodeData", + "m_ObjectId": "ffde04b05e2c42f38093d4ddd027315b", + "m_Group": { + "m_Id": "" + }, + "m_Name": "Redirect Node", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": -1286.0001220703125, + "y": 410.00006103515627, + "width": 56.0001220703125, + "height": 23.999969482421876 + } + }, + "m_Slots": [ + { + "m_Id": "e6aff6e4a9b14ff7827921e6353a87a3" + }, + { + "m_Id": "34ee9d276de1426ea3815b3e26e80564" + } + ], + "synonyms": [], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + } +} + diff --git a/TestProjects/ShaderGraph/Assets/CommonAssets/Graphs/NodeTests/TransformABC.shadergraph.meta b/TestProjects/ShaderGraph/Assets/CommonAssets/Graphs/NodeTests/TransformABC.shadergraph.meta new file mode 100644 index 00000000000..cdd8a798c5b --- /dev/null +++ b/TestProjects/ShaderGraph/Assets/CommonAssets/Graphs/NodeTests/TransformABC.shadergraph.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 3f6802084604c8643adedcba5bde5df7 +ScriptedImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 2 + userData: + assetBundleName: + assetBundleVariant: + script: {fileID: 11500000, guid: 625f186215c104763be7675aa2d941aa, type: 3} diff --git a/TestProjects/ShaderGraph/Assets/CommonAssets/Graphs/NodeTests/TransformInverses.shadergraph b/TestProjects/ShaderGraph/Assets/CommonAssets/Graphs/NodeTests/TransformInverses.shadergraph new file mode 100644 index 00000000000..c2e3c1de5ca --- /dev/null +++ b/TestProjects/ShaderGraph/Assets/CommonAssets/Graphs/NodeTests/TransformInverses.shadergraph @@ -0,0 +1,2366 @@ +{ + "m_SGVersion": 3, + "m_Type": "UnityEditor.ShaderGraph.GraphData", + "m_ObjectId": "d3a578d5f6c048d989f4fc22763a096c", + "m_Properties": [], + "m_Keywords": [ + { + "m_Id": "1bd0bd2d8a644a369163cb727342c308" + } + ], + "m_Dropdowns": [], + "m_CategoryData": [ + { + "m_Id": "82645ecd662c4d88a7de4083a8e5b53c" + } + ], + "m_Nodes": [ + { + "m_Id": "fc28a5ef65284ed0967870ff69516ffe" + }, + { + "m_Id": "970cbadefd8f4fcca05f884246b4ad3e" + }, + { + "m_Id": "3ec2632bb2694b7699d26c257e2879ea" + }, + { + "m_Id": "65611bc2ea7845359ab31d44dd0816ab" + }, + { + "m_Id": "d7fc69d9fbd84fe5b18d4361e39b39b9" + }, + { + "m_Id": "997e733a37a141d4b698281397e00d14" + }, + { + "m_Id": "d5c0ffaecc9d45f986de4d8925bc0051" + }, + { + "m_Id": "de1092b024884fdf9e8a5171a48ef13e" + }, + { + "m_Id": "fa72769f37e54f599d367774a779d845" + }, + { + "m_Id": "cd74f48ac90a40f49890cd16fbf6660a" + }, + { + "m_Id": "afd6fed3d8e8461c9ac141b19e55e04d" + }, + { + "m_Id": "1746ecad396f45c2808181de7c16ab2d" + }, + { + "m_Id": "907dd0a26f124143bbc87326f74c2f54" + }, + { + "m_Id": "54d1e21495064ae8982ce8365d45d873" + }, + { + "m_Id": "3f4fe83ebf4a492c8bd4bd8d039d4e4e" + }, + { + "m_Id": "ffde04b05e2c42f38093d4ddd027315b" + }, + { + "m_Id": "6dc28149a6e2450a9b06b18a139d8695" + }, + { + "m_Id": "49eb3060313949e8a29142442a4c029a" + }, + { + "m_Id": "4303390d71784ac2ac6443638dc5aaae" + }, + { + "m_Id": "11320eeb0d9f4e2aaf7c881af29e9d14" + } + ], + "m_GroupDatas": [], + "m_StickyNoteDatas": [ + { + "m_Id": "ebeb58a811964ae1ae55c9969cd6e146" + }, + { + "m_Id": "4e585c78521e42b7a2565e9e062786fc" + } + ], + "m_Edges": [ + { + "m_OutputSlot": { + "m_Node": { + "m_Id": "11320eeb0d9f4e2aaf7c881af29e9d14" + }, + "m_SlotId": 1 + }, + "m_InputSlot": { + "m_Node": { + "m_Id": "d5c0ffaecc9d45f986de4d8925bc0051" + }, + "m_SlotId": 1 + } + }, + { + "m_OutputSlot": { + "m_Node": { + "m_Id": "11320eeb0d9f4e2aaf7c881af29e9d14" + }, + "m_SlotId": 1 + }, + "m_InputSlot": { + "m_Node": { + "m_Id": "ffde04b05e2c42f38093d4ddd027315b" + }, + "m_SlotId": 0 + } + }, + { + "m_OutputSlot": { + "m_Node": { + "m_Id": "1746ecad396f45c2808181de7c16ab2d" + }, + "m_SlotId": 1 + }, + "m_InputSlot": { + "m_Node": { + "m_Id": "afd6fed3d8e8461c9ac141b19e55e04d" + }, + "m_SlotId": 2 + } + }, + { + "m_OutputSlot": { + "m_Node": { + "m_Id": "3f4fe83ebf4a492c8bd4bd8d039d4e4e" + }, + "m_SlotId": 1 + }, + "m_InputSlot": { + "m_Node": { + "m_Id": "907dd0a26f124143bbc87326f74c2f54" + }, + "m_SlotId": 2 + } + }, + { + "m_OutputSlot": { + "m_Node": { + "m_Id": "4303390d71784ac2ac6443638dc5aaae" + }, + "m_SlotId": 1 + }, + "m_InputSlot": { + "m_Node": { + "m_Id": "6dc28149a6e2450a9b06b18a139d8695" + }, + "m_SlotId": 0 + } + }, + { + "m_OutputSlot": { + "m_Node": { + "m_Id": "4303390d71784ac2ac6443638dc5aaae" + }, + "m_SlotId": 1 + }, + "m_InputSlot": { + "m_Node": { + "m_Id": "d5c0ffaecc9d45f986de4d8925bc0051" + }, + "m_SlotId": 0 + } + }, + { + "m_OutputSlot": { + "m_Node": { + "m_Id": "49eb3060313949e8a29142442a4c029a" + }, + "m_SlotId": 2 + }, + "m_InputSlot": { + "m_Node": { + "m_Id": "d7fc69d9fbd84fe5b18d4361e39b39b9" + }, + "m_SlotId": 1 + } + }, + { + "m_OutputSlot": { + "m_Node": { + "m_Id": "54d1e21495064ae8982ce8365d45d873" + }, + "m_SlotId": 1 + }, + "m_InputSlot": { + "m_Node": { + "m_Id": "907dd0a26f124143bbc87326f74c2f54" + }, + "m_SlotId": 1 + } + }, + { + "m_OutputSlot": { + "m_Node": { + "m_Id": "6dc28149a6e2450a9b06b18a139d8695" + }, + "m_SlotId": 1 + }, + "m_InputSlot": { + "m_Node": { + "m_Id": "54d1e21495064ae8982ce8365d45d873" + }, + "m_SlotId": 0 + } + }, + { + "m_OutputSlot": { + "m_Node": { + "m_Id": "907dd0a26f124143bbc87326f74c2f54" + }, + "m_SlotId": 0 + }, + "m_InputSlot": { + "m_Node": { + "m_Id": "65611bc2ea7845359ab31d44dd0816ab" + }, + "m_SlotId": 0 + } + }, + { + "m_OutputSlot": { + "m_Node": { + "m_Id": "997e733a37a141d4b698281397e00d14" + }, + "m_SlotId": 0 + }, + "m_InputSlot": { + "m_Node": { + "m_Id": "49eb3060313949e8a29142442a4c029a" + }, + "m_SlotId": 1 + } + }, + { + "m_OutputSlot": { + "m_Node": { + "m_Id": "afd6fed3d8e8461c9ac141b19e55e04d" + }, + "m_SlotId": 3 + }, + "m_InputSlot": { + "m_Node": { + "m_Id": "907dd0a26f124143bbc87326f74c2f54" + }, + "m_SlotId": 3 + } + }, + { + "m_OutputSlot": { + "m_Node": { + "m_Id": "cd74f48ac90a40f49890cd16fbf6660a" + }, + "m_SlotId": 2 + }, + "m_InputSlot": { + "m_Node": { + "m_Id": "1746ecad396f45c2808181de7c16ab2d" + }, + "m_SlotId": 0 + } + }, + { + "m_OutputSlot": { + "m_Node": { + "m_Id": "d5c0ffaecc9d45f986de4d8925bc0051" + }, + "m_SlotId": 2 + }, + "m_InputSlot": { + "m_Node": { + "m_Id": "fa72769f37e54f599d367774a779d845" + }, + "m_SlotId": 0 + } + }, + { + "m_OutputSlot": { + "m_Node": { + "m_Id": "d7fc69d9fbd84fe5b18d4361e39b39b9" + }, + "m_SlotId": 0 + }, + "m_InputSlot": { + "m_Node": { + "m_Id": "4303390d71784ac2ac6443638dc5aaae" + }, + "m_SlotId": 0 + } + }, + { + "m_OutputSlot": { + "m_Node": { + "m_Id": "d7fc69d9fbd84fe5b18d4361e39b39b9" + }, + "m_SlotId": 0 + }, + "m_InputSlot": { + "m_Node": { + "m_Id": "de1092b024884fdf9e8a5171a48ef13e" + }, + "m_SlotId": 0 + } + }, + { + "m_OutputSlot": { + "m_Node": { + "m_Id": "de1092b024884fdf9e8a5171a48ef13e" + }, + "m_SlotId": 1 + }, + "m_InputSlot": { + "m_Node": { + "m_Id": "11320eeb0d9f4e2aaf7c881af29e9d14" + }, + "m_SlotId": 0 + } + }, + { + "m_OutputSlot": { + "m_Node": { + "m_Id": "fa72769f37e54f599d367774a779d845" + }, + "m_SlotId": 1 + }, + "m_InputSlot": { + "m_Node": { + "m_Id": "cd74f48ac90a40f49890cd16fbf6660a" + }, + "m_SlotId": 0 + } + }, + { + "m_OutputSlot": { + "m_Node": { + "m_Id": "ffde04b05e2c42f38093d4ddd027315b" + }, + "m_SlotId": 1 + }, + "m_InputSlot": { + "m_Node": { + "m_Id": "3f4fe83ebf4a492c8bd4bd8d039d4e4e" + }, + "m_SlotId": 0 + } + } + ], + "m_VertexContext": { + "m_Position": { + "x": 362.00006103515627, + "y": -291.0 + }, + "m_Blocks": [ + { + "m_Id": "fc28a5ef65284ed0967870ff69516ffe" + }, + { + "m_Id": "970cbadefd8f4fcca05f884246b4ad3e" + }, + { + "m_Id": "3ec2632bb2694b7699d26c257e2879ea" + } + ] + }, + "m_FragmentContext": { + "m_Position": { + "x": 362.00006103515627, + "y": -91.0 + }, + "m_Blocks": [ + { + "m_Id": "65611bc2ea7845359ab31d44dd0816ab" + } + ] + }, + "m_PreviewData": { + "serializedMesh": { + "m_SerializedMesh": "{\"mesh\":{\"instanceID\":0}}", + "m_Guid": "" + }, + "preventRotation": false + }, + "m_Path": "Shader Graphs", + "m_GraphPrecision": 1, + "m_PreviewMode": 2, + "m_OutputNode": { + "m_Id": "" + }, + "m_ActiveTargets": [ + { + "m_Id": "1e17856cccb848638b5a1829dd00d4f8" + } + ] +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.Vector3MaterialSlot", + "m_ObjectId": "008e372e323b4f7190fc81b4798c881c", + "m_Id": 0, + "m_DisplayName": "In", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "In", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_Labels": [] +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "07748643054049eea2a69011501a6a15", + "m_Id": 1, + "m_DisplayName": "Out", + "m_SlotType": 1, + "m_Hidden": false, + "m_ShaderOutputName": "Out", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "0feeb8b29d1e419eace88f822f0989c2", + "m_Id": 3, + "m_DisplayName": "DIFF", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "DIFF", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 2, + "m_Type": "UnityEditor.ShaderGraph.TransformNode", + "m_ObjectId": "11320eeb0d9f4e2aaf7c881af29e9d14", + "m_Group": { + "m_Id": "" + }, + "m_Name": "Transform", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": -1783.0, + "y": 281.0, + "width": 213.0, + "height": 341.0 + } + }, + "m_Slots": [ + { + "m_Id": "008e372e323b4f7190fc81b4798c881c" + }, + { + "m_Id": "b773686d103b468db631276e1625c82c" + } + ], + "synonyms": [ + "world", + "tangent", + "object", + "view", + "screen", + "convert" + ], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + }, + "m_Conversion": { + "from": 4, + "to": 1 + }, + "m_ConversionType": 0, + "m_Normalize": false +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "156a815141254f84a321db112c7b7771", + "m_Id": 0, + "m_DisplayName": "", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.SaturateNode", + "m_ObjectId": "1746ecad396f45c2808181de7c16ab2d", + "m_Group": { + "m_Id": "" + }, + "m_Name": "Saturate", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": -688.0, + "y": 2.0, + "width": 208.0, + "height": 278.0 + } + }, + "m_Slots": [ + { + "m_Id": "691ae26bade44166941282be4b9e5582" + }, + { + "m_Id": "b20bd24cda5545cba5f1e7f3fdb7868d" + } + ], + "synonyms": [ + "clamp" + ], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + } +} + +{ + "m_SGVersion": 1, + "m_Type": "UnityEditor.ShaderGraph.ShaderKeyword", + "m_ObjectId": "1bd0bd2d8a644a369163cb727342c308", + "m_Guid": { + "m_GuidSerialized": "7a8918ce-9570-4947-b06a-6445703e6938" + }, + "m_Name": "MODE", + "m_DefaultRefNameVersion": 1, + "m_RefNameGeneratedByDisplayName": "MODE", + "m_DefaultReferenceName": "_MODE", + "m_OverrideReferenceName": "", + "m_GeneratePropertyBlock": true, + "m_UseCustomSlotLabel": false, + "m_CustomSlotLabel": "", + "m_KeywordType": 1, + "m_KeywordDefinition": 0, + "m_KeywordScope": 0, + "m_KeywordStages": 63, + "m_Entries": [ + { + "id": 3, + "displayName": "DIFF", + "referenceName": "DIFF" + }, + { + "id": 1, + "displayName": "EXPECTED", + "referenceName": "EXPECTED" + }, + { + "id": 2, + "displayName": "ACTUAL", + "referenceName": "ACTUAL" + } + ], + "m_Value": 0, + "m_IsEditable": true +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "1d11b6b53cef4b47869bbb766c74c0ea", + "m_Id": 0, + "m_DisplayName": "In", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "In", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 1, + "m_Type": "UnityEditor.Rendering.Universal.ShaderGraph.UniversalTarget", + "m_ObjectId": "1e17856cccb848638b5a1829dd00d4f8", + "m_ActiveSubTarget": { + "m_Id": "416b95b32d794f768b76ab713d607602" + }, + "m_AllowMaterialOverride": false, + "m_SurfaceType": 0, + "m_ZTestMode": 4, + "m_ZWriteControl": 0, + "m_AlphaMode": 0, + "m_RenderFace": 2, + "m_AlphaClip": false, + "m_CastShadows": true, + "m_ReceiveShadows": true, + "m_CustomEditorGUI": "", + "m_SupportVFX": false +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.Vector2MaterialSlot", + "m_ObjectId": "21393da4eb4d423a8f0b10e2ec444b34", + "m_Id": 1, + "m_DisplayName": "Coord", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "Coord", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0 + }, + "m_Labels": [] +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "311522a28e9843e8a1f5e8b38b3ea247", + "m_Id": 1, + "m_DisplayName": "", + "m_SlotType": 1, + "m_Hidden": false, + "m_ShaderOutputName": "", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "34ee9d276de1426ea3815b3e26e80564", + "m_Id": 1, + "m_DisplayName": "", + "m_SlotType": 1, + "m_Hidden": false, + "m_ShaderOutputName": "", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "38d77b7f78e54e4e952af3311791ccd4", + "m_Id": 2, + "m_DisplayName": "Out", + "m_SlotType": 1, + "m_Hidden": false, + "m_ShaderOutputName": "Out", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.ColorRGBMaterialSlot", + "m_ObjectId": "3b6e685d10224984b1ec689fc2168cf2", + "m_Id": 0, + "m_DisplayName": "Base Color", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "BaseColor", + "m_StageCapability": 2, + "m_Value": { + "x": 0.5, + "y": 0.5, + "z": 0.5 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_Labels": [], + "m_ColorMode": 0, + "m_DefaultColor": { + "r": 0.5, + "g": 0.5, + "b": 0.5, + "a": 1.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.BlockNode", + "m_ObjectId": "3ec2632bb2694b7699d26c257e2879ea", + "m_Group": { + "m_Id": "" + }, + "m_Name": "VertexDescription.Tangent", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": 0.0, + "y": 0.0, + "width": 0.0, + "height": 0.0 + } + }, + "m_Slots": [ + { + "m_Id": "628ef29e9b5d447e9caa4531bcbe6b10" + } + ], + "synonyms": [], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + }, + "m_SerializedDescriptor": "VertexDescription.Tangent" +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.AbsoluteNode", + "m_ObjectId": "3f4fe83ebf4a492c8bd4bd8d039d4e4e", + "m_Group": { + "m_Id": "" + }, + "m_Name": "Absolute", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": -113.00003051757813, + "y": 363.0000915527344, + "width": 132.0000457763672, + "height": 93.9998779296875 + } + }, + "m_Slots": [ + { + "m_Id": "1d11b6b53cef4b47869bbb766c74c0ea" + }, + { + "m_Id": "07748643054049eea2a69011501a6a15" + } + ], + "synonyms": [ + "positive" + ], + "m_Precision": 0, + "m_PreviewExpanded": false, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.Rendering.Universal.ShaderGraph.UniversalUnlitSubTarget", + "m_ObjectId": "416b95b32d794f768b76ab713d607602" +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "42ed096a23f0457eab55df8305100690", + "m_Id": 0, + "m_DisplayName": "Out", + "m_SlotType": 1, + "m_Hidden": false, + "m_ShaderOutputName": "Out", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.RedirectNodeData", + "m_ObjectId": "4303390d71784ac2ac6443638dc5aaae", + "m_Group": { + "m_Id": "" + }, + "m_Name": "Redirect Node", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": -1782.9998779296875, + "y": -102.9999008178711, + "width": 56.0001220703125, + "height": 24.0 + } + }, + "m_Slots": [ + { + "m_Id": "156a815141254f84a321db112c7b7771" + }, + { + "m_Id": "311522a28e9843e8a1f5e8b38b3ea247" + } + ], + "synonyms": [], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "44ff4c8e37d149f0a0ea59d40128711c", + "m_Id": 2, + "m_DisplayName": "T", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "T", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.AddNode", + "m_ObjectId": "49eb3060313949e8a29142442a4c029a", + "m_Group": { + "m_Id": "" + }, + "m_Name": "Add", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": -2635.999755859375, + "y": 41.00001907348633, + "width": 208.0, + "height": 302.9998779296875 + } + }, + "m_Slots": [ + { + "m_Id": "cee2261d7bcb4e288eb8e4171fa1e0b9" + }, + { + "m_Id": "c481840984234183a87b86bd85e4b13d" + }, + { + "m_Id": "6b856ac4f8634c3bae87e2ac66690f86" + } + ], + "synonyms": [ + "addition", + "sum", + "plus" + ], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.StickyNoteData", + "m_ObjectId": "4e585c78521e42b7a2565e9e062786fc", + "m_Title": "Purpose", + "m_Content": "Testing that a transfom, followed by it's inverse, is equivalent to the original value (when not normalized)", + "m_TextSize": 0, + "m_Theme": 0, + "m_Position": { + "serializedVersion": "2", + "x": -1834.0, + "y": -393.0, + "width": 200.0, + "height": 160.0 + }, + "m_Group": { + "m_Id": "" + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "50f3802c0e1d464abca40855381706b0", + "m_Id": 1, + "m_DisplayName": "", + "m_SlotType": 1, + "m_Hidden": false, + "m_ShaderOutputName": "", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.AbsoluteNode", + "m_ObjectId": "54d1e21495064ae8982ce8365d45d873", + "m_Group": { + "m_Id": "" + }, + "m_Name": "Absolute", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": -113.00003051757813, + "y": -294.9999694824219, + "width": 132.0000457763672, + "height": 94.00001525878906 + } + }, + "m_Slots": [ + { + "m_Id": "c87f1f151ea74a4995743a525e3f011b" + }, + { + "m_Id": "8331dcbe952448e3b4cf2b6523349985" + } + ], + "synonyms": [ + "positive" + ], + "m_Precision": 0, + "m_PreviewExpanded": false, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "54f4946a07ec470ab8eec9a158a27258", + "m_Id": 3, + "m_DisplayName": "Out", + "m_SlotType": 1, + "m_Hidden": false, + "m_ShaderOutputName": "Out", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "5743e9b1804044f38daa56bd9f883145", + "m_Id": 0, + "m_DisplayName": "", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "5773db1af68243e0b9bd3ef7d7e70faa", + "m_Id": 0, + "m_DisplayName": "A", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "A", + "m_StageCapability": 3, + "m_Value": { + "x": 1.0, + "y": 1.0, + "z": 1.0, + "w": 1.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "6286951a44ca42e8adf651ceec17a756", + "m_Id": 1, + "m_DisplayName": "Out", + "m_SlotType": 1, + "m_Hidden": false, + "m_ShaderOutputName": "Out", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.TangentMaterialSlot", + "m_ObjectId": "628ef29e9b5d447e9caa4531bcbe6b10", + "m_Id": 0, + "m_DisplayName": "Tangent", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "Tangent", + "m_StageCapability": 1, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_Labels": [], + "m_Space": 0 +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.BlockNode", + "m_ObjectId": "65611bc2ea7845359ab31d44dd0816ab", + "m_Group": { + "m_Id": "" + }, + "m_Name": "SurfaceDescription.BaseColor", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": 0.0, + "y": 0.0, + "width": 0.0, + "height": 0.0 + } + }, + "m_Slots": [ + { + "m_Id": "3b6e685d10224984b1ec689fc2168cf2" + } + ], + "synonyms": [], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + }, + "m_SerializedDescriptor": "SurfaceDescription.BaseColor" +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "691ae26bade44166941282be4b9e5582", + "m_Id": 0, + "m_DisplayName": "In", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "In", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "6a253040a6fd42dcbf025ac7ff33aa6c", + "m_Id": 1, + "m_DisplayName": "B", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "B", + "m_StageCapability": 3, + "m_Value": { + "x": 1.0, + "y": 1.0, + "z": 1.0, + "w": 1.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "6b856ac4f8634c3bae87e2ac66690f86", + "m_Id": 2, + "m_DisplayName": "Out", + "m_SlotType": 1, + "m_Hidden": false, + "m_ShaderOutputName": "Out", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.Vector3MaterialSlot", + "m_ObjectId": "6bb1519686984d74ab200c925b9a3676", + "m_Id": 1, + "m_DisplayName": "Out", + "m_SlotType": 1, + "m_Hidden": false, + "m_ShaderOutputName": "Out", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_Labels": [] +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.RedirectNodeData", + "m_ObjectId": "6dc28149a6e2450a9b06b18a139d8695", + "m_Group": { + "m_Id": "" + }, + "m_Name": "Redirect Node", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": -1312.0001220703125, + "y": -247.9999542236328, + "width": 56.0001220703125, + "height": 23.999984741210939 + } + }, + "m_Slots": [ + { + "m_Id": "5743e9b1804044f38daa56bd9f883145" + }, + { + "m_Id": "50f3802c0e1d464abca40855381706b0" + } + ], + "synonyms": [], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "76d15710128b4ba5a42566d71f242c7e", + "m_Id": 0, + "m_DisplayName": "In", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "In", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicValueMaterialSlot", + "m_ObjectId": "78abf71b291948a891e8fa2a931cac62", + "m_Id": 0, + "m_DisplayName": "A", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "A", + "m_StageCapability": 3, + "m_Value": { + "e00": 200.0, + "e01": 0.0, + "e02": 0.0, + "e03": 0.0, + "e10": 0.0, + "e11": 0.0, + "e12": 0.0, + "e13": 0.0, + "e20": 0.0, + "e21": 0.0, + "e22": 0.0, + "e23": 0.0, + "e30": 0.0, + "e31": 0.0, + "e32": 0.0, + "e33": 0.0 + }, + "m_DefaultValue": { + "e00": 1.0, + "e01": 0.0, + "e02": 0.0, + "e03": 0.0, + "e10": 0.0, + "e11": 1.0, + "e12": 0.0, + "e13": 0.0, + "e20": 0.0, + "e21": 0.0, + "e22": 1.0, + "e23": 0.0, + "e30": 0.0, + "e31": 0.0, + "e32": 0.0, + "e33": 1.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.CategoryData", + "m_ObjectId": "82645ecd662c4d88a7de4083a8e5b53c", + "m_Name": "", + "m_ChildObjectList": [ + { + "m_Id": "1bd0bd2d8a644a369163cb727342c308" + } + ] +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "8331dcbe952448e3b4cf2b6523349985", + "m_Id": 1, + "m_DisplayName": "Out", + "m_SlotType": 1, + "m_Hidden": false, + "m_ShaderOutputName": "Out", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.Vector3MaterialSlot", + "m_ObjectId": "8a871f1b8d354b02b2dbcf3aed00bd1d", + "m_Id": 0, + "m_DisplayName": "Hash", + "m_SlotType": 1, + "m_Hidden": false, + "m_ShaderOutputName": "Hash", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_Labels": [] +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.KeywordNode", + "m_ObjectId": "907dd0a26f124143bbc87326f74c2f54", + "m_Group": { + "m_Id": "" + }, + "m_Name": "MODE", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": 126.99999237060547, + "y": -91.0, + "width": 208.00003051757813, + "height": 326.0 + } + }, + "m_Slots": [ + { + "m_Id": "42ed096a23f0457eab55df8305100690" + }, + { + "m_Id": "0feeb8b29d1e419eace88f822f0989c2" + }, + { + "m_Id": "aec17fc7875a44f38f7d9153cf74f50f" + }, + { + "m_Id": "994474eebdcf4c66a55e6ac3838b66ce" + } + ], + "synonyms": [], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + }, + "m_Keyword": { + "m_Id": "1bd0bd2d8a644a369163cb727342c308" + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.BlockNode", + "m_ObjectId": "970cbadefd8f4fcca05f884246b4ad3e", + "m_Group": { + "m_Id": "" + }, + "m_Name": "VertexDescription.Normal", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": 0.0, + "y": 0.0, + "width": 0.0, + "height": 0.0 + } + }, + "m_Slots": [ + { + "m_Id": "d25d1af86a094ac7be2f0127f4634d7b" + } + ], + "synonyms": [], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + }, + "m_SerializedDescriptor": "VertexDescription.Normal" +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "994474eebdcf4c66a55e6ac3838b66ce", + "m_Id": 2, + "m_DisplayName": "ACTUAL", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "ACTUAL", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.ScreenPositionNode", + "m_ObjectId": "997e733a37a141d4b698281397e00d14", + "m_Group": { + "m_Id": "" + }, + "m_Name": "Screen Position", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": -2935.999755859375, + "y": 107.99995422363281, + "width": 208.0, + "height": 312.99993896484377 + } + }, + "m_Slots": [ + { + "m_Id": "ad89e0280e524d9999c12e31260bd0a2" + } + ], + "synonyms": [], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + }, + "m_ScreenSpaceType": 4 +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicValueMaterialSlot", + "m_ObjectId": "a6ad0619b0ff4b35b9c068ac56819033", + "m_Id": 2, + "m_DisplayName": "Out", + "m_SlotType": 1, + "m_Hidden": false, + "m_ShaderOutputName": "Out", + "m_StageCapability": 3, + "m_Value": { + "e00": 0.0, + "e01": 0.0, + "e02": 0.0, + "e03": 0.0, + "e10": 0.0, + "e11": 0.0, + "e12": 0.0, + "e13": 0.0, + "e20": 0.0, + "e21": 0.0, + "e22": 0.0, + "e23": 0.0, + "e30": 0.0, + "e31": 0.0, + "e32": 0.0, + "e33": 0.0 + }, + "m_DefaultValue": { + "e00": 1.0, + "e01": 0.0, + "e02": 0.0, + "e03": 0.0, + "e10": 0.0, + "e11": 1.0, + "e12": 0.0, + "e13": 0.0, + "e20": 0.0, + "e21": 0.0, + "e22": 1.0, + "e23": 0.0, + "e30": 0.0, + "e31": 0.0, + "e32": 0.0, + "e33": 1.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.Vector4MaterialSlot", + "m_ObjectId": "ad89e0280e524d9999c12e31260bd0a2", + "m_Id": 0, + "m_DisplayName": "Out", + "m_SlotType": 1, + "m_Hidden": false, + "m_ShaderOutputName": "Out", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_Labels": [] +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "aec17fc7875a44f38f7d9153cf74f50f", + "m_Id": 1, + "m_DisplayName": "EXPECTED", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "EXPECTED", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.LerpNode", + "m_ObjectId": "afd6fed3d8e8461c9ac141b19e55e04d", + "m_Group": { + "m_Id": "" + }, + "m_Name": "Lerp", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": -321.0, + "y": -86.99998474121094, + "width": 207.99998474121095, + "height": 326.0 + } + }, + "m_Slots": [ + { + "m_Id": "d0bc4074e39847c09e25d45223ff7f12" + }, + { + "m_Id": "fefaeb0050de4b00a9a812607dec2e12" + }, + { + "m_Id": "44ff4c8e37d149f0a0ea59d40128711c" + }, + { + "m_Id": "54f4946a07ec470ab8eec9a158a27258" + } + ], + "synonyms": [ + "mix", + "blend", + "linear interpolate" + ], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "b20bd24cda5545cba5f1e7f3fdb7868d", + "m_Id": 1, + "m_DisplayName": "Out", + "m_SlotType": 1, + "m_Hidden": false, + "m_ShaderOutputName": "Out", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.Vector3MaterialSlot", + "m_ObjectId": "b773686d103b468db631276e1625c82c", + "m_Id": 1, + "m_DisplayName": "Out", + "m_SlotType": 1, + "m_Hidden": false, + "m_ShaderOutputName": "Out", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_Labels": [] +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "c481840984234183a87b86bd85e4b13d", + "m_Id": 1, + "m_DisplayName": "B", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "B", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "c87f1f151ea74a4995743a525e3f011b", + "m_Id": 0, + "m_DisplayName": "In", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "In", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.MultiplyNode", + "m_ObjectId": "cd74f48ac90a40f49890cd16fbf6660a", + "m_Group": { + "m_Id": "" + }, + "m_Name": "Multiply", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": -896.0, + "y": 2.0, + "width": 208.0, + "height": 302.0 + } + }, + "m_Slots": [ + { + "m_Id": "78abf71b291948a891e8fa2a931cac62" + }, + { + "m_Id": "df63aca4443847ec96ffc346ffd297b7" + }, + { + "m_Id": "a6ad0619b0ff4b35b9c068ac56819033" + } + ], + "synonyms": [ + "multiplication", + "times", + "x" + ], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "cee2261d7bcb4e288eb8e4171fa1e0b9", + "m_Id": 0, + "m_DisplayName": "A", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "A", + "m_StageCapability": 3, + "m_Value": { + "x": 0.5, + "y": 0.5, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "d0bc4074e39847c09e25d45223ff7f12", + "m_Id": 0, + "m_DisplayName": "A", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "A", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 1.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.NormalMaterialSlot", + "m_ObjectId": "d25d1af86a094ac7be2f0127f4634d7b", + "m_Id": 0, + "m_DisplayName": "Normal", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "Normal", + "m_StageCapability": 1, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_Labels": [], + "m_Space": 0 +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.SubtractNode", + "m_ObjectId": "d5c0ffaecc9d45f986de4d8925bc0051", + "m_Group": { + "m_Id": "" + }, + "m_Name": "Subtract", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": -1312.0, + "y": 3.0000650882720949, + "width": 208.0, + "height": 302.0 + } + }, + "m_Slots": [ + { + "m_Id": "5773db1af68243e0b9bd3ef7d7e70faa" + }, + { + "m_Id": "6a253040a6fd42dcbf025ac7ff33aa6c" + }, + { + "m_Id": "38d77b7f78e54e4e952af3311791ccd4" + } + ], + "synonyms": [ + "subtraction", + "remove", + "minus", + "take away" + ], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.IntegerHashNode", + "m_ObjectId": "d7fc69d9fbd84fe5b18d4361e39b39b9", + "m_Group": { + "m_Id": "" + }, + "m_Name": "Integer Hash", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": -2386.999755859375, + "y": 107.99995422363281, + "width": 207.999755859375, + "height": 312.99993896484377 + } + }, + "m_Slots": [ + { + "m_Id": "21393da4eb4d423a8f0b10e2ec444b34" + }, + { + "m_Id": "8a871f1b8d354b02b2dbcf3aed00bd1d" + } + ], + "synonyms": [], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + }, + "m_HashType": 1 +} + +{ + "m_SGVersion": 2, + "m_Type": "UnityEditor.ShaderGraph.TransformNode", + "m_ObjectId": "de1092b024884fdf9e8a5171a48ef13e", + "m_Group": { + "m_Id": "" + }, + "m_Name": "Transform", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": -1996.0, + "y": 281.0, + "width": 213.0, + "height": 341.0 + } + }, + "m_Slots": [ + { + "m_Id": "e52abb26e3ba40958f14752a649a892c" + }, + { + "m_Id": "6bb1519686984d74ab200c925b9a3676" + } + ], + "synonyms": [ + "world", + "tangent", + "object", + "view", + "screen", + "convert" + ], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + }, + "m_Conversion": { + "from": 0, + "to": 4 + }, + "m_ConversionType": 0, + "m_Normalize": false +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicValueMaterialSlot", + "m_ObjectId": "df63aca4443847ec96ffc346ffd297b7", + "m_Id": 1, + "m_DisplayName": "B", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "B", + "m_StageCapability": 3, + "m_Value": { + "e00": 200.0, + "e01": 200.0, + "e02": 200.0, + "e03": 2.0, + "e10": 2.0, + "e11": 2.0, + "e12": 2.0, + "e13": 2.0, + "e20": 2.0, + "e21": 2.0, + "e22": 2.0, + "e23": 2.0, + "e30": 2.0, + "e31": 2.0, + "e32": 2.0, + "e33": 2.0 + }, + "m_DefaultValue": { + "e00": 1.0, + "e01": 0.0, + "e02": 0.0, + "e03": 0.0, + "e10": 0.0, + "e11": 1.0, + "e12": 0.0, + "e13": 0.0, + "e20": 0.0, + "e21": 0.0, + "e22": 1.0, + "e23": 0.0, + "e30": 0.0, + "e31": 0.0, + "e32": 0.0, + "e33": 1.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.Vector3MaterialSlot", + "m_ObjectId": "e52abb26e3ba40958f14752a649a892c", + "m_Id": 0, + "m_DisplayName": "In", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "In", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_Labels": [] +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "e6aff6e4a9b14ff7827921e6353a87a3", + "m_Id": 0, + "m_DisplayName": "", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.StickyNoteData", + "m_ObjectId": "ebeb58a811964ae1ae55c9969cd6e146", + "m_Title": "Note", + "m_Content": "Since screen position is 0.5 centered, the round on the integer hash is sitting right on the boundary which is unstable.\nWe give it a bit of a push to one side to make sure it's deterministic.\n", + "m_TextSize": 0, + "m_Theme": 0, + "m_Position": { + "serializedVersion": "2", + "x": -2630.0, + "y": -133.0, + "width": 200.0, + "height": 172.0 + }, + "m_Group": { + "m_Id": "" + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.AbsoluteNode", + "m_ObjectId": "fa72769f37e54f599d367774a779d845", + "m_Group": { + "m_Id": "" + }, + "m_Name": "Absolute", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": -1104.0, + "y": 3.0000650882720949, + "width": 207.9998779296875, + "height": 278.0 + } + }, + "m_Slots": [ + { + "m_Id": "76d15710128b4ba5a42566d71f242c7e" + }, + { + "m_Id": "6286951a44ca42e8adf651ceec17a756" + } + ], + "synonyms": [ + "positive" + ], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.BlockNode", + "m_ObjectId": "fc28a5ef65284ed0967870ff69516ffe", + "m_Group": { + "m_Id": "" + }, + "m_Name": "VertexDescription.Position", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": 0.0, + "y": 0.0, + "width": 0.0, + "height": 0.0 + } + }, + "m_Slots": [ + { + "m_Id": "fc66c175daa9462fa1430c43a99d7698" + } + ], + "synonyms": [], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + }, + "m_SerializedDescriptor": "VertexDescription.Position" +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.PositionMaterialSlot", + "m_ObjectId": "fc66c175daa9462fa1430c43a99d7698", + "m_Id": 0, + "m_DisplayName": "Position", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "Position", + "m_StageCapability": 1, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_Labels": [], + "m_Space": 0 +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "fefaeb0050de4b00a9a812607dec2e12", + "m_Id": 1, + "m_DisplayName": "B", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "B", + "m_StageCapability": 3, + "m_Value": { + "x": 1.0, + "y": 0.0, + "z": 0.0, + "w": 1.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.RedirectNodeData", + "m_ObjectId": "ffde04b05e2c42f38093d4ddd027315b", + "m_Group": { + "m_Id": "" + }, + "m_Name": "Redirect Node", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": -1286.0001220703125, + "y": 410.00006103515627, + "width": 56.0001220703125, + "height": 23.999969482421876 + } + }, + "m_Slots": [ + { + "m_Id": "e6aff6e4a9b14ff7827921e6353a87a3" + }, + { + "m_Id": "34ee9d276de1426ea3815b3e26e80564" + } + ], + "synonyms": [], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + } +} + diff --git a/TestProjects/ShaderGraph/Assets/CommonAssets/Graphs/NodeTests/TransformInverses.shadergraph.meta b/TestProjects/ShaderGraph/Assets/CommonAssets/Graphs/NodeTests/TransformInverses.shadergraph.meta new file mode 100644 index 00000000000..185ac754dfa --- /dev/null +++ b/TestProjects/ShaderGraph/Assets/CommonAssets/Graphs/NodeTests/TransformInverses.shadergraph.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: bb2cd92af7992f741b9ccaa858abcd08 +ScriptedImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 2 + userData: + assetBundleName: + assetBundleVariant: + script: {fileID: 11500000, guid: 625f186215c104763be7675aa2d941aa, type: 3} diff --git a/TestProjects/ShaderGraph/Assets/CommonAssets/Graphs/NodeTests/TransformNormalize.shadergraph b/TestProjects/ShaderGraph/Assets/CommonAssets/Graphs/NodeTests/TransformNormalize.shadergraph new file mode 100644 index 00000000000..d30a161c457 --- /dev/null +++ b/TestProjects/ShaderGraph/Assets/CommonAssets/Graphs/NodeTests/TransformNormalize.shadergraph @@ -0,0 +1,2366 @@ +{ + "m_SGVersion": 3, + "m_Type": "UnityEditor.ShaderGraph.GraphData", + "m_ObjectId": "d3a578d5f6c048d989f4fc22763a096c", + "m_Properties": [], + "m_Keywords": [ + { + "m_Id": "1bd0bd2d8a644a369163cb727342c308" + } + ], + "m_Dropdowns": [], + "m_CategoryData": [ + { + "m_Id": "82645ecd662c4d88a7de4083a8e5b53c" + } + ], + "m_Nodes": [ + { + "m_Id": "fc28a5ef65284ed0967870ff69516ffe" + }, + { + "m_Id": "970cbadefd8f4fcca05f884246b4ad3e" + }, + { + "m_Id": "3ec2632bb2694b7699d26c257e2879ea" + }, + { + "m_Id": "65611bc2ea7845359ab31d44dd0816ab" + }, + { + "m_Id": "d7fc69d9fbd84fe5b18d4361e39b39b9" + }, + { + "m_Id": "997e733a37a141d4b698281397e00d14" + }, + { + "m_Id": "d5c0ffaecc9d45f986de4d8925bc0051" + }, + { + "m_Id": "de1092b024884fdf9e8a5171a48ef13e" + }, + { + "m_Id": "fa72769f37e54f599d367774a779d845" + }, + { + "m_Id": "cd74f48ac90a40f49890cd16fbf6660a" + }, + { + "m_Id": "afd6fed3d8e8461c9ac141b19e55e04d" + }, + { + "m_Id": "1746ecad396f45c2808181de7c16ab2d" + }, + { + "m_Id": "907dd0a26f124143bbc87326f74c2f54" + }, + { + "m_Id": "54d1e21495064ae8982ce8365d45d873" + }, + { + "m_Id": "3f4fe83ebf4a492c8bd4bd8d039d4e4e" + }, + { + "m_Id": "ffde04b05e2c42f38093d4ddd027315b" + }, + { + "m_Id": "6dc28149a6e2450a9b06b18a139d8695" + }, + { + "m_Id": "49eb3060313949e8a29142442a4c029a" + }, + { + "m_Id": "9fa27d76367a4b37b0351f86e835a86e" + }, + { + "m_Id": "bd41e49cf4f8409f9dfb75d384345a4b" + } + ], + "m_GroupDatas": [], + "m_StickyNoteDatas": [ + { + "m_Id": "ebeb58a811964ae1ae55c9969cd6e146" + }, + { + "m_Id": "6861d370b150463a8e84fb6bf7973bdc" + } + ], + "m_Edges": [ + { + "m_OutputSlot": { + "m_Node": { + "m_Id": "1746ecad396f45c2808181de7c16ab2d" + }, + "m_SlotId": 1 + }, + "m_InputSlot": { + "m_Node": { + "m_Id": "afd6fed3d8e8461c9ac141b19e55e04d" + }, + "m_SlotId": 2 + } + }, + { + "m_OutputSlot": { + "m_Node": { + "m_Id": "3f4fe83ebf4a492c8bd4bd8d039d4e4e" + }, + "m_SlotId": 1 + }, + "m_InputSlot": { + "m_Node": { + "m_Id": "907dd0a26f124143bbc87326f74c2f54" + }, + "m_SlotId": 2 + } + }, + { + "m_OutputSlot": { + "m_Node": { + "m_Id": "49eb3060313949e8a29142442a4c029a" + }, + "m_SlotId": 2 + }, + "m_InputSlot": { + "m_Node": { + "m_Id": "d7fc69d9fbd84fe5b18d4361e39b39b9" + }, + "m_SlotId": 1 + } + }, + { + "m_OutputSlot": { + "m_Node": { + "m_Id": "54d1e21495064ae8982ce8365d45d873" + }, + "m_SlotId": 1 + }, + "m_InputSlot": { + "m_Node": { + "m_Id": "907dd0a26f124143bbc87326f74c2f54" + }, + "m_SlotId": 1 + } + }, + { + "m_OutputSlot": { + "m_Node": { + "m_Id": "6dc28149a6e2450a9b06b18a139d8695" + }, + "m_SlotId": 1 + }, + "m_InputSlot": { + "m_Node": { + "m_Id": "54d1e21495064ae8982ce8365d45d873" + }, + "m_SlotId": 0 + } + }, + { + "m_OutputSlot": { + "m_Node": { + "m_Id": "907dd0a26f124143bbc87326f74c2f54" + }, + "m_SlotId": 0 + }, + "m_InputSlot": { + "m_Node": { + "m_Id": "65611bc2ea7845359ab31d44dd0816ab" + }, + "m_SlotId": 0 + } + }, + { + "m_OutputSlot": { + "m_Node": { + "m_Id": "997e733a37a141d4b698281397e00d14" + }, + "m_SlotId": 0 + }, + "m_InputSlot": { + "m_Node": { + "m_Id": "49eb3060313949e8a29142442a4c029a" + }, + "m_SlotId": 1 + } + }, + { + "m_OutputSlot": { + "m_Node": { + "m_Id": "9fa27d76367a4b37b0351f86e835a86e" + }, + "m_SlotId": 1 + }, + "m_InputSlot": { + "m_Node": { + "m_Id": "bd41e49cf4f8409f9dfb75d384345a4b" + }, + "m_SlotId": 0 + } + }, + { + "m_OutputSlot": { + "m_Node": { + "m_Id": "afd6fed3d8e8461c9ac141b19e55e04d" + }, + "m_SlotId": 3 + }, + "m_InputSlot": { + "m_Node": { + "m_Id": "907dd0a26f124143bbc87326f74c2f54" + }, + "m_SlotId": 3 + } + }, + { + "m_OutputSlot": { + "m_Node": { + "m_Id": "bd41e49cf4f8409f9dfb75d384345a4b" + }, + "m_SlotId": 1 + }, + "m_InputSlot": { + "m_Node": { + "m_Id": "6dc28149a6e2450a9b06b18a139d8695" + }, + "m_SlotId": 0 + } + }, + { + "m_OutputSlot": { + "m_Node": { + "m_Id": "bd41e49cf4f8409f9dfb75d384345a4b" + }, + "m_SlotId": 1 + }, + "m_InputSlot": { + "m_Node": { + "m_Id": "d5c0ffaecc9d45f986de4d8925bc0051" + }, + "m_SlotId": 0 + } + }, + { + "m_OutputSlot": { + "m_Node": { + "m_Id": "cd74f48ac90a40f49890cd16fbf6660a" + }, + "m_SlotId": 2 + }, + "m_InputSlot": { + "m_Node": { + "m_Id": "1746ecad396f45c2808181de7c16ab2d" + }, + "m_SlotId": 0 + } + }, + { + "m_OutputSlot": { + "m_Node": { + "m_Id": "d5c0ffaecc9d45f986de4d8925bc0051" + }, + "m_SlotId": 2 + }, + "m_InputSlot": { + "m_Node": { + "m_Id": "fa72769f37e54f599d367774a779d845" + }, + "m_SlotId": 0 + } + }, + { + "m_OutputSlot": { + "m_Node": { + "m_Id": "d7fc69d9fbd84fe5b18d4361e39b39b9" + }, + "m_SlotId": 0 + }, + "m_InputSlot": { + "m_Node": { + "m_Id": "9fa27d76367a4b37b0351f86e835a86e" + }, + "m_SlotId": 0 + } + }, + { + "m_OutputSlot": { + "m_Node": { + "m_Id": "d7fc69d9fbd84fe5b18d4361e39b39b9" + }, + "m_SlotId": 0 + }, + "m_InputSlot": { + "m_Node": { + "m_Id": "de1092b024884fdf9e8a5171a48ef13e" + }, + "m_SlotId": 0 + } + }, + { + "m_OutputSlot": { + "m_Node": { + "m_Id": "de1092b024884fdf9e8a5171a48ef13e" + }, + "m_SlotId": 1 + }, + "m_InputSlot": { + "m_Node": { + "m_Id": "d5c0ffaecc9d45f986de4d8925bc0051" + }, + "m_SlotId": 1 + } + }, + { + "m_OutputSlot": { + "m_Node": { + "m_Id": "de1092b024884fdf9e8a5171a48ef13e" + }, + "m_SlotId": 1 + }, + "m_InputSlot": { + "m_Node": { + "m_Id": "ffde04b05e2c42f38093d4ddd027315b" + }, + "m_SlotId": 0 + } + }, + { + "m_OutputSlot": { + "m_Node": { + "m_Id": "fa72769f37e54f599d367774a779d845" + }, + "m_SlotId": 1 + }, + "m_InputSlot": { + "m_Node": { + "m_Id": "cd74f48ac90a40f49890cd16fbf6660a" + }, + "m_SlotId": 0 + } + }, + { + "m_OutputSlot": { + "m_Node": { + "m_Id": "ffde04b05e2c42f38093d4ddd027315b" + }, + "m_SlotId": 1 + }, + "m_InputSlot": { + "m_Node": { + "m_Id": "3f4fe83ebf4a492c8bd4bd8d039d4e4e" + }, + "m_SlotId": 0 + } + } + ], + "m_VertexContext": { + "m_Position": { + "x": 362.00006103515627, + "y": -291.0 + }, + "m_Blocks": [ + { + "m_Id": "fc28a5ef65284ed0967870ff69516ffe" + }, + { + "m_Id": "970cbadefd8f4fcca05f884246b4ad3e" + }, + { + "m_Id": "3ec2632bb2694b7699d26c257e2879ea" + } + ] + }, + "m_FragmentContext": { + "m_Position": { + "x": 362.00006103515627, + "y": -91.0 + }, + "m_Blocks": [ + { + "m_Id": "65611bc2ea7845359ab31d44dd0816ab" + } + ] + }, + "m_PreviewData": { + "serializedMesh": { + "m_SerializedMesh": "{\"mesh\":{\"instanceID\":0}}", + "m_Guid": "" + }, + "preventRotation": false + }, + "m_Path": "Shader Graphs", + "m_GraphPrecision": 1, + "m_PreviewMode": 2, + "m_OutputNode": { + "m_Id": "" + }, + "m_ActiveTargets": [ + { + "m_Id": "1e17856cccb848638b5a1829dd00d4f8" + } + ] +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "07748643054049eea2a69011501a6a15", + "m_Id": 1, + "m_DisplayName": "Out", + "m_SlotType": 1, + "m_Hidden": false, + "m_ShaderOutputName": "Out", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.SaturateNode", + "m_ObjectId": "1746ecad396f45c2808181de7c16ab2d", + "m_Group": { + "m_Id": "" + }, + "m_Name": "Saturate", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": -688.0, + "y": 2.0, + "width": 208.0, + "height": 278.0 + } + }, + "m_Slots": [ + { + "m_Id": "691ae26bade44166941282be4b9e5582" + }, + { + "m_Id": "b20bd24cda5545cba5f1e7f3fdb7868d" + } + ], + "synonyms": [ + "clamp" + ], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + } +} + +{ + "m_SGVersion": 1, + "m_Type": "UnityEditor.ShaderGraph.ShaderKeyword", + "m_ObjectId": "1bd0bd2d8a644a369163cb727342c308", + "m_Guid": { + "m_GuidSerialized": "7a8918ce-9570-4947-b06a-6445703e6938" + }, + "m_Name": "MODE", + "m_DefaultRefNameVersion": 1, + "m_RefNameGeneratedByDisplayName": "MODE", + "m_DefaultReferenceName": "_MODE", + "m_OverrideReferenceName": "", + "m_GeneratePropertyBlock": true, + "m_UseCustomSlotLabel": false, + "m_CustomSlotLabel": "", + "m_KeywordType": 1, + "m_KeywordDefinition": 0, + "m_KeywordScope": 0, + "m_KeywordStages": 63, + "m_Entries": [ + { + "id": 3, + "displayName": "DIFF", + "referenceName": "DIFF" + }, + { + "id": 1, + "displayName": "EXPECTED", + "referenceName": "EXPECTED" + }, + { + "id": 2, + "displayName": "ACTUAL", + "referenceName": "ACTUAL" + } + ], + "m_Value": 0, + "m_IsEditable": true +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "1d11b6b53cef4b47869bbb766c74c0ea", + "m_Id": 0, + "m_DisplayName": "In", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "In", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 1, + "m_Type": "UnityEditor.Rendering.Universal.ShaderGraph.UniversalTarget", + "m_ObjectId": "1e17856cccb848638b5a1829dd00d4f8", + "m_ActiveSubTarget": { + "m_Id": "416b95b32d794f768b76ab713d607602" + }, + "m_AllowMaterialOverride": false, + "m_SurfaceType": 0, + "m_ZTestMode": 4, + "m_ZWriteControl": 0, + "m_AlphaMode": 0, + "m_RenderFace": 2, + "m_AlphaClip": false, + "m_CastShadows": true, + "m_ReceiveShadows": true, + "m_CustomEditorGUI": "", + "m_SupportVFX": false +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.Vector2MaterialSlot", + "m_ObjectId": "21393da4eb4d423a8f0b10e2ec444b34", + "m_Id": 1, + "m_DisplayName": "Coord", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "Coord", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0 + }, + "m_Labels": [] +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "2a3224dfa9bd4cae86c581149bb64689", + "m_Id": 0, + "m_DisplayName": "In", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "In", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "34ee9d276de1426ea3815b3e26e80564", + "m_Id": 1, + "m_DisplayName": "", + "m_SlotType": 1, + "m_Hidden": false, + "m_ShaderOutputName": "", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.Vector3MaterialSlot", + "m_ObjectId": "353328e353834293ac0840fb8eb6f2c8", + "m_Id": 1, + "m_DisplayName": "Out", + "m_SlotType": 1, + "m_Hidden": false, + "m_ShaderOutputName": "Out", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_Labels": [] +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "38d77b7f78e54e4e952af3311791ccd4", + "m_Id": 2, + "m_DisplayName": "Out", + "m_SlotType": 1, + "m_Hidden": false, + "m_ShaderOutputName": "Out", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.ColorRGBMaterialSlot", + "m_ObjectId": "3b6e685d10224984b1ec689fc2168cf2", + "m_Id": 0, + "m_DisplayName": "Base Color", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "BaseColor", + "m_StageCapability": 2, + "m_Value": { + "x": 0.5, + "y": 0.5, + "z": 0.5 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_Labels": [], + "m_ColorMode": 0, + "m_DefaultColor": { + "r": 0.5, + "g": 0.5, + "b": 0.5, + "a": 1.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.BlockNode", + "m_ObjectId": "3ec2632bb2694b7699d26c257e2879ea", + "m_Group": { + "m_Id": "" + }, + "m_Name": "VertexDescription.Tangent", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": 0.0, + "y": 0.0, + "width": 0.0, + "height": 0.0 + } + }, + "m_Slots": [ + { + "m_Id": "628ef29e9b5d447e9caa4531bcbe6b10" + } + ], + "synonyms": [], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + }, + "m_SerializedDescriptor": "VertexDescription.Tangent" +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.AbsoluteNode", + "m_ObjectId": "3f4fe83ebf4a492c8bd4bd8d039d4e4e", + "m_Group": { + "m_Id": "" + }, + "m_Name": "Absolute", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": -113.00003051757813, + "y": 363.0000915527344, + "width": 132.0000457763672, + "height": 93.9998779296875 + } + }, + "m_Slots": [ + { + "m_Id": "1d11b6b53cef4b47869bbb766c74c0ea" + }, + { + "m_Id": "07748643054049eea2a69011501a6a15" + } + ], + "synonyms": [ + "positive" + ], + "m_Precision": 0, + "m_PreviewExpanded": false, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.Rendering.Universal.ShaderGraph.UniversalUnlitSubTarget", + "m_ObjectId": "416b95b32d794f768b76ab713d607602" +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "42ed096a23f0457eab55df8305100690", + "m_Id": 0, + "m_DisplayName": "Out", + "m_SlotType": 1, + "m_Hidden": false, + "m_ShaderOutputName": "Out", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "44ff4c8e37d149f0a0ea59d40128711c", + "m_Id": 2, + "m_DisplayName": "T", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "T", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.AddNode", + "m_ObjectId": "49eb3060313949e8a29142442a4c029a", + "m_Group": { + "m_Id": "" + }, + "m_Name": "Add", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": -2635.999755859375, + "y": 41.00001907348633, + "width": 208.0, + "height": 302.9998779296875 + } + }, + "m_Slots": [ + { + "m_Id": "cee2261d7bcb4e288eb8e4171fa1e0b9" + }, + { + "m_Id": "c481840984234183a87b86bd85e4b13d" + }, + { + "m_Id": "6b856ac4f8634c3bae87e2ac66690f86" + } + ], + "synonyms": [ + "addition", + "sum", + "plus" + ], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.Vector3MaterialSlot", + "m_ObjectId": "4f283af276d64dac858d0947d1fdbaaa", + "m_Id": 0, + "m_DisplayName": "In", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "In", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_Labels": [] +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "50f3802c0e1d464abca40855381706b0", + "m_Id": 1, + "m_DisplayName": "", + "m_SlotType": 1, + "m_Hidden": false, + "m_ShaderOutputName": "", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.AbsoluteNode", + "m_ObjectId": "54d1e21495064ae8982ce8365d45d873", + "m_Group": { + "m_Id": "" + }, + "m_Name": "Absolute", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": -113.00003051757813, + "y": -294.9999694824219, + "width": 132.0000457763672, + "height": 94.00001525878906 + } + }, + "m_Slots": [ + { + "m_Id": "c87f1f151ea74a4995743a525e3f011b" + }, + { + "m_Id": "8331dcbe952448e3b4cf2b6523349985" + } + ], + "synonyms": [ + "positive" + ], + "m_Precision": 0, + "m_PreviewExpanded": false, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "54f4946a07ec470ab8eec9a158a27258", + "m_Id": 3, + "m_DisplayName": "Out", + "m_SlotType": 1, + "m_Hidden": false, + "m_ShaderOutputName": "Out", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "5743e9b1804044f38daa56bd9f883145", + "m_Id": 0, + "m_DisplayName": "", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "5773db1af68243e0b9bd3ef7d7e70faa", + "m_Id": 0, + "m_DisplayName": "A", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "A", + "m_StageCapability": 3, + "m_Value": { + "x": 1.0, + "y": 1.0, + "z": 1.0, + "w": 1.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "6286951a44ca42e8adf651ceec17a756", + "m_Id": 1, + "m_DisplayName": "Out", + "m_SlotType": 1, + "m_Hidden": false, + "m_ShaderOutputName": "Out", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.TangentMaterialSlot", + "m_ObjectId": "628ef29e9b5d447e9caa4531bcbe6b10", + "m_Id": 0, + "m_DisplayName": "Tangent", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "Tangent", + "m_StageCapability": 1, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_Labels": [], + "m_Space": 0 +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.BlockNode", + "m_ObjectId": "65611bc2ea7845359ab31d44dd0816ab", + "m_Group": { + "m_Id": "" + }, + "m_Name": "SurfaceDescription.BaseColor", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": 0.0, + "y": 0.0, + "width": 0.0, + "height": 0.0 + } + }, + "m_Slots": [ + { + "m_Id": "3b6e685d10224984b1ec689fc2168cf2" + } + ], + "synonyms": [], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + }, + "m_SerializedDescriptor": "SurfaceDescription.BaseColor" +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.StickyNoteData", + "m_ObjectId": "6861d370b150463a8e84fb6bf7973bdc", + "m_Title": "Purpose", + "m_Content": "Validate that the normalization option works", + "m_TextSize": 0, + "m_Theme": 0, + "m_Position": { + "serializedVersion": "2", + "x": -1892.0, + "y": -407.0, + "width": 200.0, + "height": 160.0 + }, + "m_Group": { + "m_Id": "" + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "691ae26bade44166941282be4b9e5582", + "m_Id": 0, + "m_DisplayName": "In", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "In", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "6a253040a6fd42dcbf025ac7ff33aa6c", + "m_Id": 1, + "m_DisplayName": "B", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "B", + "m_StageCapability": 3, + "m_Value": { + "x": 1.0, + "y": 1.0, + "z": 1.0, + "w": 1.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "6b856ac4f8634c3bae87e2ac66690f86", + "m_Id": 2, + "m_DisplayName": "Out", + "m_SlotType": 1, + "m_Hidden": false, + "m_ShaderOutputName": "Out", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.Vector3MaterialSlot", + "m_ObjectId": "6bb1519686984d74ab200c925b9a3676", + "m_Id": 1, + "m_DisplayName": "Out", + "m_SlotType": 1, + "m_Hidden": false, + "m_ShaderOutputName": "Out", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_Labels": [] +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.RedirectNodeData", + "m_ObjectId": "6dc28149a6e2450a9b06b18a139d8695", + "m_Group": { + "m_Id": "" + }, + "m_Name": "Redirect Node", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": -1312.0001220703125, + "y": -247.9999542236328, + "width": 56.0001220703125, + "height": 23.999984741210939 + } + }, + "m_Slots": [ + { + "m_Id": "5743e9b1804044f38daa56bd9f883145" + }, + { + "m_Id": "50f3802c0e1d464abca40855381706b0" + } + ], + "synonyms": [], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "76d15710128b4ba5a42566d71f242c7e", + "m_Id": 0, + "m_DisplayName": "In", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "In", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicValueMaterialSlot", + "m_ObjectId": "78abf71b291948a891e8fa2a931cac62", + "m_Id": 0, + "m_DisplayName": "A", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "A", + "m_StageCapability": 3, + "m_Value": { + "e00": 200.0, + "e01": 0.0, + "e02": 0.0, + "e03": 0.0, + "e10": 0.0, + "e11": 0.0, + "e12": 0.0, + "e13": 0.0, + "e20": 0.0, + "e21": 0.0, + "e22": 0.0, + "e23": 0.0, + "e30": 0.0, + "e31": 0.0, + "e32": 0.0, + "e33": 0.0 + }, + "m_DefaultValue": { + "e00": 1.0, + "e01": 0.0, + "e02": 0.0, + "e03": 0.0, + "e10": 0.0, + "e11": 1.0, + "e12": 0.0, + "e13": 0.0, + "e20": 0.0, + "e21": 0.0, + "e22": 1.0, + "e23": 0.0, + "e30": 0.0, + "e31": 0.0, + "e32": 0.0, + "e33": 1.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "79c8bd704d2a4ce48efa862b75d36053", + "m_Id": 3, + "m_DisplayName": "DIFF", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "DIFF", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.CategoryData", + "m_ObjectId": "82645ecd662c4d88a7de4083a8e5b53c", + "m_Name": "", + "m_ChildObjectList": [ + { + "m_Id": "1bd0bd2d8a644a369163cb727342c308" + } + ] +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "8331dcbe952448e3b4cf2b6523349985", + "m_Id": 1, + "m_DisplayName": "Out", + "m_SlotType": 1, + "m_Hidden": false, + "m_ShaderOutputName": "Out", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.Vector3MaterialSlot", + "m_ObjectId": "8a871f1b8d354b02b2dbcf3aed00bd1d", + "m_Id": 0, + "m_DisplayName": "Hash", + "m_SlotType": 1, + "m_Hidden": false, + "m_ShaderOutputName": "Hash", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_Labels": [] +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.KeywordNode", + "m_ObjectId": "907dd0a26f124143bbc87326f74c2f54", + "m_Group": { + "m_Id": "" + }, + "m_Name": "MODE", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": 126.99999237060547, + "y": -91.0, + "width": 208.00003051757813, + "height": 326.0 + } + }, + "m_Slots": [ + { + "m_Id": "42ed096a23f0457eab55df8305100690" + }, + { + "m_Id": "79c8bd704d2a4ce48efa862b75d36053" + }, + { + "m_Id": "aec17fc7875a44f38f7d9153cf74f50f" + }, + { + "m_Id": "994474eebdcf4c66a55e6ac3838b66ce" + } + ], + "synonyms": [], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + }, + "m_Keyword": { + "m_Id": "1bd0bd2d8a644a369163cb727342c308" + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.BlockNode", + "m_ObjectId": "970cbadefd8f4fcca05f884246b4ad3e", + "m_Group": { + "m_Id": "" + }, + "m_Name": "VertexDescription.Normal", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": 0.0, + "y": 0.0, + "width": 0.0, + "height": 0.0 + } + }, + "m_Slots": [ + { + "m_Id": "d25d1af86a094ac7be2f0127f4634d7b" + } + ], + "synonyms": [], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + }, + "m_SerializedDescriptor": "VertexDescription.Normal" +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "994474eebdcf4c66a55e6ac3838b66ce", + "m_Id": 2, + "m_DisplayName": "ACTUAL", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "ACTUAL", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.ScreenPositionNode", + "m_ObjectId": "997e733a37a141d4b698281397e00d14", + "m_Group": { + "m_Id": "" + }, + "m_Name": "Screen Position", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": -2935.999755859375, + "y": 107.99995422363281, + "width": 208.0, + "height": 312.99993896484377 + } + }, + "m_Slots": [ + { + "m_Id": "ad89e0280e524d9999c12e31260bd0a2" + } + ], + "synonyms": [], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + }, + "m_ScreenSpaceType": 4 +} + +{ + "m_SGVersion": 2, + "m_Type": "UnityEditor.ShaderGraph.TransformNode", + "m_ObjectId": "9fa27d76367a4b37b0351f86e835a86e", + "m_Group": { + "m_Id": "" + }, + "m_Name": "Transform", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": -1996.0001220703125, + "y": -115.0, + "width": 213.0, + "height": 341.0000305175781 + } + }, + "m_Slots": [ + { + "m_Id": "4f283af276d64dac858d0947d1fdbaaa" + }, + { + "m_Id": "353328e353834293ac0840fb8eb6f2c8" + } + ], + "synonyms": [ + "world", + "tangent", + "object", + "view", + "screen", + "convert" + ], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + }, + "m_Conversion": { + "from": 0, + "to": 3 + }, + "m_ConversionType": 1, + "m_Normalize": false +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicValueMaterialSlot", + "m_ObjectId": "a6ad0619b0ff4b35b9c068ac56819033", + "m_Id": 2, + "m_DisplayName": "Out", + "m_SlotType": 1, + "m_Hidden": false, + "m_ShaderOutputName": "Out", + "m_StageCapability": 3, + "m_Value": { + "e00": 0.0, + "e01": 0.0, + "e02": 0.0, + "e03": 0.0, + "e10": 0.0, + "e11": 0.0, + "e12": 0.0, + "e13": 0.0, + "e20": 0.0, + "e21": 0.0, + "e22": 0.0, + "e23": 0.0, + "e30": 0.0, + "e31": 0.0, + "e32": 0.0, + "e33": 0.0 + }, + "m_DefaultValue": { + "e00": 1.0, + "e01": 0.0, + "e02": 0.0, + "e03": 0.0, + "e10": 0.0, + "e11": 1.0, + "e12": 0.0, + "e13": 0.0, + "e20": 0.0, + "e21": 0.0, + "e22": 1.0, + "e23": 0.0, + "e30": 0.0, + "e31": 0.0, + "e32": 0.0, + "e33": 1.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.Vector4MaterialSlot", + "m_ObjectId": "ad89e0280e524d9999c12e31260bd0a2", + "m_Id": 0, + "m_DisplayName": "Out", + "m_SlotType": 1, + "m_Hidden": false, + "m_ShaderOutputName": "Out", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_Labels": [] +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "aec17fc7875a44f38f7d9153cf74f50f", + "m_Id": 1, + "m_DisplayName": "EXPECTED", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "EXPECTED", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.LerpNode", + "m_ObjectId": "afd6fed3d8e8461c9ac141b19e55e04d", + "m_Group": { + "m_Id": "" + }, + "m_Name": "Lerp", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": -321.0, + "y": -86.99998474121094, + "width": 207.99998474121095, + "height": 326.0 + } + }, + "m_Slots": [ + { + "m_Id": "d0bc4074e39847c09e25d45223ff7f12" + }, + { + "m_Id": "fefaeb0050de4b00a9a812607dec2e12" + }, + { + "m_Id": "44ff4c8e37d149f0a0ea59d40128711c" + }, + { + "m_Id": "54f4946a07ec470ab8eec9a158a27258" + } + ], + "synonyms": [ + "mix", + "blend", + "linear interpolate" + ], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "b20bd24cda5545cba5f1e7f3fdb7868d", + "m_Id": 1, + "m_DisplayName": "Out", + "m_SlotType": 1, + "m_Hidden": false, + "m_ShaderOutputName": "Out", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.NormalizeNode", + "m_ObjectId": "bd41e49cf4f8409f9dfb75d384345a4b", + "m_Group": { + "m_Id": "" + }, + "m_Name": "Normalize", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": -1783.0001220703125, + "y": -115.0, + "width": 208.0, + "height": 278.0000305175781 + } + }, + "m_Slots": [ + { + "m_Id": "2a3224dfa9bd4cae86c581149bb64689" + }, + { + "m_Id": "c9171edd5edd4b8ab9a329ee2f0e0658" + } + ], + "synonyms": [], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "c481840984234183a87b86bd85e4b13d", + "m_Id": 1, + "m_DisplayName": "B", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "B", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "c87f1f151ea74a4995743a525e3f011b", + "m_Id": 0, + "m_DisplayName": "In", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "In", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "c9171edd5edd4b8ab9a329ee2f0e0658", + "m_Id": 1, + "m_DisplayName": "Out", + "m_SlotType": 1, + "m_Hidden": false, + "m_ShaderOutputName": "Out", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.MultiplyNode", + "m_ObjectId": "cd74f48ac90a40f49890cd16fbf6660a", + "m_Group": { + "m_Id": "" + }, + "m_Name": "Multiply", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": -896.0, + "y": 2.0, + "width": 208.0, + "height": 302.0 + } + }, + "m_Slots": [ + { + "m_Id": "78abf71b291948a891e8fa2a931cac62" + }, + { + "m_Id": "df63aca4443847ec96ffc346ffd297b7" + }, + { + "m_Id": "a6ad0619b0ff4b35b9c068ac56819033" + } + ], + "synonyms": [ + "multiplication", + "times", + "x" + ], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "cee2261d7bcb4e288eb8e4171fa1e0b9", + "m_Id": 0, + "m_DisplayName": "A", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "A", + "m_StageCapability": 3, + "m_Value": { + "x": 0.5, + "y": 0.5, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "d0bc4074e39847c09e25d45223ff7f12", + "m_Id": 0, + "m_DisplayName": "A", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "A", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 1.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.NormalMaterialSlot", + "m_ObjectId": "d25d1af86a094ac7be2f0127f4634d7b", + "m_Id": 0, + "m_DisplayName": "Normal", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "Normal", + "m_StageCapability": 1, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_Labels": [], + "m_Space": 0 +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.SubtractNode", + "m_ObjectId": "d5c0ffaecc9d45f986de4d8925bc0051", + "m_Group": { + "m_Id": "" + }, + "m_Name": "Subtract", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": -1312.0, + "y": 3.0000650882720949, + "width": 208.0, + "height": 302.0 + } + }, + "m_Slots": [ + { + "m_Id": "5773db1af68243e0b9bd3ef7d7e70faa" + }, + { + "m_Id": "6a253040a6fd42dcbf025ac7ff33aa6c" + }, + { + "m_Id": "38d77b7f78e54e4e952af3311791ccd4" + } + ], + "synonyms": [ + "subtraction", + "remove", + "minus", + "take away" + ], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.IntegerHashNode", + "m_ObjectId": "d7fc69d9fbd84fe5b18d4361e39b39b9", + "m_Group": { + "m_Id": "" + }, + "m_Name": "Integer Hash", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": -2386.999755859375, + "y": 107.99995422363281, + "width": 207.999755859375, + "height": 312.99993896484377 + } + }, + "m_Slots": [ + { + "m_Id": "21393da4eb4d423a8f0b10e2ec444b34" + }, + { + "m_Id": "8a871f1b8d354b02b2dbcf3aed00bd1d" + } + ], + "synonyms": [], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + }, + "m_HashType": 1 +} + +{ + "m_SGVersion": 2, + "m_Type": "UnityEditor.ShaderGraph.TransformNode", + "m_ObjectId": "de1092b024884fdf9e8a5171a48ef13e", + "m_Group": { + "m_Id": "" + }, + "m_Name": "Transform", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": -1996.0001220703125, + "y": 226.00003051757813, + "width": 213.0, + "height": 340.9999694824219 + } + }, + "m_Slots": [ + { + "m_Id": "e52abb26e3ba40958f14752a649a892c" + }, + { + "m_Id": "6bb1519686984d74ab200c925b9a3676" + } + ], + "synonyms": [ + "world", + "tangent", + "object", + "view", + "screen", + "convert" + ], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + }, + "m_Conversion": { + "from": 0, + "to": 3 + }, + "m_ConversionType": 1, + "m_Normalize": true +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicValueMaterialSlot", + "m_ObjectId": "df63aca4443847ec96ffc346ffd297b7", + "m_Id": 1, + "m_DisplayName": "B", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "B", + "m_StageCapability": 3, + "m_Value": { + "e00": 200.0, + "e01": 200.0, + "e02": 200.0, + "e03": 2.0, + "e10": 2.0, + "e11": 2.0, + "e12": 2.0, + "e13": 2.0, + "e20": 2.0, + "e21": 2.0, + "e22": 2.0, + "e23": 2.0, + "e30": 2.0, + "e31": 2.0, + "e32": 2.0, + "e33": 2.0 + }, + "m_DefaultValue": { + "e00": 1.0, + "e01": 0.0, + "e02": 0.0, + "e03": 0.0, + "e10": 0.0, + "e11": 1.0, + "e12": 0.0, + "e13": 0.0, + "e20": 0.0, + "e21": 0.0, + "e22": 1.0, + "e23": 0.0, + "e30": 0.0, + "e31": 0.0, + "e32": 0.0, + "e33": 1.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.Vector3MaterialSlot", + "m_ObjectId": "e52abb26e3ba40958f14752a649a892c", + "m_Id": 0, + "m_DisplayName": "In", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "In", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_Labels": [] +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "e6aff6e4a9b14ff7827921e6353a87a3", + "m_Id": 0, + "m_DisplayName": "", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.StickyNoteData", + "m_ObjectId": "ebeb58a811964ae1ae55c9969cd6e146", + "m_Title": "Note", + "m_Content": "Since screen position is 0.5 centered, the round on the integer hash is sitting right on the boundary which is unstable.\nWe give it a bit of a push to one side to make sure it's deterministic.\n", + "m_TextSize": 0, + "m_Theme": 0, + "m_Position": { + "serializedVersion": "2", + "x": -2630.0, + "y": -133.0, + "width": 200.0, + "height": 172.0 + }, + "m_Group": { + "m_Id": "" + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.AbsoluteNode", + "m_ObjectId": "fa72769f37e54f599d367774a779d845", + "m_Group": { + "m_Id": "" + }, + "m_Name": "Absolute", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": -1104.0, + "y": 3.0000650882720949, + "width": 207.9998779296875, + "height": 278.0 + } + }, + "m_Slots": [ + { + "m_Id": "76d15710128b4ba5a42566d71f242c7e" + }, + { + "m_Id": "6286951a44ca42e8adf651ceec17a756" + } + ], + "synonyms": [ + "positive" + ], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.BlockNode", + "m_ObjectId": "fc28a5ef65284ed0967870ff69516ffe", + "m_Group": { + "m_Id": "" + }, + "m_Name": "VertexDescription.Position", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": 0.0, + "y": 0.0, + "width": 0.0, + "height": 0.0 + } + }, + "m_Slots": [ + { + "m_Id": "fc66c175daa9462fa1430c43a99d7698" + } + ], + "synonyms": [], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + }, + "m_SerializedDescriptor": "VertexDescription.Position" +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.PositionMaterialSlot", + "m_ObjectId": "fc66c175daa9462fa1430c43a99d7698", + "m_Id": 0, + "m_DisplayName": "Position", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "Position", + "m_StageCapability": 1, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_Labels": [], + "m_Space": 0 +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "fefaeb0050de4b00a9a812607dec2e12", + "m_Id": 1, + "m_DisplayName": "B", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "B", + "m_StageCapability": 3, + "m_Value": { + "x": 1.0, + "y": 0.0, + "z": 0.0, + "w": 1.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.RedirectNodeData", + "m_ObjectId": "ffde04b05e2c42f38093d4ddd027315b", + "m_Group": { + "m_Id": "" + }, + "m_Name": "Redirect Node", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": -1286.0001220703125, + "y": 410.00006103515627, + "width": 56.0001220703125, + "height": 23.999969482421876 + } + }, + "m_Slots": [ + { + "m_Id": "e6aff6e4a9b14ff7827921e6353a87a3" + }, + { + "m_Id": "34ee9d276de1426ea3815b3e26e80564" + } + ], + "synonyms": [], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + } +} + diff --git a/TestProjects/ShaderGraph/Assets/CommonAssets/Graphs/NodeTests/TransformNormalize.shadergraph.meta b/TestProjects/ShaderGraph/Assets/CommonAssets/Graphs/NodeTests/TransformNormalize.shadergraph.meta new file mode 100644 index 00000000000..37543d59203 --- /dev/null +++ b/TestProjects/ShaderGraph/Assets/CommonAssets/Graphs/NodeTests/TransformNormalize.shadergraph.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: f27c372b91c153749bfee96a4083a5fe +ScriptedImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 2 + userData: + assetBundleName: + assetBundleVariant: + script: {fileID: 11500000, guid: 625f186215c104763be7675aa2d941aa, type: 3} diff --git a/TestProjects/ShaderGraph/Assets/CommonAssets/Graphs/TransformGraph.shadergraph b/TestProjects/ShaderGraph/Assets/CommonAssets/Graphs/NodeTests/TransformV1MatchesOldTransform.shadergraph similarity index 98% rename from TestProjects/ShaderGraph/Assets/CommonAssets/Graphs/TransformGraph.shadergraph rename to TestProjects/ShaderGraph/Assets/CommonAssets/Graphs/NodeTests/TransformV1MatchesOldTransform.shadergraph index 646424086d9..48c7b305de4 100644 --- a/TestProjects/ShaderGraph/Assets/CommonAssets/Graphs/TransformGraph.shadergraph +++ b/TestProjects/ShaderGraph/Assets/CommonAssets/Graphs/NodeTests/TransformV1MatchesOldTransform.shadergraph @@ -77,6 +77,9 @@ "m_StickyNoteDatas": [ { "m_Id": "ebeb58a811964ae1ae55c9969cd6e146" + }, + { + "m_Id": "fb3521ba1d0e4afc8006f556b4cb15a4" } ], "m_Edges": [ @@ -189,7 +192,7 @@ "m_Node": { "m_Id": "907dd0a26f124143bbc87326f74c2f54" }, - "m_SlotId": 4 + "m_SlotId": 3 } }, { @@ -405,30 +408,6 @@ } } -{ - "m_SGVersion": 0, - "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", - "m_ObjectId": "0e02596103584467b3f08ceaeeea231e", - "m_Id": 4, - "m_DisplayName": "COMPARE", - "m_SlotType": 0, - "m_Hidden": false, - "m_ShaderOutputName": "COMPARE", - "m_StageCapability": 3, - "m_Value": { - "x": 0.0, - "y": 0.0, - "z": 0.0, - "w": 0.0 - }, - "m_DefaultValue": { - "x": 0.0, - "y": 0.0, - "z": 0.0, - "w": 0.0 - } -} - { "m_SGVersion": 0, "m_Type": "UnityEditor.ShaderGraph.SaturateNode", @@ -487,9 +466,9 @@ "m_KeywordStages": 63, "m_Entries": [ { - "id": 4, - "displayName": "COMPARE", - "referenceName": "COMPARE" + "id": 3, + "displayName": "DIFF", + "referenceName": "DIFF" }, { "id": 1, @@ -571,6 +550,30 @@ "m_Labels": [] } +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "2e230e759137416eae22a09ab75727e6", + "m_Id": 3, + "m_DisplayName": "DIFF", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "DIFF", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + { "m_SGVersion": 0, "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", @@ -1313,7 +1316,7 @@ "m_Id": "42ed096a23f0457eab55df8305100690" }, { - "m_Id": "0e02596103584467b3f08ceaeeea231e" + "m_Id": "2e230e759137416eae22a09ab75727e6" }, { "m_Id": "aec17fc7875a44f38f7d9153cf74f50f" @@ -2124,6 +2127,26 @@ } } +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.StickyNoteData", + "m_ObjectId": "fb3521ba1d0e4afc8006f556b4cb15a4", + "m_Title": "Purpose", + "m_Content": "Testing that the new Transform node, in legacy v1 mode, is equivalent to the old Transform node behavior.", + "m_TextSize": 0, + "m_Theme": 0, + "m_Position": { + "serializedVersion": "2", + "x": -1560.0, + "y": -368.0, + "width": 200.0, + "height": 192.0 + }, + "m_Group": { + "m_Id": "" + } +} + { "m_SGVersion": 0, "m_Type": "UnityEditor.ShaderGraph.BlockNode", diff --git a/TestProjects/ShaderGraph/Assets/CommonAssets/Graphs/TransformGraph.shadergraph.meta b/TestProjects/ShaderGraph/Assets/CommonAssets/Graphs/NodeTests/TransformV1MatchesOldTransform.shadergraph.meta similarity index 100% rename from TestProjects/ShaderGraph/Assets/CommonAssets/Graphs/TransformGraph.shadergraph.meta rename to TestProjects/ShaderGraph/Assets/CommonAssets/Graphs/NodeTests/TransformV1MatchesOldTransform.shadergraph.meta From 97f6d659c0743e6d10627bf11e7ff081076b2cb5 Mon Sep 17 00:00:00 2001 From: Chris Tchou Date: Thu, 30 Sep 2021 17:24:34 -0700 Subject: [PATCH 19/23] Cleaning up comments --- .../Assets/CommonAssets/Editor/NodeTests.cs | 8 ++++++-- .../Editor/ShaderGraphTestRenderer.cs | 15 --------------- .../ShaderLibrary/SpaceTransforms.hlsl | 4 ++-- 3 files changed, 8 insertions(+), 19 deletions(-) diff --git a/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/NodeTests.cs b/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/NodeTests.cs index 45e623bccb1..d082582c525 100644 --- a/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/NodeTests.cs +++ b/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/NodeTests.cs @@ -78,6 +78,7 @@ public IEnumerator TransformV1MatchesOldTransform() [UnityTest] public IEnumerator TransformInverses() { + // Test that A->B and B->A result in the original value string graphPath = "Assets/CommonAssets/Graphs/NodeTests/TransformInverses.shadergraph"; var graph = LoadGraph(graphPath); ResetTestReporting(); @@ -116,6 +117,7 @@ public IEnumerator TransformInverses() [UnityTest] public IEnumerator TransformABC() { + // Test that transforming from A->B then B->C is the same as A->C (for all A,B,C) string graphPath = "Assets/CommonAssets/Graphs/NodeTests/TransformABC.shadergraph"; var graph = LoadGraph(graphPath); ResetTestReporting(); @@ -162,6 +164,8 @@ public IEnumerator TransformABC() [UnityTest] public IEnumerator TransformNormalize() { + // Test that A->B then normalizing is the same as A->B with normalize enabled + // for all direction and normal conversion types string graphPath = "Assets/CommonAssets/Graphs/NodeTests/TransformNormalize.shadergraph"; var graph = LoadGraph(graphPath); @@ -178,11 +182,11 @@ public IEnumerator TransformNormalize() { foreach (CoordinateSpace dest in Enum.GetValues(typeof(CoordinateSpace))) { - // setup transform(v1) node + // setup normalized transform norm.conversion = new CoordinateSpaceConversion(source, dest); norm.conversionType = conversionType; - // setup old transform node + // setup unnormalized transform unnorm.conversion = new CoordinateSpaceConversion(source, dest); unnorm.conversionType = conversionType; diff --git a/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/ShaderGraphTestRenderer.cs b/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/ShaderGraphTestRenderer.cs index 98463f84437..8f74aab4b9a 100644 --- a/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/ShaderGraphTestRenderer.cs +++ b/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/ShaderGraphTestRenderer.cs @@ -139,22 +139,7 @@ internal static void CreateDirectoriesForFilePath(string systemFilePath) internal static void CreateDirectories(string systemDirectoryPath) { - //var systemDirectory = Application.dataPath + "/../" + directoryPath; Directory.CreateDirectory(systemDirectoryPath); - /* - var dirs = directoryPath.Split('/'); - string curpath = string.Empty; - foreach (var dir in dirs) - { - var parentPath = curpath; - curpath = curpath + dir; - if (!UnityEditor.AssetDatabase.IsValidFolder(curpath)) - { - AssetDatabase.CreateFolder(parentPath, dir); - } - curpath = curpath + '/'; - } - */ } internal static void ReportArtifact(string artifactPath) diff --git a/com.unity.render-pipelines.core/ShaderLibrary/SpaceTransforms.hlsl b/com.unity.render-pipelines.core/ShaderLibrary/SpaceTransforms.hlsl index 47c008959a9..26e366ce141 100644 --- a/com.unity.render-pipelines.core/ShaderLibrary/SpaceTransforms.hlsl +++ b/com.unity.render-pipelines.core/ShaderLibrary/SpaceTransforms.hlsl @@ -301,8 +301,8 @@ real3 TransformTangentToWorldDir(real3 dirWS, real3x3 tangentToWorld, bool doNor float sgn = determinant < 0.0 ? (-1.0) : 1.0; // inverse transposed but scaled by determinant - // Will remove transpose part by using matrix as the first arg in the mul() below - // this makes it the exact inverse of what TransformTangentToWorld() does. + // Will remove transpose part by using matrix as the second arg in the mul() below + // this makes it the exact inverse of what TransformWorldToTangentDir() does. real3x3 matTBN_I_T = real3x3(col0, col1, col2); real3 result = sgn * mul(dirWS, matTBN_I_T); if (doNormalize) From 2346d00b3ea7a78453af5af43217a0b28a0fa373 Mon Sep 17 00:00:00 2001 From: Chris Tchou Date: Mon, 4 Oct 2021 12:26:03 -0700 Subject: [PATCH 20/23] Comment cleanup --- .../Editor/ShaderGraphTestRenderer.cs | 4 +--- .../ShaderLibrary/SpaceTransforms.hlsl | 18 +++++++++--------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/ShaderGraphTestRenderer.cs b/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/ShaderGraphTestRenderer.cs index 8f74aab4b9a..efd87611efd 100644 --- a/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/ShaderGraphTestRenderer.cs +++ b/TestProjects/ShaderGraph/Assets/CommonAssets/Editor/ShaderGraphTestRenderer.cs @@ -57,8 +57,8 @@ internal int RunNodeTest(GraphData graph, string filePrefix, SetupMaterialDelega // use a non-standard transform, so that view, object, etc. transforms are non trivial RenderQuadPreview(graph, target, testPosition, testRotation, setupMaterial, Mode.DIFF, useSRP: true); + // default expected color is green (test shaders should be set up to return green on success) int incorrectPixels = CountPixelsNotEqual(target, expectedColor ?? new Color32(0, 255, 0, 255), false); - //Debug.Log($"{filePrefix}: {target.width}x{target.height} Failing pixels: {incorrectPixels}"); if (incorrectPixels != expectedIncorrectPixels) { @@ -223,8 +223,6 @@ internal void RenderQuadPreview(GraphData graph, RenderTexture target, Vector3 s previewScene.camera.orthographicSize = 0.5f; previewScene.camera.orthographic = true; - // EditorUtility.SetCameraAnimateMaterialsTime(sceneResources.camera, 7.3542f); - graph.ValidateGraph(); // build the shader diff --git a/com.unity.render-pipelines.core/ShaderLibrary/SpaceTransforms.hlsl b/com.unity.render-pipelines.core/ShaderLibrary/SpaceTransforms.hlsl index 26e366ce141..a0a67d91401 100644 --- a/com.unity.render-pipelines.core/ShaderLibrary/SpaceTransforms.hlsl +++ b/com.unity.render-pipelines.core/ShaderLibrary/SpaceTransforms.hlsl @@ -111,13 +111,13 @@ float4 TransformObjectToHClip(float3 positionOS) return mul(GetWorldToHClipMatrix(), mul(GetObjectToWorldMatrix(), float4(positionOS, 1.0))); } -// Tranforms position from world space to homogenous space +// Transforms position from world space to homogenous space float4 TransformWorldToHClip(float3 positionWS) { return mul(GetWorldToHClipMatrix(), float4(positionWS, 1.0)); } -// Tranforms position from view space to homogenous space +// Transforms position from view space to homogenous space float4 TransformWViewToHClip(float3 positionVS) { return mul(GetViewToHClipMatrix(), float4(positionVS, 1.0)); @@ -151,7 +151,7 @@ float3 TransformWorldToObjectDir(float3 dirWS, bool doNormalize = true) return dirOS; } -// Tranforms vector from world space to view space +// Transforms vector from world space to view space real3 TransformWorldToViewDir(real3 dirWS, bool doNormalize = false) { float3 dirVS = mul((real3x3)GetWorldToViewMatrix(), dirWS).xyz; @@ -161,7 +161,7 @@ real3 TransformWorldToViewDir(real3 dirWS, bool doNormalize = false) return dirVS; } -// Tranforms vector from view space to world space +// Transforms vector from view space to world space real3 TransformViewToWorldDir(real3 dirVS, bool doNormalize = false) { float3 dirWS = mul((real3x3)GetViewToWorldMatrix(), dirVS).xyz; @@ -171,21 +171,21 @@ real3 TransformViewToWorldDir(real3 dirVS, bool doNormalize = false) return dirWS; } -// Tranforms normal from world space to view space +// Transforms normal from world space to view space real3 TransformWorldToViewNormal(real3 normalWS, bool doNormalize = false) { - // assuming view matrix is not non-uniformly scaled, we can use direction transform + // assuming view matrix is uniformly scaled, we can use direction transform return TransformWorldToViewDir(normalWS, doNormalize); } -// Tranforms normal from view space to world space +// Transforms normal from view space to world space real3 TransformViewToWorldNormal(real3 normalVS, bool doNormalize = false) { - // assuming view matrix is not non-uniformly scaled, we can use direction transform + // assuming view matrix is uniformly scaled, we can use direction transform return TransformViewToWorldDir(normalVS, doNormalize); } -// Tranforms vector from world space to homogenous space +// Transforms vector from world space to homogenous space real3 TransformWorldToHClipDir(real3 directionWS, bool doNormalize = false) { float3 dirHCS = mul((real3x3)GetWorldToHClipMatrix(), directionWS).xyz; From fab53e24968b191e595484bcf4f02ba178986c0f Mon Sep 17 00:00:00 2001 From: Chris Tchou Date: Mon, 4 Oct 2021 12:27:41 -0700 Subject: [PATCH 21/23] Fixing one more comment --- com.unity.shadergraph/Editor/Drawing/Inspector/InspectorView.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/com.unity.shadergraph/Editor/Drawing/Inspector/InspectorView.cs b/com.unity.shadergraph/Editor/Drawing/Inspector/InspectorView.cs index d4c6538a6c9..fb8ff832756 100644 --- a/com.unity.shadergraph/Editor/Drawing/Inspector/InspectorView.cs +++ b/com.unity.shadergraph/Editor/Drawing/Inspector/InspectorView.cs @@ -133,7 +133,7 @@ public void TriggerInspectorUpdate(IEnumerable selectionList) public void Update() { - // Tear down node all existing active property drawers, everything is getting rebuilt + // Tear down all existing active property drawers, everything is getting rebuilt foreach (IPropertyDrawer propDrawer in m_AllActivePropertyDrawers) propDrawer.DisposePropertyDrawer(); m_AllActivePropertyDrawers.Clear(); From c871da5454e407e88ca3014de70cec82fa73280a Mon Sep 17 00:00:00 2001 From: Chris Tchou Date: Mon, 4 Oct 2021 18:13:42 -0700 Subject: [PATCH 22/23] Fixing non-normalized tangent transforms (when your tangentToWorld is not orthogonal...) --- .../ShaderLibrary/SpaceTransforms.hlsl | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/com.unity.render-pipelines.core/ShaderLibrary/SpaceTransforms.hlsl b/com.unity.render-pipelines.core/ShaderLibrary/SpaceTransforms.hlsl index a0a67d91401..ebe50818ee9 100644 --- a/com.unity.render-pipelines.core/ShaderLibrary/SpaceTransforms.hlsl +++ b/com.unity.render-pipelines.core/ShaderLibrary/SpaceTransforms.hlsl @@ -261,16 +261,19 @@ real3 TransformWorldToTangent(real3 normalWS, real3x3 tangentToWorld, bool doNor float3 col2 = cross(row0, row1); float determinant = dot(row0, col0); - float sgn = determinant<0.0 ? (-1.0) : 1.0; // inverse transposed but scaled by determinant // Will remove transpose part by using matrix as the first arg in the mul() below // this makes it the exact inverse of what TransformTangentToWorld() does. real3x3 matTBN_I_T = real3x3(col0, col1, col2); - real3 result = sgn * mul(matTBN_I_T, normalWS); + real3 result = mul(matTBN_I_T, normalWS); if (doNormalize) - return SafeNormalize(result); - return result; + { + float sgn = determinant < 0.0 ? (-1.0) : 1.0; + return SafeNormalize(sgn * result); + } + else + return result / determinant; } // this function is intended to work on Vectors/Directions @@ -298,16 +301,19 @@ real3 TransformTangentToWorldDir(real3 dirWS, real3x3 tangentToWorld, bool doNor float3 col2 = cross(row0, row1); float determinant = dot(row0, col0); - float sgn = determinant < 0.0 ? (-1.0) : 1.0; // inverse transposed but scaled by determinant // Will remove transpose part by using matrix as the second arg in the mul() below // this makes it the exact inverse of what TransformWorldToTangentDir() does. real3x3 matTBN_I_T = real3x3(col0, col1, col2); - real3 result = sgn * mul(dirWS, matTBN_I_T); + real3 result = mul(dirWS, matTBN_I_T); if (doNormalize) - return SafeNormalize(result); - return result; + { + float sgn = determinant < 0.0 ? (-1.0) : 1.0; + return SafeNormalize(sgn * result); + } + else + return result / determinant; } real3 TransformTangentToObject(real3 dirTS, real3x3 tangentToWorld) From e24c5f16d68d12266484694ee5697ac699d14da4 Mon Sep 17 00:00:00 2001 From: Chris Tchou Date: Mon, 4 Oct 2021 18:24:41 -0700 Subject: [PATCH 23/23] Adding comments about what "tangentToWorld" matrix means --- .../ShaderLibrary/SpaceTransforms.hlsl | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/com.unity.render-pipelines.core/ShaderLibrary/SpaceTransforms.hlsl b/com.unity.render-pipelines.core/ShaderLibrary/SpaceTransforms.hlsl index ebe50818ee9..0995b2d35f6 100644 --- a/com.unity.render-pipelines.core/ShaderLibrary/SpaceTransforms.hlsl +++ b/com.unity.render-pipelines.core/ShaderLibrary/SpaceTransforms.hlsl @@ -235,6 +235,7 @@ real3x3 CreateTangentToWorld(real3 normal, real3 tangent, real flipSign) } // this function is intended to work on Normals (handles non-uniform scale) +// tangentToWorld is the matrix representing the transformation of a normal from tangent to world space real3 TransformTangentToWorld(real3 normalTS, real3x3 tangentToWorld, bool doNormalize = false) { // Note matrix is in row major convention with left multiplication as it is build on the fly @@ -248,6 +249,7 @@ real3 TransformTangentToWorld(real3 normalTS, real3x3 tangentToWorld, bool doNor // This function does the exact inverse of TransformTangentToWorld() and is // also decribed within comments in mikktspace.h and it follows implicitly // from the scalar triple product (google it). +// tangentToWorld is the matrix representing the transformation of a normal from tangent to world space real3 TransformWorldToTangent(real3 normalWS, real3x3 tangentToWorld, bool doNormalize = true) { // Note matrix is in row major convention with left multiplication as it is build on the fly @@ -277,6 +279,7 @@ real3 TransformWorldToTangent(real3 normalWS, real3x3 tangentToWorld, bool doNor } // this function is intended to work on Vectors/Directions +// tangentToWorld is the matrix representing the transformation of a normal from tangent to world space real3 TransformWorldToTangentDir(real3 dirWS, real3x3 tangentToWorld, bool doNormalize = false) { // Note matrix is in row major convention with left multiplication as it is build on the fly @@ -288,6 +291,7 @@ real3 TransformWorldToTangentDir(real3 dirWS, real3x3 tangentToWorld, bool doNor // this function is intended to work on Vectors/Directions // This function does the exact inverse of TransformWorldToTangentDir() +// tangentToWorld is the matrix representing the transformation of a normal from tangent to world space real3 TransformTangentToWorldDir(real3 dirWS, real3x3 tangentToWorld, bool doNormalize = false) { // Note matrix is in row major convention with left multiplication as it is build on the fly @@ -316,6 +320,7 @@ real3 TransformTangentToWorldDir(real3 dirWS, real3x3 tangentToWorld, bool doNor return result / determinant; } +// tangentToWorld is the matrix representing the transformation of a normal from tangent to world space real3 TransformTangentToObject(real3 dirTS, real3x3 tangentToWorld) { // Note matrix is in row major convention with left multiplication as it is build on the fly @@ -323,6 +328,7 @@ real3 TransformTangentToObject(real3 dirTS, real3x3 tangentToWorld) return TransformWorldToObjectNormal(normalWS); } +// tangentToWorld is the matrix representing the transformation of a normal from tangent to world space real3 TransformObjectToTangent(real3 dirOS, real3x3 tangentToWorld) { // Note matrix is in row major convention with left multiplication as it is build on the fly