diff --git a/Packages/com.unity.shadergraph/Editor/Data/Graphs/DynamicVectorMaterialSlot.cs b/Packages/com.unity.shadergraph/Editor/Data/Graphs/DynamicVectorMaterialSlot.cs index ad0674e1ba7..5ca8f2d1141 100644 --- a/Packages/com.unity.shadergraph/Editor/Data/Graphs/DynamicVectorMaterialSlot.cs +++ b/Packages/com.unity.shadergraph/Editor/Data/Graphs/DynamicVectorMaterialSlot.cs @@ -84,7 +84,7 @@ protected override string ConcreteSlotValueAsVariable() var channelCount = SlotValueHelper.GetChannelCount(concreteValueType); string values = NodeUtils.FloatToShaderValue(value.x); if (channelCount == 1) - return values; + return string.Format("$precision({0})", values); for (var i = 1; i < channelCount; i++) values += ", " + NodeUtils.FloatToShaderValue(value[i]); return string.Format("$precision{0}({1})", channelCount, values); diff --git a/Packages/com.unity.shadergraph/Editor/Data/Graphs/Vector1MaterialSlot.cs b/Packages/com.unity.shadergraph/Editor/Data/Graphs/Vector1MaterialSlot.cs index 69588881abf..d3be40d45b0 100644 --- a/Packages/com.unity.shadergraph/Editor/Data/Graphs/Vector1MaterialSlot.cs +++ b/Packages/com.unity.shadergraph/Editor/Data/Graphs/Vector1MaterialSlot.cs @@ -69,7 +69,7 @@ public override VisualElement InstantiateControl() protected override string ConcreteSlotValueAsVariable() { - return NodeUtils.FloatToShaderValue(value); + return string.Format("$precision({0})", NodeUtils.FloatToShaderValue(value)); } public override void AddDefaultProperty(PropertyCollector properties, GenerationMode generationMode) diff --git a/Packages/com.unity.shadergraph/Tests/Editor/UnitTests/MaterialSlotTests.cs b/Packages/com.unity.shadergraph/Tests/Editor/UnitTests/MaterialSlotTests.cs index 53395d6abcd..01b17296242 100644 --- a/Packages/com.unity.shadergraph/Tests/Editor/UnitTests/MaterialSlotTests.cs +++ b/Packages/com.unity.shadergraph/Tests/Editor/UnitTests/MaterialSlotTests.cs @@ -103,8 +103,8 @@ public void MaterialSlotReturnsValidDefaultValue() Assert.AreEqual(expected, result); m_NodeA.slot1.value = 6; - result = m_NodeA.slot1.GetDefaultValue(GenerationMode.ForReals); - Assert.AreEqual("6", result); + result = m_NodeA.slot1.GetDefaultValue(GenerationMode.ForReals, ConcretePrecision.Half); + Assert.AreEqual("half(6)", result); m_NodeA.slot2.value = new Vector4(6, 6, 6, 1); result = m_NodeA.slot2.GetDefaultValue(GenerationMode.ForReals, ConcretePrecision.Half);