浏览代码

Remove partial derivative precision

/main
Matt Dean 7 年前
当前提交
df7a48db
共有 3 个文件被更改,包括 6 次插入184 次删除
  1. 68
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Derivative/DDXNode.cs
  2. 61
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Derivative/DDXYNode.cs
  3. 61
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Derivative/DDYNode.cs

68
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Derivative/DDXNode.cs


namespace UnityEditor.ShaderGraph
{
public enum PartialDerivativePrecision
{
Coarse,
Default,
Fine
};
[Title("Math", "Derivative", "DDX")]
public class DDXNode : CodeFunctionNode
{

}
[SerializeField]
private PartialDerivativePrecision m_PartialDerivativePrecision = PartialDerivativePrecision.Default;
[EnumControl("Precision")]
public PartialDerivativePrecision partialDerivativePrecision
{
get { return m_PartialDerivativePrecision; }
set
{
if (m_PartialDerivativePrecision == value)
return;
m_PartialDerivativePrecision = value;
if (onModified != null)
{
onModified(this, ModificationScope.Graph);
}
}
}
string GetCurrentPrecision()
{
return System.Enum.GetName(typeof(PartialDerivativePrecision), m_PartialDerivativePrecision);
}
switch (m_PartialDerivativePrecision)
{
case PartialDerivativePrecision.Fine:
return GetType().GetMethod("Unity_DDX_Fine", BindingFlags.Static | BindingFlags.NonPublic);
case PartialDerivativePrecision.Coarse:
return GetType().GetMethod("Unity_DDX_Coarse", BindingFlags.Static | BindingFlags.NonPublic);
default:
return GetType().GetMethod("Unity_DDX_Default", BindingFlags.Static | BindingFlags.NonPublic);
}
return GetType().GetMethod("Unity_DDX", BindingFlags.Static | BindingFlags.NonPublic);
static string Unity_DDX_Default(
static string Unity_DDX(
[Slot(0, Binding.None)] DynamicDimensionVector In,
[Slot(1, Binding.None)] out DynamicDimensionVector Out)
{

Out = ddx(In);
}
";
}
static string Unity_DDX_Coarse(
[Slot(0, Binding.None)] DynamicDimensionVector In,
[Slot(1, Binding.None)] out DynamicDimensionVector Out)
{
return
@"
{
Out = ddx_coarse(In);
}
";
}
static string Unity_DDX_Fine(
[Slot(0, Binding.None)] DynamicDimensionVector In,
[Slot(1, Binding.None)] out DynamicDimensionVector Out)
{
return
@"
{
Out = ddx_fine(In);
}
";
}

61
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Derivative/DDXYNode.cs


name = "DDXY";
}
[SerializeField]
private PartialDerivativePrecision m_PartialDerivativePrecision = PartialDerivativePrecision.Default;
[EnumControl("Precision")]
public PartialDerivativePrecision partialDerivativePrecision
{
get { return m_PartialDerivativePrecision; }
set
{
if (m_PartialDerivativePrecision == value)
return;
m_PartialDerivativePrecision = value;
if (onModified != null)
{
onModified(this, ModificationScope.Graph);
}
}
}
string GetCurrentPrecision()
{
return System.Enum.GetName(typeof(PartialDerivativePrecision), m_PartialDerivativePrecision);
}
switch (m_PartialDerivativePrecision)
{
case PartialDerivativePrecision.Fine:
return GetType().GetMethod("Unity_DDXY_Fine", BindingFlags.Static | BindingFlags.NonPublic);
case PartialDerivativePrecision.Coarse:
return GetType().GetMethod("Unity_DDXY_Coarse", BindingFlags.Static | BindingFlags.NonPublic);
default:
return GetType().GetMethod("Unity_DDXY_Default", BindingFlags.Static | BindingFlags.NonPublic);
}
return GetType().GetMethod("Unity_DDXY", BindingFlags.Static | BindingFlags.NonPublic);
static string Unity_DDXY_Default(
static string Unity_DDXY(
[Slot(0, Binding.None)] DynamicDimensionVector In,
[Slot(1, Binding.None)] out DynamicDimensionVector Out)
{

Out = abs(ddx(In) + ddy(In));
}
";
}
static string Unity_DDXY_Coarse(
[Slot(0, Binding.None)] DynamicDimensionVector In,
[Slot(1, Binding.None)] out DynamicDimensionVector Out)
{
return
@"
{
Out = abs(ddx_coarse(In) + ddy_coarse(In));
}
";
}
static string Unity_DDXY_Fine(
[Slot(0, Binding.None)] DynamicDimensionVector In,
[Slot(1, Binding.None)] out DynamicDimensionVector Out)
{
return
@"
{
Out = abs(ddx_fine(In) + ddy_fine(In));
}
";
}

61
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Derivative/DDYNode.cs


name = "DDY";
}
[SerializeField]
private PartialDerivativePrecision m_PartialDerivativePrecision = PartialDerivativePrecision.Default;
[EnumControl("Precision")]
public PartialDerivativePrecision partialDerivativePrecision
{
get { return m_PartialDerivativePrecision; }
set
{
if (m_PartialDerivativePrecision == value)
return;
m_PartialDerivativePrecision = value;
if (onModified != null)
{
onModified(this, ModificationScope.Graph);
}
}
}
string GetCurrentPrecision()
{
return System.Enum.GetName(typeof(PartialDerivativePrecision), m_PartialDerivativePrecision);
}
switch (m_PartialDerivativePrecision)
{
case PartialDerivativePrecision.Fine:
return GetType().GetMethod("Unity_DDY_Fine", BindingFlags.Static | BindingFlags.NonPublic);
case PartialDerivativePrecision.Coarse:
return GetType().GetMethod("Unity_DDY_Coarse", BindingFlags.Static | BindingFlags.NonPublic);
default:
return GetType().GetMethod("Unity_DDY_Default", BindingFlags.Static | BindingFlags.NonPublic);
}
return GetType().GetMethod("Unity_DDY", BindingFlags.Static | BindingFlags.NonPublic);
static string Unity_DDY_Default(
static string Unity_DDY(
[Slot(0, Binding.None)] DynamicDimensionVector In,
[Slot(1, Binding.None)] out DynamicDimensionVector Out)
{

Out = ddy(In);
}
";
}
static string Unity_DDY_Coarse(
[Slot(0, Binding.None)] DynamicDimensionVector In,
[Slot(1, Binding.None)] out DynamicDimensionVector Out)
{
return
@"
{
Out = ddy_coarse(In);
}
";
}
static string Unity_DDY_Fine(
[Slot(0, Binding.None)] DynamicDimensionVector In,
[Slot(1, Binding.None)] out DynamicDimensionVector Out)
{
return
@"
{
Out = ddy_fine(In);
}
";
}
正在加载...
取消
保存