diff --git a/com.unity.shadergraph/CHANGELOG.md b/com.unity.shadergraph/CHANGELOG.md index c08dd8feca0..2899c5c0239 100644 --- a/com.unity.shadergraph/CHANGELOG.md +++ b/com.unity.shadergraph/CHANGELOG.md @@ -4,6 +4,11 @@ All notable changes to this package are documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## [10.x.x] + +### Added +- ShaderGraph BoneIndex & BoneWeight nodes + ## [10.9.0] - 2021-12-06 Version Updated diff --git a/com.unity.shadergraph/Editor/Data/Nodes/Input/Geometry/BoneIndexNode.cs b/com.unity.shadergraph/Editor/Data/Nodes/Input/Geometry/BoneIndexNode.cs new file mode 100644 index 00000000000..e355e967bdf --- /dev/null +++ b/com.unity.shadergraph/Editor/Data/Nodes/Input/Geometry/BoneIndexNode.cs @@ -0,0 +1,55 @@ +using System; +using System.Text.RegularExpressions; +using System.Collections.Generic; +using System.Linq; +using UnityEngine; +using UnityEditor.Graphing; +using UnityEditor.ShaderGraph.Drawing.Controls; +using UnityEditor.ShaderGraph.Internal; + +namespace UnityEditor.ShaderGraph +{ + [FormerName("UnityEngine.MaterialGraph.BoneIndexNode")] + [Title("Input", "Geometry", "BoneIndex")] + class BoneIndexNode : AbstractMaterialNode, IMayRequireVertexSkinning + { + public override int latestVersion => 1; + private const int kOutputSlotId = 0; + public const string kOutputSlotName = "Out"; + //public override List validSpaces => new List { CoordinateSpace.Object }; + + public BoneIndexNode() + { + name = "BoneIndex"; + precision = Precision.Single; + UpdateNodeAfterDeserialization(); + } + + + public sealed override void UpdateNodeAfterDeserialization() + { + AddSlot(new Vector4MaterialSlot(kOutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, Vector4.zero)); + RemoveSlotsNameNotMatching(new[] { kOutputSlotId }); + } + + public override string GetVariableNameForSlot(int slotId) + { + return "IN.BoneIndices"; + } + + public bool RequiresVertexSkinning(ShaderStageCapability stageCapability = ShaderStageCapability.All) + { + return true; + } + + public override void OnAfterMultiDeserialize(string json) + { + base.OnAfterMultiDeserialize(json); + //required update + if(sgVersion < 1) + { + ChangeVersion(1); + } + } + } +} diff --git a/com.unity.shadergraph/Editor/Data/Nodes/Input/Geometry/BoneIndexNode.cs.meta b/com.unity.shadergraph/Editor/Data/Nodes/Input/Geometry/BoneIndexNode.cs.meta new file mode 100644 index 00000000000..69d25d38f23 --- /dev/null +++ b/com.unity.shadergraph/Editor/Data/Nodes/Input/Geometry/BoneIndexNode.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 298d2a6c03c44b144baa0905b1794a12 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.unity.shadergraph/Editor/Data/Nodes/Input/Geometry/BoneWeightNode.cs b/com.unity.shadergraph/Editor/Data/Nodes/Input/Geometry/BoneWeightNode.cs new file mode 100644 index 00000000000..bb2a51c06a8 --- /dev/null +++ b/com.unity.shadergraph/Editor/Data/Nodes/Input/Geometry/BoneWeightNode.cs @@ -0,0 +1,55 @@ +using System; +using System.Text.RegularExpressions; +using System.Collections.Generic; +using System.Linq; +using UnityEngine; +using UnityEditor.Graphing; +using UnityEditor.ShaderGraph.Drawing.Controls; +using UnityEditor.ShaderGraph.Internal; + +namespace UnityEditor.ShaderGraph +{ + [FormerName("UnityEngine.MaterialGraph.BoneWeightNode")] + [Title("Input", "Geometry", "BoneWeight")] + class BoneWeightNode : AbstractMaterialNode, IMayRequireVertexSkinning + { + public override int latestVersion => 1; + private const int kOutputSlotId = 0; + public const string kOutputSlotName = "Out"; + //public override List validSpaces => new List { CoordinateSpace.Object }; + + public BoneWeightNode() + { + name = "BoneWeight"; + precision = Precision.Single; + UpdateNodeAfterDeserialization(); + } + + + public sealed override void UpdateNodeAfterDeserialization() + { + AddSlot(new Vector4MaterialSlot(kOutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, Vector4.zero)); + RemoveSlotsNameNotMatching(new[] { kOutputSlotId }); + } + + public override string GetVariableNameForSlot(int slotId) + { + return "IN.BoneWeights"; + } + + public bool RequiresVertexSkinning(ShaderStageCapability stageCapability = ShaderStageCapability.All) + { + return true; + } + + public override void OnAfterMultiDeserialize(string json) + { + base.OnAfterMultiDeserialize(json); + //required update + if(sgVersion < 1) + { + ChangeVersion(1); + } + } + } +} diff --git a/com.unity.shadergraph/Editor/Data/Nodes/Input/Geometry/BoneWeightNode.cs.meta b/com.unity.shadergraph/Editor/Data/Nodes/Input/Geometry/BoneWeightNode.cs.meta new file mode 100644 index 00000000000..2f6c9662470 --- /dev/null +++ b/com.unity.shadergraph/Editor/Data/Nodes/Input/Geometry/BoneWeightNode.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 9afd94d8053b70f41896d4c76afb81a9 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: