浏览代码

Improve 'geometry' based nodes so they can do space translations internally.

/main
Tim Cooper 7 年前
当前提交
b2eceafe
共有 24 个文件被更改,包括 307 次插入246 次删除
  1. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/AbstractMaterialGraph.cs
  2. 19
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Interfaces/NeededCoordinateSpace.cs
  3. 25
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/BitangentNode.cs
  4. 18
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/NormalNode.cs
  5. 23
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/PositionNode.cs
  6. 6
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/PositionNode.cs.meta
  7. 23
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/TangentNode.cs
  8. 1
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/VertexColorNode.cs
  9. 23
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/ViewDirectionNode.cs
  10. 235
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Util/ShaderGenerator.cs
  11. 38
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/GeometryNode.cs
  12. 11
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/GeometryNode.cs.meta
  13. 7
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/IMayRequireBitangent.cs
  14. 11
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/IMayRequireBitangent.cs.meta
  15. 7
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/IMayRequirePosition.cs
  16. 11
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/IMayRequirePosition.cs.meta
  17. 7
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/IMayRequireTangent.cs
  18. 11
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/IMayRequireTangent.cs.meta
  19. 7
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/IMayRequireViewDirection.cs
  20. 11
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/IMayRequireViewDirection.cs.meta
  21. 8
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/WorldSpacePositionNode.cs.meta
  22. 49
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/WorldSpacePositionNode.cs
  23. 0
      /MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/TangentNode.cs
  24. 0
      /MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/TangentNode.cs.meta

2
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/AbstractMaterialGraph.cs


fullName = "UnityEngine.MaterialGraph.WorldPosNode",
assemblyName = "Assembly-CSharp"
};
result[worldPosNode] = SerializationHelper.GetTypeSerializableAsString(typeof(WorldSpacePositionNode));
result[worldPosNode] = SerializationHelper.GetTypeSerializableAsString(typeof(PositionNode));
return result;
}

19
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Interfaces/NeededCoordinateSpace.cs


Tangent = 1 << 3
}
public enum CoordinateSpace
public enum CoordinateSpace : int
{
Object,
View,

public static string ToVariableName(this CoordinateSpace space, InterpolatorType type)
{
return string.Format("{0}Space{1}", space, type);
}
public static NeededCoordinateSpace ToNeededCoordinateSpace(this CoordinateSpace space)
{
switch (space)
{
case CoordinateSpace.Object:
return NeededCoordinateSpace.Object;
case CoordinateSpace.View:
return NeededCoordinateSpace.View;
case CoordinateSpace.World:
return NeededCoordinateSpace.World;
case CoordinateSpace.Tangent:
return NeededCoordinateSpace.Tangent;
default:
throw new ArgumentOutOfRangeException("space", space, null);
}
}
}
}

25
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/BitangentNode.cs


namespace UnityEngine.MaterialGraph
{
public interface IMayRequireBitangent
{
NeededCoordinateSpace RequiresBitangent();
}
[Title("Input/Geometry/World Bitangent")]
public class BitangentNode : AbstractMaterialNode, IMayRequireBitangent
[Title("Input/Geometry/Bitangent")]
public class BitangentNode : GeometryNode, IMayRequireBitangent
{
public const int kOutputSlotId = 0;
public const string kOutputSlotName = "Bitangent";

AddSlot(new Vector3MaterialSlot(kOutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, new Vector4(0, 0, 1)));
RemoveSlotsNameNotMatching(new[] { kOutputSlotId });
}
public override bool hasPreview
{
get { return true; }
}
public override PreviewMode previewMode
{
get { return PreviewMode.Preview3D; }
}
return CoordinateSpace.World.ToVariableName(InterpolatorType.BiTangent);
return space.ToVariableName(InterpolatorType.BiTangent);
return NeededCoordinateSpace.World;
return space.ToNeededCoordinateSpace();
}
}
}

18
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/NormalNode.cs


namespace UnityEngine.MaterialGraph
{
[Title("Input/Geometry/World Normal")]
public class NormalNode : AbstractMaterialNode, IMayRequireNormal
[Title("Input/Geometry/Normal")]
public class NormalNode : GeometryNode, IMayRequireNormal
{
public const int kOutputSlotId = 0;
public const string kOutputSlotName = "Normal";

RemoveSlotsNameNotMatching(new[] { kOutputSlotId });
}
public override bool hasPreview
{
get { return true; }
}
public override PreviewMode previewMode
{
get { return PreviewMode.Preview3D; }
}
return CoordinateSpace.World.ToVariableName(InterpolatorType.Normal);
return space.ToVariableName(InterpolatorType.Normal);
return NeededCoordinateSpace.World;
return space.ToNeededCoordinateSpace();
}
}
}

