浏览代码

tidy up code

/main
Tim Cooper 7 年前
当前提交
5bc05ae7
共有 1 个文件被更改,包括 45 次插入39 次删除
  1. 84
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Util/ShaderGenerator.cs

84
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Util/ShaderGenerator.cs


get { return m_ShaderChunks.Count; }
}
public enum InputType
public enum InputType
{
Position,
Vector,

this.name = name;
transpose = false;
}
static TransformDesc[] GetTransformPath(CoordinateSpace from, CoordinateSpace to)
{
if (m_transforms[(int) from, (int) to] != null)

var queue = new List<CoordinateSpace>();
foreach (var space in Enum.GetValues(typeof(CoordinateSpace)))
{
distance[(int)space] = int.MaxValue;
prev[(int)space] = null;
queue.Add((CoordinateSpace)space);
distance[(int) space] = int.MaxValue;
prev[(int) space] = null;
queue.Add((CoordinateSpace) space);
distance[(int)from] = 0;
distance[(int) from] = 0;
queue.Sort((x, y) => distance[(int)x] - distance[(int)y]);
queue.Sort((x, y) => distance[(int) x] - distance[(int) y]);
while (prev[(int)min] != null)
while (prev[(int) min] != null)
min = prev[(int)min].Value;
min = prev[(int) min].Value;
if (distance[(int)min] == int.MaxValue)
if (distance[(int) min] == int.MaxValue)
int index = (int)space;
if (m_transforms[(int)min, index] != null)
int index = (int) space;
if (m_transforms[(int) min, index] != null)
var alt = distance[(int)min] + m_transforms[(int)min, index].Length;
var alt = distance[(int) min] + m_transforms[(int) min, index].Length;
if (alt < distance[index])
{
distance[index] = alt;

}
}
path.Reverse();
var matrixList = new TransformDesc[path.Count];
int idx = 0;
var matrixList = new List<TransformDesc>();
matrixList[idx] = m_transforms[(int)from, (int)node][0];
matrixList.AddRange(m_transforms[(int) from, (int) node]);
idx++;
return matrixList;
return matrixList.ToArray();
}
static void InitTransforms()

m_transforms = new TransformDesc[4, 4][];
m_transforms[(int)CoordinateSpace.Object, (int)CoordinateSpace.Object] = new TransformDesc[] { };
m_transforms[(int)CoordinateSpace.View, (int)CoordinateSpace.View] = new TransformDesc[] { };
m_transforms[(int)CoordinateSpace.World, (int)CoordinateSpace.World] = new TransformDesc[] { };
m_transforms[(int)CoordinateSpace.Tangent, (int)CoordinateSpace.Tangent] = new TransformDesc[] { };
m_transforms[(int)CoordinateSpace.Object, (int)CoordinateSpace.World]
= new TransformDesc[] { new TransformDesc("unity_ObjectToWorld") };
m_transforms[(int)CoordinateSpace.View, (int)CoordinateSpace.World]
= new TransformDesc[] { new TransformDesc("UNITY_MATRIX_I_V") };
m_transforms[(int)CoordinateSpace.World, (int)CoordinateSpace.Object]
= new TransformDesc[] { new TransformDesc("unity_WorldToObject") };
m_transforms[(int)CoordinateSpace.World, (int)CoordinateSpace.View]
= new TransformDesc[] { new TransformDesc("UNITY_MATRIX_V") };
m_transforms[(int) CoordinateSpace.Object, (int) CoordinateSpace.Object] = new TransformDesc[] { };
m_transforms[(int) CoordinateSpace.View, (int) CoordinateSpace.View] = new TransformDesc[] { };
m_transforms[(int) CoordinateSpace.World, (int) CoordinateSpace.World] = new TransformDesc[] { };
m_transforms[(int) CoordinateSpace.Tangent, (int) CoordinateSpace.Tangent] = new TransformDesc[] { };
m_transforms[(int) CoordinateSpace.Object, (int) CoordinateSpace.World]
= new TransformDesc[] {new TransformDesc("unity_ObjectToWorld")};
m_transforms[(int) CoordinateSpace.View, (int) CoordinateSpace.World]
= new TransformDesc[] {new TransformDesc("UNITY_MATRIX_I_V")};
m_transforms[(int) CoordinateSpace.World, (int) CoordinateSpace.Object]
= new TransformDesc[] {new TransformDesc("unity_WorldToObject")};
m_transforms[(int) CoordinateSpace.World, (int) CoordinateSpace.View]
= new TransformDesc[] {new TransformDesc("UNITY_MATRIX_V")};
if (m_transforms[(int)from, (int)to] == null)
if (m_transforms[(int) from, (int) to] == null)
m_transforms[(int)from, (int)to] = GetTransformPath(from, to);
m_transforms[(int) from, (int) to] = GetTransformPath(from, to);
}
}
}

m_transforms[(int)CoordinateSpace.Tangent, (int)k] = null;
m_transforms[(int)k, (int)CoordinateSpace.Tangent] = null;
m_transforms[(int) CoordinateSpace.Tangent, (int) k] = null;
m_transforms[(int) k, (int) CoordinateSpace.Tangent] = null;
public static string EmitTransform(TransformDesc[] matrices, TransformDesc[] invMatrices, string variable, bool isAffine, bool inverseTranspose)
{
if (inverseTranspose)

return variable;
}
public static string ConvertBetweenSpace(string variable, CoordinateSpace from, CoordinateSpace to, InputType inputType, CoordinateSpace tangentMatrixSpace = CoordinateSpace.Object)
public static string ConvertBetweenSpace(string variable, CoordinateSpace from, CoordinateSpace to,
InputType inputType, CoordinateSpace tangentMatrixSpace = CoordinateSpace.Object)
{
if (from == to)
{

inputType = InputType.Vector;
isNormal = true;
}
m_transforms[(int)CoordinateSpace.Tangent, (int)tangentMatrixSpace] = new[] { new TransformDesc("tangentSpaceTransform") };
m_transforms[(int)tangentMatrixSpace, (int)CoordinateSpace.Tangent] = new[] { new TransformDesc("tangentSpaceTransform", true) };
m_transforms[(int) CoordinateSpace.Tangent, (int) tangentMatrixSpace] =
new[] {new TransformDesc("tangentSpaceTransform")};
m_transforms[(int) tangentMatrixSpace, (int) CoordinateSpace.Tangent] = new[]
{new TransformDesc("tangentSpaceTransform", true)};
GetTransformPath(CoordinateSpace.Tangent, tangentMatrixSpace),
GetTransformPath(tangentMatrixSpace, CoordinateSpace.Tangent),
variable, affine, !isNormal);
GetTransformPath(CoordinateSpace.Tangent, tangentMatrixSpace),
GetTransformPath(tangentMatrixSpace, CoordinateSpace.Tangent),
variable, affine, !isNormal);
if (to == tangentMatrixSpace)
{
return variable;

正在加载...
取消
保存