您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 

59 行
1.8 KiB

using UnityEditor.ShaderGraph.Drawing.Controls;
using UnityEngine;
using UnityEditor.Graphing;
namespace UnityEditor.ShaderGraph
{
[Title("Input", "Geometry", "UV")]
public class UVNode : AbstractMaterialNode, IGeneratesBodyCode, IMayRequireMeshUV
{
public const int OutputSlotId = 0;
private const string kOutputSlotName = "Out";
[SerializeField]
private UVChannel m_OutputChannel;
[EnumControl("Channel")]
public UVChannel uvChannel
{
get { return m_OutputChannel; }
set
{
if (m_OutputChannel == value)
return;
m_OutputChannel = value;
Dirty(ModificationScope.Graph);
}
}
public override bool hasPreview { get { return true; } }
public UVNode()
{
name = "UV";
UpdateNodeAfterDeserialization();
}
public override string documentationURL
{
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/UV-Node"; }
}
public override void UpdateNodeAfterDeserialization()
{
AddSlot(new Vector4MaterialSlot(OutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, Vector2.zero));
RemoveSlotsNameNotMatching(new[] { OutputSlotId });
}
public void GenerateNodeCode(ShaderGenerator visitor, GenerationMode generationMode)
{
visitor.AddShaderChunk(string.Format("{0}4 {1} = IN.{2};", precision, GetVariableNameForSlot(OutputSlotId), m_OutputChannel.GetUVName()), true);
}
public bool RequiresMeshUV(UVChannel channel, ShaderStageCapability stageCapability)
{
return channel == uvChannel;
}
}
}