浏览代码

Transform Triplanar normal output to tangent space

/main
Matt Dean 7 年前
当前提交
e36aeb23
共有 1 个文件被更改,包括 27 次插入1 次删除
  1. 28
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/UV/TriplanarNode.cs

28
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/UV/TriplanarNode.cs


namespace UnityEditor.ShaderGraph
{
[Title("UV", "Triplanar")]
public class TriplanarNode : AbstractMaterialNode, IGeneratesBodyCode, IMayRequirePosition, IMayRequireNormal
public class TriplanarNode : AbstractMaterialNode, IGeneratesBodyCode, IMayRequirePosition, IMayRequireNormal, IMayRequireTangent, IMayRequireBitangent
{
public const int OutputSlotId = 0;
public const int TextureInputId = 1;

, precision
, GetVariableNameForSlot(OutputSlotId)
, GetVariableNameForNode());
sb.AppendLine("float3x3 {0}_Transform = float3x3(IN.WorldSpaceTangent, IN.WorldSpaceBiTangent, IN.WorldSpaceNormal);", GetVariableNameForNode());
sb.AppendLine("{0}.rgb = TransformWorldToTangent({0}.rgb, {1}_Transform);"
, GetVariableNameForSlot(OutputSlotId)
, GetVariableNameForNode());
break;
default:
sb.AppendLine("{0}3 {1}_Blend = pow(abs({2}), {3});", precision, GetVariableNameForNode(),

public NeededCoordinateSpace RequiresNormal()
{
return CoordinateSpace.World.ToNeededCoordinateSpace();
}
public NeededCoordinateSpace RequiresTangent()
{
switch(m_TextureType)
{
case TextureType.Normal:
return CoordinateSpace.World.ToNeededCoordinateSpace();
default:
return NeededCoordinateSpace.None;
}
}
public NeededCoordinateSpace RequiresBitangent()
{
switch(m_TextureType)
{
case TextureType.Normal:
return CoordinateSpace.World.ToNeededCoordinateSpace();
default:
return NeededCoordinateSpace.None;
}
}
}
}
正在加载...
取消
保存