23
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/PositionNode.cs


namespace UnityEngine.MaterialGraph
{
[Title("Input/Geometry/Position")]
public class PositionNode : AbstractMaterialNode
public class PositionNode : GeometryNode, IMayRequirePosition
const string kOutputSlotName = "XYZW";
private const int kOutputSlotId = 0;
public const string kOutputSlotName = "Position";
public const int OutputSlotId = 0;
public PositionNode()
{

public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new Vector4MaterialSlot(OutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, Vector4.zero, ShaderStage.Vertex));
RemoveSlotsNameNotMatching(validSlots);
AddSlot(new Vector3MaterialSlot(
kOutputSlotId,
kOutputSlotName,
kOutputSlotName,
SlotType.Output,
Vector3.zero));
RemoveSlotsNameNotMatching(new[] { kOutputSlotId });
protected int[] validSlots
public override string GetVariableNameForSlot(int slotId)
get { return new[] { OutputSlotId }; }
return space.ToVariableName(InterpolatorType.Position);
public override string GetVariableNameForSlot(int slotId)
public NeededCoordinateSpace RequiresPosition()
return "v.vertex";
return space.ToNeededCoordinateSpace();
}
}
}

6
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/PositionNode.cs.meta


fileFormatVersion: 2
guid: 27fd3b60f289f4242a6142556ed287f1
timeCreated: 1495658351
licenseType: Pro
guid: 137f6921c5ee7ca4dbffb34de10f52f5
MonoImporter:
serializedVersion: 2
defaultReferences: []

assetBundleName:
assetBundleVariant:

23
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/TangentNode.cs


namespace UnityEngine.MaterialGraph
{
public interface IMayRequireTangent
{
NeededCoordinateSpace RequiresTangent();
}
[Title("Input/Geometry/World Tangent")]
public class TangentNode : AbstractMaterialNode, IMayRequireTangent
[Title("Input/Geometry/Tangent")]
public class TangentNode : GeometryNode, IMayRequireTangent
{
public const int kOutputSlotId = 0;
public const string kOutputSlotName = "Tangent";

RemoveSlotsNameNotMatching(new[] { kOutputSlotId });
}
public override bool hasPreview
{
get { return true; }
}
public override PreviewMode previewMode
{
get { return PreviewMode.Preview3D; }
}
return CoordinateSpace.World.ToVariableName(InterpolatorType.Tangent);
return space.ToVariableName(InterpolatorType.Tangent);
return NeededCoordinateSpace.Object;
return space.ToNeededCoordinateSpace();
}
}
}

1
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/VertexColorNode.cs


using System.ComponentModel;
using UnityEngine.Graphing;
namespace UnityEngine.MaterialGraph

23
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/ViewDirectionNode.cs


using System.ComponentModel;
interface IMayRequireViewDirection
{
NeededCoordinateSpace RequiresViewDirection();
}
public class ViewDirectionNode : AbstractMaterialNode, IMayRequireViewDirection
public class ViewDirectionNode : GeometryNode, IMayRequireViewDirection
public override bool hasPreview { get { return true; } }
public override PreviewMode previewMode
{
get { return PreviewMode.Preview3D; }
}
public const string kOutputSlotName = "ViewDirection";
public ViewDirectionNode()
{

{
AddSlot(new Vector3MaterialSlot(
kOutputSlotId,
CoordinateSpace.World.ToVariableName(InterpolatorType.ViewDirection),
CoordinateSpace.World.ToVariableName(InterpolatorType.ViewDirection),
kOutputSlotName,
kOutputSlotName,
SlotType.Output,
Vector4.zero));
RemoveSlotsNameNotMatching(new[] { kOutputSlotId });

{
return CoordinateSpace.World.ToVariableName(InterpolatorType.ViewDirection);
return space.ToVariableName(InterpolatorType.ViewDirection);
return NeededCoordinateSpace.World;
return space.ToNeededCoordinateSpace();
}
}
}

235
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Util/ShaderGenerator.cs


