浏览代码

Object Node

/main
Matt Dean 7 年前
当前提交
e9a12809
共有 2 个文件被更改,包括 49 次插入0 次删除
  1. 41
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Scene/ObjectNode.cs
  2. 8
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Scene/ObjectNode.cs.meta

41
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Scene/ObjectNode.cs


using UnityEditor.Graphing;
using UnityEngine;
namespace UnityEditor.ShaderGraph
{
[Title("Input/Scene/Object")]
public class ObjectNode : AbstractMaterialNode
{
const string kOutputSlotName = "Position";
const string kOutputSlot1Name = "Scale";
public const int OutputSlotId = 0;
public const int OutputSlot1Id = 1;
public ObjectNode()
{
name = "Object";
UpdateNodeAfterDeserialization();
}
public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new Vector3MaterialSlot(OutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, Vector3.zero));
AddSlot(new Vector3MaterialSlot(OutputSlot1Id, kOutputSlot1Name, kOutputSlot1Name, SlotType.Output, Vector3.zero));
RemoveSlotsNameNotMatching(new[] { OutputSlotId, OutputSlot1Id });
}
public override string GetVariableNameForSlot(int slotId)
{
switch (slotId)
{
case OutputSlot1Id:
return @"float3(length(float3(unity_ObjectToWorld[0].x, unity_ObjectToWorld[1].x, unity_ObjectToWorld[2].x)),
length(float3(unity_ObjectToWorld[0].y, unity_ObjectToWorld[1].y, unity_ObjectToWorld[2].y)),
length(float3(unity_ObjectToWorld[0].z, unity_ObjectToWorld[1].z, unity_ObjectToWorld[2].z)))";
default:
return "unity_ObjectToWorld._m03_m13_m23";
}
}
}
}

8
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Scene/ObjectNode.cs.meta


fileFormatVersion: 2
guid: 081b8aed5e33ba1418a6a80f7693b9b4
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
正在加载...
取消
保存