浏览代码

Update Transform node to latest SRP library

/main
Matt Dean 7 年前
当前提交
a20b14d1
共有 1 个文件被更改,包括 14 次插入16 次删除
  1. 30
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Vector/TransformNode.cs

30
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Vector/TransformNode.cs


}
else if (conversion.to == CoordinateSpace.Object)
{
transformString = "mul(unity_WorldToObject, float4(" + inputValue + ", 0)).xyz";
transformString = string.Format("TransformWorldToObject({0})", inputValue);
transformString = "mul(" + inputValue + ", " + targetTransformString + ").xyz";
transformString = string.Format("TransformWorldToTangent({0}, {1})", inputValue, targetTransformString);
transformString = "mul( UNITY_MATRIX_V, float4(" + inputValue + ", 0)).xyz";
transformString = string.Format("TransformWorldToView({0})", inputValue);
}
}
else if (conversion.from == CoordinateSpace.Object)

transformString = "mul(unity_ObjectToWorld, float4(" + inputValue + ", 0)).xyz";
transformString = string.Format("TransformObjectToWorld({0})", inputValue);
}
else if (conversion.to == CoordinateSpace.Object)
{

{
requiresTangentTransform = true;
transformString = "mul(float4(" + inputValue + ", 0).xyz, " + targetTransformString + ").xyz";
transformString = string.Format("TransformWorldToTangent(TransformObjectToWorld({0}), {1})", inputValue, targetTransformString);
transformString = "mul( UNITY_MATRIX_MV, float4(" + inputValue + ", 0)).xyz";
transformString = string.Format("TransformWorldToView(TransformObjectToWorld({0}))", inputValue);
}
}
else if (conversion.from == CoordinateSpace.Tangent)

requiresTransposeTangentTransform = true;
transformString = "mul( " + inputValue + ", " + transposeTargetTransformString + " ).xyz";
transformString = string.Format("mul({0}, {1}).xyz", inputValue, transposeTargetTransformString);
transformString = "mul( unity_WorldToObject, float4(mul(" + inputValue + ", " + transposeTargetTransformString + " ),0) ).xyz";
transformString = string.Format("TransformWorldToObject(mul({0}, {1}).xyz)", inputValue, transposeTargetTransformString);
}
else if (conversion.to == CoordinateSpace.Tangent)
{

{
requiresTransposeTangentTransform = true;
transformString = "mul( UNITY_MATRIX_V, float4(mul(" + inputValue + ", " + transposeTargetTransformString + " ),0) ).xyz";
transformString = string.Format("TransformWorldToView(mul({0}, {1}).xyz)", inputValue, transposeTargetTransformString);
}
}
else if (conversion.from == CoordinateSpace.View)

transformString = "mul( float4(" + inputValue + ", 0), UNITY_MATRIX_V ).xyz";
transformString = string.Format("mul(UNITY_MATRIX_I_V, float4({0}, 1)).xyz", inputValue);
transformString = "mul( float4(" + inputValue + ", 0), UNITY_MATRIX_MV ).xyz";
transformString = string.Format("TransformWorldToObject(mul(UNITY_MATRIX_I_V, float4({0}, 1) ).xyz)", inputValue);
transformString = "mul( mul( float4(" + inputValue + ", 0), UNITY_MATRIX_V ).xyz, " + targetTransformString + ").xyz";
transformString = string.Format("TransformWorldToTangent(mul(UNITY_MATRIX_I_V, float4({0}, 1) ).xyz, {1})", inputValue, targetTransformString);
}
else if (conversion.to == CoordinateSpace.View)
{

visitor.AddShaderChunk("float3x3 " + transposeTargetTransformString + " = transpose(float3x3(" + CoordinateSpace.World.ToString() + "SpaceTangent, " + CoordinateSpace.World.ToString() + "SpaceBiTangent, " + CoordinateSpace.World.ToString() + "SpaceNormal));", true);
visitor.AddShaderChunk(string.Format("float3x3 {0} = transpose(float3x3(IN.{1}SpaceTangent, IN.{1}SpaceBiTangent, IN.{1}SpaceNormal));", transposeTargetTransformString, CoordinateSpace.World.ToString()), true);
visitor.AddShaderChunk("float3x3 " + targetTransformString + " = float3x3(" + tangentTransformSpace + "SpaceTangent, " + tangentTransformSpace + "SpaceBiTangent, " + tangentTransformSpace + "SpaceNormal);", true);
visitor.AddShaderChunk(string.Format("float3x3 {0} = CreateWorldToTangent(IN.{1}SpaceNormal, IN.{1}SpaceTangent, 1);", targetTransformString, tangentTransformSpace), true);
visitor.AddShaderChunk(string.Format("{0} {1} = {2};", NodeUtils.ConvertConcreteSlotValueTypeToString(precision, FindOutputSlot<MaterialSlot>(OutputSlotId).concreteValueType),
GetVariableNameForSlot(OutputSlotId),
transformString), true);

正在加载...
取消
保存