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

60 行
1.8 KiB

using UnityEngine;
using UnityEditor.Graphing;
using UnityEditor.ShaderGraph.Drawing.Controls;
namespace UnityEditor.ShaderGraph
{
[Title("Input", "Geometry", "Screen Position")]
class ScreenPositionNode : AbstractMaterialNode, IGeneratesBodyCode, IMayRequireScreenPosition
{
public ScreenPositionNode()
{
name = "Screen Position";
UpdateNodeAfterDeserialization();
}
[SerializeField]
private ScreenSpaceType m_ScreenSpaceType = ScreenSpaceType.Default;
[EnumControl("Mode")]
public ScreenSpaceType screenSpaceType
{
get { return m_ScreenSpaceType; }
set
{
if (m_ScreenSpaceType == value)
return;
m_ScreenSpaceType = value;
Dirty(ModificationScope.Graph);
}
}
private const int kOutputSlotId = 0;
private const string kOutputSlotName = "Out";
public override bool hasPreview { get { return true; } }
public override PreviewMode previewMode
{
get { return PreviewMode.Preview2D; }
}
public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new Vector4MaterialSlot(kOutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, Vector4.zero));
RemoveSlotsNameNotMatching(new[] { kOutputSlotId });
}
public void GenerateNodeCode(ShaderStringBuilder sb, GenerationMode generationMode)
{
sb.AppendLine(string.Format("$precision4 {0} = {1};", GetVariableNameForSlot(kOutputSlotId), m_ScreenSpaceType.ToValueAsVariable()));
}
public bool RequiresScreenPosition(ShaderStageCapability stageCapability)
{
return true;
}
}
}