Boat Attack使用了Universal RP的许多新图形功能,可以用于探索 Universal RP 的使用方式和技巧。
您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 

75 行
1.8 KiB

using System.Reflection;
using UnityEngine;
using UnityEditor.Graphing;
using UnityEditor.ShaderGraph.Drawing.Controls;
namespace UnityEditor.ShaderGraph
{
enum ReciprocalMethod
{
Default,
Fast
};
[Title("Math", "Advanced", "Reciprocal")]
class ReciprocalNode : CodeFunctionNode
{
public ReciprocalNode()
{
name = "Reciprocal";
}
[SerializeField]
private ReciprocalMethod m_ReciprocalMethod = ReciprocalMethod.Default;
[EnumControl("Method")]
public ReciprocalMethod reciprocalMethod
{
get { return m_ReciprocalMethod; }
set
{
if (m_ReciprocalMethod == value)
return;
m_ReciprocalMethod = value;
Dirty(ModificationScope.Graph);
}
}
protected override MethodInfo GetFunctionToConvert()
{
switch (m_ReciprocalMethod)
{
case ReciprocalMethod.Fast:
return GetType().GetMethod("Unity_Reciprocal_Fast", BindingFlags.Static | BindingFlags.NonPublic);
default:
return GetType().GetMethod("Unity_Reciprocal", BindingFlags.Static | BindingFlags.NonPublic);
}
}
static string Unity_Reciprocal(
[Slot(0, Binding.None, 1, 1, 1, 1)] DynamicDimensionVector In,
[Slot(1, Binding.None)] out DynamicDimensionVector Out)
{
return
@"
{
Out = 1.0/In;
}
";
}
static string Unity_Reciprocal_Fast(
[Slot(0, Binding.None, 1, 1, 1, 1)] DynamicDimensionVector In,
[Slot(1, Binding.None)] out DynamicDimensionVector Out)
{
return
@"
{
Out = rcp(In);
}
";
}
}
}