浏览代码

Merge pull request #1354 from Unity-Technologies/sg/fix-error-float-value-to-string

Fix float value to string error
/main
GitHub 7 年前
当前提交
92542c54
共有 5 个文件被更改,包括 15 次插入14 次删除
  1. 1
      ShaderGraph/CHANGELOG.md
  2. 8
      ShaderGraph/com.unity.shadergraph/Editor/Data/Graphs/ColorMaterialSlot.cs
  3. 6
      ShaderGraph/com.unity.shadergraph/Editor/Data/Graphs/ColorRGBMaterialSlot.cs
  4. 6
      ShaderGraph/com.unity.shadergraph/Editor/Data/Nodes/Artistic/Normal/NormalCreateNode.cs
  5. 8
      ShaderGraph/com.unity.shadergraph/Editor/Data/Nodes/Input/Basic/ColorNode.cs

1
ShaderGraph/CHANGELOG.md


- Make nodes that are copied from one graph to another spawn in the center of the current view. ([#333](https://github.com/Unity-Technologies/ShaderGraph/issues/333))
- Fixed an issue with editable sub graph paths, causing the search window to sometimes yield a null reference exception.
- Ensure that the blackboard is within view when deserialized.
- Fixed float value to string error and truncation warning for normal create node.

8
ShaderGraph/com.unity.shadergraph/Editor/Data/Graphs/ColorMaterialSlot.cs


{
return string.Format("IsGammaSpace() ? {0}4({1}, {2}, {3}, {4}) : {0}4 (SRGBToLinear({0}3({1}, {2}, {3})), {4})"
, precision
, value.x
, value.y
, value.z
, value.w);
, NodeUtils.FloatToShaderValue(value.x)
, NodeUtils.FloatToShaderValue(value.y)
, NodeUtils.FloatToShaderValue(value.z)
, NodeUtils.FloatToShaderValue(value.w));
}
public override void AddDefaultProperty(PropertyCollector properties, GenerationMode generationMode)

6
ShaderGraph/com.unity.shadergraph/Editor/Data/Graphs/ColorRGBMaterialSlot.cs


{
return string.Format("IsGammaSpace() ? {0}3({1}, {2}, {3}) : SRGBToLinear({0}3({1}, {2}, {3}))"
, precision
, value.x
, value.y
, value.z);
, NodeUtils.FloatToShaderValue(value.x)
, NodeUtils.FloatToShaderValue(value.y)
, NodeUtils.FloatToShaderValue(value.z));
}
public override void AddDefaultProperty(PropertyCollector properties, GenerationMode generationMode)

6
ShaderGraph/com.unity.shadergraph/Editor/Data/Nodes/Artistic/Normal/NormalCreateNode.cs


sb.AppendLine("{0}2 offsetU = float2(UV.x + Offset, UV.y);", precision);
sb.AppendLine("{0}2 offsetV = float2(UV.x, UV.y + Offset);", precision);
sb.AppendLine("{0} normalSample = Texture.Sample(Sampler, UV);", precision);
sb.AppendLine("{0} uSample = Texture.Sample(Sampler, offsetU);", precision);
sb.AppendLine("{0} vSample = Texture.Sample(Sampler, offsetV);", precision);
sb.AppendLine("{0} normalSample = Texture.Sample(Sampler, UV).x;", precision);
sb.AppendLine("{0} uSample = Texture.Sample(Sampler, offsetU).x;", precision);
sb.AppendLine("{0} vSample = Texture.Sample(Sampler, offsetV).x;", precision);
sb.AppendLine("{0}3 va = float3(1, 0, (uSample - normalSample) * Strength);", precision);
sb.AppendLine("{0}3 vb = float3(0, 1, (vSample - normalSample) * Strength);", precision);

8
ShaderGraph/com.unity.shadergraph/Editor/Data/Nodes/Input/Basic/ColorNode.cs


@"{0}4 {1} = IsGammaSpace() ? {0}4({2}, {3}, {4}, {5}) : {0}4(SRGBToLinear({0}3({2}, {3}, {4})), {5});"
, precision
, GetVariableNameForNode()
, color.color.r
, color.color.g
, color.color.b
, color.color.a), true);
, NodeUtils.FloatToShaderValue(color.color.r)
, NodeUtils.FloatToShaderValue(color.color.g)
, NodeUtils.FloatToShaderValue(color.color.b)
, NodeUtils.FloatToShaderValue(color.color.a)), true);
}
public override string GetVariableNameForSlot(int slotId)

正在加载...
取消
保存