|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
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++; |
|
|
|
} |
|
|
|