get { return m_ShaderChunks.Count; }
}
public enum InputType
public enum InputType
public static string EmitTransform(string[] matrices, string[] invMatrices, string variable, bool isAffine, bool inverseTranspose)
public struct TransformDesc
{
public TransformDesc(string name)
{
this.name = name;
transpose = false;
}
public TransformDesc(string name, bool transpose)
{
this.name = name;
this.transpose = transpose;
}
public string name;
public bool transpose;
}
static TransformDesc[,][] m_transforms = null;
static TransformDesc[] GetTransformPath(CoordinateSpace from, CoordinateSpace to)
{
if (m_transforms[(int) from, (int) to] != null)
{
return m_transforms[(int) from, (int) to];
}
var distance = new int[4];
var prev = new CoordinateSpace?[4];
var queue = new List<CoordinateSpace>();
foreach (var space in Enum.GetValues(typeof(CoordinateSpace)))
{
distance[(int)space] = int.MaxValue;
prev[(int)space] = null;
queue.Add((CoordinateSpace)space);
}
distance[(int)from] = 0;
List<CoordinateSpace> path = null;
while (queue.Count != 0)
{
queue.Sort((x, y) => distance[(int)x] - distance[(int)y]);
var min = queue[0];
queue.Remove(min);
if (min == to)
{
path = new List<CoordinateSpace>();
while (prev[(int)min] != null)
{
path.Add(min);
min = prev[(int)min].Value;
}
break;
}
if (distance[(int)min] == int.MaxValue)
{
break;
}
foreach (var space in Enum.GetValues(typeof(CoordinateSpace)))
{
int index = (int)space;
if (m_transforms[(int)min, index] != null)
{
var alt = distance[(int)min] + m_transforms[(int)min, index].Length;
if (alt < distance[index])
{
distance[index] = alt;
prev[index] = min;
}
}
}
}
path.Reverse();
var matrixList = new TransformDesc[path.Count];
int idx = 0;
foreach (var node in path)
{
matrixList[idx] = m_transforms[(int)from, (int)node][0];
from = node;
idx++;
}
return matrixList;
}
static void InitTransforms()
{
if (m_transforms == null)
{
m_transforms = new TransformDesc[4, 4][];
m_transforms[(int)CoordinateSpace.Object, (int)CoordinateSpace.Object] = new TransformDesc[] { };
m_transforms[(int)CoordinateSpace.View, (int)CoordinateSpace.View] = new TransformDesc[] { };
m_transforms[(int)CoordinateSpace.World, (int)CoordinateSpace.World] = new TransformDesc[] { };
m_transforms[(int)CoordinateSpace.Tangent, (int)CoordinateSpace.Tangent] = new TransformDesc[] { };
m_transforms[(int)CoordinateSpace.Object, (int)CoordinateSpace.World]
= new TransformDesc[] { new TransformDesc("unity_ObjectToWorld") };
m_transforms[(int)CoordinateSpace.View, (int)CoordinateSpace.World]
= new TransformDesc[] { new TransformDesc("UNITY_MATRIX_I_V") };
m_transforms[(int)CoordinateSpace.World, (int)CoordinateSpace.Object]
= new TransformDesc[] { new TransformDesc("unity_WorldToObject") };
m_transforms[(int)CoordinateSpace.World, (int)CoordinateSpace.View]
= new TransformDesc[] { new TransformDesc("UNITY_MATRIX_V") };
for (var from = CoordinateSpace.Object; from != CoordinateSpace.Tangent; from++)
{
for (var to = CoordinateSpace.Object; to != CoordinateSpace.Tangent; to++)
{
if (m_transforms[(int)from, (int)to] == null)
{
m_transforms[(int)from, (int)to] = GetTransformPath(from, to);
}
}
}
}
for (var k = CoordinateSpace.Object; k != CoordinateSpace.Tangent; k++)
{
m_transforms[(int)CoordinateSpace.Tangent, (int)k] = null;
m_transforms[(int)k, (int)CoordinateSpace.Tangent] = null;
}
}
public static string EmitTransform(TransformDesc[] matrices, TransformDesc[] invMatrices, string variable, bool isAffine, bool inverseTranspose)
var matrix = m;
var matrix = m.name;
if (m.transpose)
inverseTranspose = !inverseTranspose;
variable = inverseTranspose
? string.Format("mul({1},{0})", matrix, variable)
: string.Format("mul({0},{1})", matrix, variable);

