|
|
|
|
|
|
|
|
|
|
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); |
|
|
|
} |
|
|
|
";
|
|
|
|
} |