浏览代码

Fix object and world position affine check

/main
Matt Dean 7 年前
当前提交
db7fee2a
共有 1 个文件被更改,包括 7 次插入6 次删除
  1. 13
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Util/ShaderGenerator.cs

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


}
}
public static string EmitTransform(TransformDesc[] matrices, TransformDesc[] invMatrices, string variable, bool isAffine, bool inverseTranspose)
public static string EmitTransform(TransformDesc[] matrices, TransformDesc[] invMatrices, string variable, bool isAffine, bool noMatrixCast, bool inverseTranspose)
{
if (inverseTranspose)
matrices = invMatrices;

foreach (var m in matrices)
{
var matrix = m.name;
if (!isAffine)
if (!isAffine && !noMatrixCast)
{
matrix = "(float3x3)" + matrix;
}

// Ensure that the transform graph is initialized
InitTransforms();
bool isNormal = false;
bool affine = (inputType == InputType.Position);
bool affine = (inputType == InputType.Position && to != CoordinateSpace.World);
bool noMatrixCast = (inputType == InputType.Position && to == CoordinateSpace.World);
if (inputType == InputType.Normal)
{
inputType = InputType.Vector;

variable = EmitTransform(
GetTransformPath(CoordinateSpace.Tangent, tangentMatrixSpace),
GetTransformPath(tangentMatrixSpace, CoordinateSpace.Tangent),
variable, affine, !isNormal);
variable, affine, noMatrixCast, !isNormal);
return EmitTransform(GetTransformPath(from, to), GetTransformPath(to, from), variable, affine, isNormal);
return EmitTransform(GetTransformPath(from, to), GetTransformPath(to, from), variable, affine, noMatrixCast, isNormal);
}
public static void GenerateSpaceTranslationSurfaceInputs(

{
var name = preferedCoordinateSpace.ToVariableName(InterpolatorType.Position);
interpolators.AddShaderChunk(string.Format("float3 {0} : TEXCOORD{1};", name, interpolatorIndex), false);
vertexShader.AddShaderChunk(string.Format("o.{0} = {1};", name, ConvertBetweenSpace("v.vertex", CoordinateSpace.Object, preferedCoordinateSpace, InputType.Vector)), false);
vertexShader.AddShaderChunk(string.Format("o.{0} = {1};", name, ConvertBetweenSpace("v.vertex", CoordinateSpace.Object, preferedCoordinateSpace, InputType.Position)), false);
pixelShader.AddShaderChunk(string.Format("float3 {0} = IN.{0};", name), false);
interpolatorIndex++;
}

正在加载...
取消
保存