public static string EmitTransform(string matrix, string invMatrix, string variable, bool isAffine, bool inverseTranspose)
{
return EmitTransform(new[] { matrix }, new[] { invMatrix }, variable, isAffine, inverseTranspose);
}
public static string ConvertBetweenSpace(
string variable,
CoordinateSpace from,
CoordinateSpace to,
InputType inputType,
CoordinateSpace tangentMatrixSpace = CoordinateSpace.Object)
public static string ConvertBetweenSpace(string variable, CoordinateSpace from, CoordinateSpace to, InputType inputType, CoordinateSpace tangentMatrixSpace = CoordinateSpace.Object)
{
if (from == to)
{

// Ensure that the transform graph is initialized
InitTransforms();
{
inputType = InputType.Vector;
}
m_transforms[(int)CoordinateSpace.Tangent, (int)tangentMatrixSpace] = new[] { new TransformDesc("tangentSpaceTransform") };
m_transforms[(int)tangentMatrixSpace, (int)CoordinateSpace.Tangent] = new[] { new TransformDesc("tangentSpaceTransform", true) };
// if converting from tangent space, reuse the object space code for now
// if converting from tangent space, reuse the underlying space
variable = EmitTransform("tangentSpaceTransform", "transpose(tangentSpaceTransform)", variable, affine, !isNormal);
variable = EmitTransform(
GetTransformPath(CoordinateSpace.Tangent, tangentMatrixSpace),
GetTransformPath(tangentMatrixSpace, CoordinateSpace.Tangent),
variable, affine, !isNormal);
switch (from)
{
case CoordinateSpace.Object:
{
switch (to)
{
case CoordinateSpace.View:
return EmitTransform(new string[] { "unity_ObjectToWorld", "UNITY_MATRIX_V" }
, new string[] { "UNITY_MATRIX_I_V", "unity_WorldToObject" }
, variable, affine, isNormal);
case CoordinateSpace.World:
return EmitTransform("unity_ObjectToWorld", "unity_WorldToObject", variable, affine, isNormal);
case CoordinateSpace.Tangent:
return EmitTransform("tangentSpaceTransform", "transpose(tangentSpaceTransform)", variable, affine, isNormal);
default:
throw new ArgumentOutOfRangeException("from", @from, null);
}
}
case CoordinateSpace.View:
{
switch (to)
{
case CoordinateSpace.Object:
return EmitTransform(new string[] { "UNITY_MATRIX_I_V", "unity_WorldToObject" }
, new string[] { "unity_ObjectToWorld", "UNITY_MATRIX_V" }
, variable, affine, isNormal);
case CoordinateSpace.World:
return EmitTransform("UNITY_MATRIX_I_V", "UNITY_MATRIX_V", variable, affine, isNormal);
case CoordinateSpace.Tangent:
return EmitTransform(new string[] { "UNITY_MATRIX_I_V", "unity_WorldToObject", "tangentSpaceTransform" },
new string[] { "transpose(tangentSpaceTransform)", "unity_ObjectToWorld", "UNITY_MATRIX_V" },
variable, affine, isNormal);
default:
throw new ArgumentOutOfRangeException("from", @from, null);
}
}
case CoordinateSpace.World:
{
switch (to)
{
case CoordinateSpace.Object:
return EmitTransform("unity_WorldToObject", "unity_ObjectToWorld", variable, affine, isNormal);
case CoordinateSpace.View:
return EmitTransform("UNITY_MATRIX_V", "UNITY_MATRIX_I_V", variable, affine, isNormal);
case CoordinateSpace.Tangent:
return EmitTransform(new string[] { "unity_WorldToObject", "tangentSpaceTransform" },
new string[] { "transpose(tangentSpaceTransform)", "unity_ObjectToWorld" },
variable, affine, isNormal);
default:
throw new ArgumentOutOfRangeException("from", @from, null);
}
}
default:
throw new ArgumentOutOfRangeException("from", @from, null);
}
return EmitTransform(GetTransformPath(from, to), GetTransformPath(to, from), variable, affine, isNormal);
}
public static void GenerateSpaceTranslationSurfaceInputs(

string.Format("float{0} {1} = {2};", DimensionToString(dimension),
CoordinateSpace.Tangent.ToVariableName(type),
ConvertBetweenSpace(from.ToVariableName(type), from, CoordinateSpace.Tangent, inputType, from)), false);
}
public static void GenerateCopyToSurfaceInputs(
NeededCoordinateSpace neededSpaces,
ShaderGenerator pixelShader,
string objectSpaceName,
string viewSpaceName,
string worldSpaceName,
string tangentSpaceName)
{
if ((neededSpaces & NeededCoordinateSpace.Object) > 0)
pixelShader.AddShaderChunk(string.Format("surfaceInput.{0} = {0};", objectSpaceName), false);
if ((neededSpaces & NeededCoordinateSpace.World) > 0)
pixelShader.AddShaderChunk(string.Format("surfaceInput.{0} = {0};", worldSpaceName), false);
if ((neededSpaces & NeededCoordinateSpace.View) > 0)
pixelShader.AddShaderChunk(string.Format("surfaceInput.{0} = {0};", viewSpaceName), false);
if ((neededSpaces & NeededCoordinateSpace.Tangent) > 0)
pixelShader.AddShaderChunk(string.Format("surfaceInput.{0} = {0}", tangentSpaceName), false);
}
public static string GetPreviewSubShader(AbstractMaterialNode node, ShaderGraphRequirements shaderGraphRequirements)

