Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System;
using System.Linq;
using System.Collections.Generic;
using UnityEditor.Graphing;
using UnityEditor.ShaderGraph.Drawing.Controls;
using UnityEditor.ShaderGraph.Internal;
Expand Down Expand Up @@ -294,12 +296,62 @@ public NeededCoordinateSpace RequiresNormal(ShaderStageCapability stageCapabilit
return conversion.from.ToNeededCoordinateSpace();
}

public NeededTransform[] RequiresTransform(ShaderStageCapability stageCapability)
static readonly bool[,] k_ViaWorldFunction = new bool[5, 5] // [from, to]
{
{ // from CoordinateSpace.Object
false, // to CoordinateSpace.Object
true, // to CoordinateSpace.View
false, // to CoordinateSpace.World
true, // to CoordinateSpace.Tangent
true, // to CoordinateSpace.AbsoluteWorld
},
{ // from CoordinateSpace.View
true, // to CoordinateSpace.Object
false, // to CoordinateSpace.View
false, // to CoordinateSpace.World
true, // to CoordinateSpace.Tangent
true, // to CoordinateSpace.AbsoluteWorld
},
{ // from CoordinateSpace.World
false, // to CoordinateSpace.Object
false, // to CoordinateSpace.View
false, // to CoordinateSpace.World
false, // to CoordinateSpace.Tangent
false, // to CoordinateSpace.AbsoluteWorld
},
{ // from CoordinateSpace.Tangent
true, // to CoordinateSpace.Object
true, // to CoordinateSpace.View
false, // to CoordinateSpace.World
false, // to CoordinateSpace.Tangent
true, // to CoordinateSpace.AbsoluteWorld
},
{ // from CoordinateSpace.AbsoluteWorld
true, // to CoordinateSpace.Object
true, // to CoordinateSpace.View
false, // to CoordinateSpace.World
true, // to CoordinateSpace.Tangent
false, // to CoordinateSpace.AbsoluteWorld
}
};

internal static IEnumerable<NeededTransform> ComputeTransformRequirement(CoordinateSpaceConversion xform)
{
return new[]
var viaWorld = k_ViaWorldFunction[(int)xform.from, (int)xform.to];
if (viaWorld)
{
yield return new NeededTransform(xform.from.ToNeededCoordinateSpace(), NeededCoordinateSpace.World);
yield return new NeededTransform(NeededCoordinateSpace.World, xform.to.ToNeededCoordinateSpace());
}
else
{
new NeededTransform(conversion.from.ToNeededCoordinateSpace(), conversion.to.ToNeededCoordinateSpace())
};
yield return new NeededTransform(xform.from.ToNeededCoordinateSpace(), xform.to.ToNeededCoordinateSpace());
}
}

public NeededTransform[] RequiresTransform(ShaderStageCapability stageCapability)
{
return ComputeTransformRequirement(conversion).ToArray();
}
}
}
1 change: 1 addition & 0 deletions com.unity.visualeffectgraph/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Fixed
- Automatically offset contexts when a new node is inserted to avoid overlapping
- Fixed null reference exception when opening another VFX and a debug mode is enabled [Case 1347420](https://issuetracker.unity3d.com/product/unity/issues/guid/1347420/)
- Incorrect behavior of Tangent Space in ShaderGraph [Case 1363279](https://issuetracker.unity3d.com/product/unity/issues/guid/1363279/)

## [12.1.2] - 2021-10-22
### Fixed
Expand Down