mathe/Library/PackageCache/com.unity.shadergraph@14.0.8/Editor/Data/Graphs/NormalMaterialSlot.cs

41 lines
1.6 KiB
C#
Raw Normal View History

2024-09-20 20:30:10 +02:00
using System;
using UnityEditor.ShaderGraph.Drawing.Slots;
using UnityEditor.ShaderGraph.Internal;
using UnityEngine.UIElements;
namespace UnityEditor.ShaderGraph
{
[Serializable]
class NormalMaterialSlot : SpaceMaterialSlot, IMayRequireNormal
{
public NormalMaterialSlot()
{ }
public NormalMaterialSlot(int slotId, string displayName, string shaderOutputName, CoordinateSpace space,
ShaderStageCapability stageCapability = ShaderStageCapability.All, bool hidden = false)
: base(slotId, displayName, shaderOutputName, space, stageCapability, hidden)
{ }
public override VisualElement InstantiateControl()
{
return new LabelSlotControlView(space + " Space");
}
public override string GetDefaultValue(GenerationMode generationMode)
{
// HACK: we don't define AbsoluteWorldSpaceNormal, but it is the same as WorldSpaceNormal
var coordSpace = (space == CoordinateSpace.AbsoluteWorld) ? CoordinateSpace.World : space;
return string.Format("IN.{0}", coordSpace.ToVariableName(InterpolatorType.Normal));
}
public NeededCoordinateSpace RequiresNormal(ShaderStageCapability stageCapability)
{
if (isConnected)
return NeededCoordinateSpace.None;
// HACK: we don't define AbsoluteWorldSpaceNormal, but it is the same as WorldSpaceNormal
var coordSpace = (space == CoordinateSpace.AbsoluteWorld) ? CoordinateSpace.World : space;
return coordSpace.ToNeededCoordinateSpace();
}
}
}