38
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/GeometryNode.cs


using UnityEditor.MaterialGraph.Drawing.Controls;
using UnityEngine.Graphing;
namespace UnityEngine.MaterialGraph
{
public abstract class GeometryNode : AbstractMaterialNode
{
[SerializeField]
private CoordinateSpace m_Space = CoordinateSpace.World;
[EnumControl("Space")]
public CoordinateSpace space
{
get { return m_Space; }
set
{
if (m_Space == value)
return;
m_Space = value;
if (onModified != null)
{
onModified(this, ModificationScope.Graph);
}
}
}
public override bool hasPreview
{
get { return true; }
}
public override PreviewMode previewMode
{
get { return PreviewMode.Preview3D; }
}
}
}

11
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/GeometryNode.cs.meta


fileFormatVersion: 2
guid: 2e30171d4f8dfdc44beee8926ed3a83e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

7
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/IMayRequireBitangent.cs


namespace UnityEngine.MaterialGraph
{
public interface IMayRequireBitangent
{
NeededCoordinateSpace RequiresBitangent();
}
}

11
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/IMayRequireBitangent.cs.meta


fileFormatVersion: 2
guid: 2d413641b2ef00944932ea717573480f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

7
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/IMayRequirePosition.cs


namespace UnityEngine.MaterialGraph
{
interface IMayRequirePosition
{
NeededCoordinateSpace RequiresPosition();
}
}

11
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/IMayRequirePosition.cs.meta


fileFormatVersion: 2
guid: 5ab44fbceb0a1074899755c19bcd75cd
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

7
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/IMayRequireTangent.cs


namespace UnityEngine.MaterialGraph
{
public interface IMayRequireTangent
{
NeededCoordinateSpace RequiresTangent();
}
}

11
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/IMayRequireTangent.cs.meta


fileFormatVersion: 2
guid: ab1ebec1bc4dee54c9b0df228d5f6609
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

7
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/IMayRequireViewDirection.cs


namespace UnityEngine.MaterialGraph
{
interface IMayRequireViewDirection
{
NeededCoordinateSpace RequiresViewDirection();
}
}

11
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/IMayRequireViewDirection.cs.meta


fileFormatVersion: 2
guid: 8d9d2a94c350c0d4791c2220a26a54b0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

8
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/WorldSpacePositionNode.cs.meta


fileFormatVersion: 2
guid: 137f6921c5ee7ca4dbffb34de10f52f5
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

49
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/WorldSpacePositionNode.cs


using UnityEngine.Graphing;
namespace UnityEngine.MaterialGraph
{
interface IMayRequirePosition
{
NeededCoordinateSpace RequiresPosition();
}
[Title("Input/Geometry/World Space Position")]
public class WorldSpacePositionNode : AbstractMaterialNode, IMayRequirePosition
{
private const int kOutputSlotId = 0;
public override bool hasPreview { get { return true; } }
public override PreviewMode previewMode
{
get { return PreviewMode.Preview3D; }
}
public WorldSpacePositionNode()
{
name = "Position";
UpdateNodeAfterDeserialization();
}
public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new Vector3MaterialSlot(
kOutputSlotId,
CoordinateSpace.World.ToVariableName(InterpolatorType.Position),
CoordinateSpace.World.ToVariableName(InterpolatorType.Position),
SlotType.Output,
Vector3.zero));
RemoveSlotsNameNotMatching(new[] { kOutputSlotId });
}
public override string GetVariableNameForSlot(int slotId)
{
return CoordinateSpace.World.ToVariableName(InterpolatorType.Position);
}
public NeededCoordinateSpace RequiresPosition()
{
return NeededCoordinateSpace.World;
}
}
}

/MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/WorldSpaceTangentNode.cs → /MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/TangentNode.cs

/MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/WorldSpaceTangentNode.cs.meta → /MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/TangentNode.cs.meta

正在加载...
取消
保存