Tim Cooper
7 年前
当前提交
f6fa3513
共有 31 个文件被更改,包括 642 次插入 和 638 次删除
-
6MaterialGraphProject/Assets/NewNodes/Editor/ToggleNodePresenter.cs
-
19MaterialGraphProject/Assets/NewNodes/Keep/ConstantsNode.cs
-
4MaterialGraphProject/Assets/NewNodes/Kill/ToggleNode.cs
-
14MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/Presenters/GraphInspectorPresenter.cs
-
96MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/Views/GraphInspectorView.cs
-
2MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/NodeInspectors/PropertyNodeInspector.cs
-
5MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/GraphEditorPresenter.cs
-
10MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/MaterialGraphPresenter.cs
-
1MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Nodes/ColorNodePresenter.cs
-
6MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Nodes/CubemapNodePresenter.cs
-
4MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Nodes/TextureAssetNodePresenter.cs
-
4MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Nodes/TextureLODNodePresenter.cs
-
3MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Nodes/TextureSamplerNodePresenter.cs
-
19MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/PropertyNodePresenter.cs
-
4MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/IntegrationTests/PropertyNodeTests.cs
-
10MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/UnitTests/PropertyNodeTests.cs
-
293MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Graphs/AbstractMaterialGraph.cs
-
38MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/ColorNode.cs
-
4MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Texture/CubemapNode.cs
-
6MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Texture/TextureLODNode.cs
-
53MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Vector/Vector1Node.cs
-
47MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Vector/Vector2Node.cs
-
47MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Vector/Vector3Node.cs
-
43MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Vector/Vector4Node.cs
-
161MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/PropertyNode.cs
-
12MaterialGraphProject/Assets/NewNodes/Keep/Texture2DNode.cs.meta
-
137MaterialGraphProject/Assets/NewNodes/Keep/Texture2DNode.cs
-
12MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/SceneData/MotionVectorTextureNode.cs.meta
-
12MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/SceneData/DepthTextureNode.cs.meta
-
104MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/SceneData/DepthTextureNode.cs
-
104MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/SceneData/MotionVectorTextureNode.cs
|
|||
using System.Collections.Generic; |
|||
using System; |
|||
using System.Linq; |
|||
public abstract class PropertyNode : AbstractMaterialNode |
|||
[Title("Property Node")] |
|||
public class PropertyNode : AbstractMaterialNode |
|||
public enum ExposedState |
|||
{ |
|||
Exposed, |
|||
NotExposed |
|||
} |
|||
private Guid m_PropertyGuid; |
|||
private string m_Description = string.Empty; |
|||
private string m_PropertyGuidSerialized; |
|||
|
|||
public const int OutputSlotId = 0; |
|||
|
|||
public const int ROutputSlotId = 1; |
|||
public const int GOutputSlotId = 2; |
|||
public const int BOutputSlotId = 3; |
|||
public const int AOutputSlotId = 4; |
|||
public const int TOutputSlotId = 5; |
|||
[SerializeField] |
|||
private ExposedState m_Exposed = ExposedState.NotExposed; |
|||
public PropertyNode() |
|||
{ |
|||
name = "Property"; |
|||
UpdateNodeAfterDeserialization(); |
|||
} |
|||
public ExposedState exposedState |
|||
private void UpdateNode() |
|||
get |
|||
var graph = owner as AbstractMaterialGraph; |
|||
var property = graph.properties.FirstOrDefault(x => x.guid == propertyGuid); |
|||
if (property == null) |
|||
return; |
|||
|
|||
if (property is FloatShaderProperty) |
|||
{ |
|||
AddSlot(new MaterialSlot(OutputSlotId, "float", "float", SlotType.Output, SlotValueType.Vector1, Vector4.zero)); |
|||
RemoveSlotsNameNotMatching(new[] { OutputSlotId }); |
|||
} |
|||
else if (property is Vector2ShaderProperty) |
|||
if (owner is SubGraph) |
|||
return ExposedState.NotExposed; |
|||
|
|||
return m_Exposed; |
|||
AddSlot(new MaterialSlot(OutputSlotId, "V2", "V2", SlotType.Output, SlotValueType.Vector2, Vector4.zero)); |
|||
RemoveSlotsNameNotMatching(new[] { OutputSlotId }); |
|||
set |
|||
else if (property is Vector3ShaderProperty) |
|||
if (m_Exposed == value) |
|||
return; |
|||
|
|||
m_Exposed = value; |
|||
AddSlot(new MaterialSlot(OutputSlotId, "V3", "V3", SlotType.Output, SlotValueType.Vector3, Vector4.zero)); |
|||
RemoveSlotsNameNotMatching(new[] { OutputSlotId }); |
|||
} |
|||
|
|||
public string description |
|||
{ |
|||
get |
|||
else if (property is Vector4ShaderProperty) |
|||
return string.IsNullOrEmpty(m_Description) ? name : m_Description; |
|||
AddSlot(new MaterialSlot(OutputSlotId, "V4", "V4", SlotType.Output, SlotValueType.Vector4, Vector4.zero)); |
|||
RemoveSlotsNameNotMatching(new[] { OutputSlotId }); |
|||
} |
|||
else if (property is ColorShaderProperty) |
|||
{ |
|||
AddSlot(new MaterialSlot(OutputSlotId, "Color", "Color", SlotType.Output, SlotValueType.Vector4, Vector4.zero)); |
|||
RemoveSlotsNameNotMatching(new[] { OutputSlotId }); |
|||
} |
|||
else if (property is TextureShaderProperty) |
|||
{ |
|||
AddSlot(new MaterialSlot(OutputSlotId, "RGBA", "RGBA", SlotType.Output, SlotValueType.Vector4, Vector4.zero)); |
|||
AddSlot(new MaterialSlot(ROutputSlotId, "R", "R", SlotType.Output, SlotValueType.Vector1, Vector4.zero)); |
|||
AddSlot(new MaterialSlot(GOutputSlotId, "G", "G", SlotType.Output, SlotValueType.Vector1, Vector4.zero)); |
|||
AddSlot(new MaterialSlot(BOutputSlotId, "B", "B", SlotType.Output, SlotValueType.Vector1, Vector4.zero)); |
|||
AddSlot(new MaterialSlot(AOutputSlotId, "A", "A", SlotType.Output, SlotValueType.Vector1, Vector4.zero)); |
|||
AddSlot(new MaterialSlot(TOutputSlotId, "T", "T", SlotType.Output, SlotValueType.Texture2D, Vector4.zero)); |
|||
RemoveSlotsNameNotMatching(new[] { OutputSlotId, ROutputSlotId, GOutputSlotId, BOutputSlotId, AOutputSlotId, TOutputSlotId}); |
|||
set { m_Description = value; } |
|||
public string propertyName |
|||
public Guid propertyGuid |
|||
get |
|||
get { return m_PropertyGuid; } |
|||
set |
|||
return string.Format("{0}_{1}_Uniform", name, GetVariableNameForNode()); |
|||
} |
|||
} |
|||
if (m_PropertyGuid == value) |
|||
return; |
|||
public abstract PropertyType propertyType { get; } |
|||
var graph = owner as AbstractMaterialGraph; |
|||
var property = graph.properties.FirstOrDefault(x => x.guid == value); |
|||
if (property == null) |
|||
return; |
|||
m_PropertyGuid = value; |
|||
public abstract PreviewProperty GetPreviewProperty(); |
|||
UpdateNode(); |
|||
public override string GetVariableNameForSlot(int slotId) |
|||
if (onModified != null) |
|||
{ |
|||
onModified(this, ModificationScope.Topological); |
|||
} |
|||
} |
|||
} |
|||
|
|||
public sealed override void UpdateNodeAfterDeserialization() |
|||
return propertyName; |
|||
base.UpdateNodeAfterDeserialization(); |
|||
public override void CollectPreviewMaterialProperties(List<PreviewProperty> properties) |
|||
public override string GetVariableNameForSlot(int slotId) |
|||
base.CollectPreviewMaterialProperties(properties); |
|||
properties.Add(GetPreviewProperty()); |
|||
var graph = owner as AbstractMaterialGraph; |
|||
var property = graph.properties.FirstOrDefault(x => x.guid == guid); |
|||
return property.name; |
|||
if (exposedState == ExposedState.NotExposed) |
|||
return false; |
|||
var graph = owner as AbstractMaterialGraph; |
|||
var propNodes = owner.GetNodes<PropertyNode>(); |
|||
foreach (var n in propNodes) |
|||
{ |
|||
if (n == this || n.exposedState == ExposedState.NotExposed) |
|||
continue; |
|||
if (!graph.properties.Any(x => x.guid == guid)) |
|||
return true; |
|||
if (n.propertyName == propertyName) |
|||
{ |
|||
return true; |
|||
} |
|||
} |
|||
/* |
|||
public override float GetNodeUIHeight(float width) |
|||
public override void OnBeforeSerialize() |
|||
return 2 * EditorGUIUtility.singleLineHeight; |
|||
base.OnBeforeSerialize(); |
|||
m_PropertyGuidSerialized = m_PropertyGuid.ToString(); |
|||
public override bool OnGUI() |
|||
public override void OnAfterDeserialize() |
|||
EditorGUI.BeginChangeCheck(); |
|||
m_Exposed = EditorGUILayout.Toggle("Exposed Property", m_Exposed); |
|||
if (m_Exposed) |
|||
m_PropertyName = EditorGUILayout.DelayedTextField("Property Name", m_PropertyName); |
|||
|
|||
var modified = EditorGUI.EndChangeCheck(); |
|||
if (modified) |
|||
{ |
|||
owner.ValidateGraph(); |
|||
} |
|||
|
|||
if (m_Exposed) |
|||
m_Description = EditorGUILayout.TextField("Description", m_Description); |
|||
base.OnAfterDeserialize(); |
|||
if (!string.IsNullOrEmpty(m_PropertyGuidSerialized)) |
|||
m_PropertyGuid = new Guid(m_PropertyGuidSerialized); |
|||
} |
|||
modified |= base.OnGUI(); |
|||
return modified; |
|||
}*/ |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 9def76d530f56804b9f696a9b36eccfa |
|||
timeCreated: 1500545522 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
#if UNITY_EDITOR
|
|||
using UnityEditor; |
|||
#endif
|
|||
using UnityEngine.Graphing; |
|||
|
|||
namespace UnityEngine.MaterialGraph |
|||
{ |
|||
[Title("Input/Texture/Texture Asset")] |
|||
public class Texture2DNode : PropertyNode |
|||
{ |
|||
protected const string textureName = "Texture"; |
|||
|
|||
public const int textureID = 0; |
|||
|
|||
[SerializeField] |
|||
private string m_SerializedTexture; |
|||
|
|||
[SerializeField] |
|||
private TextureType m_TextureType; |
|||
|
|||
[Serializable] |
|||
private class TextureHelper |
|||
{ |
|||
public Texture texture; |
|||
} |
|||
|
|||
public override bool hasPreview { get { return false; } } |
|||
|
|||
#if UNITY_EDITOR
|
|||
public Texture defaultTexture |
|||
{ |
|||
get |
|||
{ |
|||
if (string.IsNullOrEmpty(m_SerializedTexture)) |
|||
return null; |
|||
|
|||
var tex = new TextureHelper(); |
|||
EditorJsonUtility.FromJsonOverwrite(m_SerializedTexture, tex); |
|||
return tex.texture; |
|||
} |
|||
set |
|||
{ |
|||
if (defaultTexture == value) |
|||
return; |
|||
|
|||
var tex = new TextureHelper(); |
|||
tex.texture = value; |
|||
m_SerializedTexture = EditorJsonUtility.ToJson(tex, true); |
|||
|
|||
if (onModified != null) |
|||
{ |
|||
onModified(this, ModificationScope.Node); |
|||
} |
|||
} |
|||
} |
|||
#else
|
|||
public Texture defaultTexture {get; set; } |
|||
#endif
|
|||
|
|||
public TextureType textureType |
|||
{ |
|||
get { return m_TextureType; } |
|||
set |
|||
{ |
|||
if (m_TextureType == value) |
|||
return; |
|||
|
|||
|
|||
m_TextureType = value; |
|||
if (onModified != null) |
|||
{ |
|||
onModified(this, ModificationScope.Graph); |
|||
} |
|||
} |
|||
} |
|||
|
|||
public Texture2DNode() |
|||
{ |
|||
name = "Texture2D"; |
|||
UpdateNodeAfterDeserialization(); |
|||
} |
|||
|
|||
public sealed override void UpdateNodeAfterDeserialization() |
|||
{ |
|||
AddSlot(new MaterialSlot(textureID, textureName, textureName, SlotType.Output, SlotValueType.Texture2D, Vector4.zero)); |
|||
RemoveSlotsNameNotMatching(validSlots); |
|||
} |
|||
|
|||
protected int[] validSlots |
|||
{ |
|||
get { return new[] { textureID }; } |
|||
} |
|||
|
|||
public override void CollectPreviewMaterialProperties(List<PreviewProperty> properties) |
|||
{ |
|||
properties.Add(GetPreviewProperty()); |
|||
} |
|||
|
|||
// Properties
|
|||
public override void GeneratePropertyBlock(PropertyGenerator visitor, GenerationMode generationMode) |
|||
{ |
|||
visitor.AddShaderProperty( |
|||
new TexturePropertyChunk( |
|||
propertyName, |
|||
description, |
|||
defaultTexture, m_TextureType, |
|||
PropertyChunk.HideState.Visible, |
|||
exposedState == ExposedState.Exposed ? |
|||
TexturePropertyChunk.ModifiableState.Modifiable |
|||
: TexturePropertyChunk.ModifiableState.NonModifiable)); |
|||
} |
|||
|
|||
public override void GeneratePropertyUsages(ShaderGenerator visitor, GenerationMode generationMode) |
|||
{ |
|||
var slotTexture2D = FindOutputSlot<MaterialSlot>(0); |
|||
if (slotTexture2D != null) |
|||
{ |
|||
visitor.AddShaderChunk("UNITY_DECLARE_TEX2D(" + propertyName + ");", true); |
|||
} |
|||
} |
|||
|
|||
public override PreviewProperty GetPreviewProperty() |
|||
{ |
|||
return new PreviewProperty |
|||
{ |
|||
m_Name = propertyName, |
|||
m_PropType = PropertyType.Texture, |
|||
m_Texture = defaultTexture |
|||
}; |
|||
} |
|||
|
|||
public override PropertyType propertyType { get { return PropertyType.Texture; } } |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: c7cc7e5395a37b6449bf1835a04565f8 |
|||
timeCreated: 1490975413 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: cb01a07941c890648943fc712415a101 |
|||
timeCreated: 1490975413 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
#if UNITY_EDITOR
|
|||
using UnityEditor; |
|||
#endif
|
|||
using UnityEngine.Graphing; |
|||
|
|||
namespace UnityEngine.MaterialGraph |
|||
{ |
|||
[Title("Input/Scene Data/Depth Texture")] |
|||
public class DepthTextureNode : PropertyNode, IGeneratesBodyCode, IMayRequireMeshUV |
|||
{ |
|||
protected const string kUVSlotName = "UV"; |
|||
protected const string kOutputSlotName = "Output"; |
|||
|
|||
public const int UvSlotId = 0; |
|||
public const int OutputSlotId = 1; |
|||
|
|||
public override bool hasPreview { get { return true; } } |
|||
|
|||
public Texture defaultTexture { get; set; } |
|||
|
|||
public DepthTextureNode() |
|||
{ |
|||
name = "DepthTexture"; |
|||
UpdateNodeAfterDeserialization(); |
|||
} |
|||
|
|||
public sealed override void UpdateNodeAfterDeserialization() |
|||
{ |
|||
AddSlot(new MaterialSlot(OutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, SlotValueType.Vector4, Vector4.zero)); |
|||
AddSlot(new MaterialSlot(UvSlotId, kUVSlotName, kUVSlotName, SlotType.Input, SlotValueType.Vector2, Vector4.zero)); |
|||
RemoveSlotsNameNotMatching(validSlots); |
|||
} |
|||
|
|||
protected int[] validSlots |
|||
{ |
|||
get { return new[] { OutputSlotId, UvSlotId }; } |
|||
} |
|||
|
|||
public virtual void GenerateNodeCode(ShaderGenerator visitor, GenerationMode generationMode) |
|||
{ |
|||
var uvSlot = FindInputSlot<MaterialSlot>(UvSlotId); |
|||
if (uvSlot == null) |
|||
return; |
|||
|
|||
var uvName = string.Format("{0}.xy", UVChannel.uv0.GetUVName()); |
|||
var edges = owner.GetEdges(uvSlot.slotReference).ToList(); |
|||
|
|||
if (edges.Count > 0) |
|||
{ |
|||
var edge = edges[0]; |
|||
var fromNode = owner.GetNodeFromGuid<AbstractMaterialNode>(edge.outputSlot.nodeGuid); |
|||
uvName = ShaderGenerator.AdaptNodeOutput(fromNode, edge.outputSlot.slotId, ConcreteSlotValueType.Vector2, true); |
|||
} |
|||
|
|||
string body = "tex2D (_CameraDepthTexture, " + uvName + ")"; |
|||
visitor.AddShaderChunk(precision + "4 " + GetVariableNameForNode() + " = " + body + ";", true); |
|||
} |
|||
|
|||
public override void CollectPreviewMaterialProperties(List<PreviewProperty> properties) |
|||
{ |
|||
properties.Add(GetPreviewProperty()); |
|||
} |
|||
|
|||
public override void GeneratePropertyUsages(ShaderGenerator visitor, GenerationMode generationMode) |
|||
{ |
|||
visitor.AddShaderChunk("sampler2D _CameraDepthTexture;", true); |
|||
} |
|||
|
|||
public override PreviewProperty GetPreviewProperty() |
|||
{ |
|||
return new PreviewProperty |
|||
{ |
|||
m_Name = propertyName, |
|||
m_PropType = PropertyType.Texture, |
|||
m_Texture = defaultTexture |
|||
}; |
|||
} |
|||
|
|||
public override string GetVariableNameForSlot(int slotId) |
|||
{ |
|||
return GetVariableNameForNode(); |
|||
} |
|||
|
|||
public override PropertyType propertyType { get { return PropertyType.Texture; } } |
|||
|
|||
public bool RequiresMeshUV(UVChannel channel) |
|||
{ |
|||
if (channel != UVChannel.uv0) |
|||
{ |
|||
return false; |
|||
} |
|||
|
|||
var uvSlot = FindInputSlot<MaterialSlot>(UvSlotId); |
|||
if (uvSlot == null) |
|||
return true; |
|||
|
|||
var edges = owner.GetEdges(uvSlot.slotReference).ToList(); |
|||
return edges.Count == 0; |
|||
} |
|||
} |
|||
} |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
#if UNITY_EDITOR
|
|||
using UnityEditor; |
|||
#endif
|
|||
using UnityEngine.Graphing; |
|||
|
|||
namespace UnityEngine.MaterialGraph |
|||
{ |
|||
[Title("Input/Scene Data/Motion Vector Texture")] |
|||
public class MotionVectorTextureNode : PropertyNode, IGeneratesBodyCode, IMayRequireMeshUV |
|||
{ |
|||
protected const string kUVSlotName = "UV"; |
|||
protected const string kOutputSlotName = "Output"; |
|||
|
|||
public const int UvSlotId = 0; |
|||
public const int OutputSlotId = 1; |
|||
|
|||
public override bool hasPreview { get { return true; } } |
|||
|
|||
public Texture defaultTexture { get; set; } |
|||
|
|||
public MotionVectorTextureNode() |
|||
{ |
|||
name = "MotionVectorTexture"; |
|||
UpdateNodeAfterDeserialization(); |
|||
} |
|||
|
|||
public sealed override void UpdateNodeAfterDeserialization() |
|||
{ |
|||
AddSlot(new MaterialSlot(OutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, SlotValueType.Vector4, Vector4.zero)); |
|||
AddSlot(new MaterialSlot(UvSlotId, kUVSlotName, kUVSlotName, SlotType.Input, SlotValueType.Vector2, Vector4.zero)); |
|||
RemoveSlotsNameNotMatching(validSlots); |
|||
} |
|||
|
|||
protected int[] validSlots |
|||
{ |
|||
get { return new[] { OutputSlotId, UvSlotId }; } |
|||
} |
|||
|
|||
public virtual void GenerateNodeCode(ShaderGenerator visitor, GenerationMode generationMode) |
|||
{ |
|||
var uvSlot = FindInputSlot<MaterialSlot>(UvSlotId); |
|||
if (uvSlot == null) |
|||
return; |
|||
|
|||
var uvName = string.Format("{0}.xy", UVChannel.uv0.GetUVName()); |
|||
var edges = owner.GetEdges(uvSlot.slotReference).ToList(); |
|||
|
|||
if (edges.Count > 0) |
|||
{ |
|||
var edge = edges[0]; |
|||
var fromNode = owner.GetNodeFromGuid<AbstractMaterialNode>(edge.outputSlot.nodeGuid); |
|||
uvName = ShaderGenerator.AdaptNodeOutput(fromNode, edge.outputSlot.slotId, ConcreteSlotValueType.Vector2, true); |
|||
} |
|||
|
|||
string body = "tex2D (_CameraMotionVectorTexture, " + uvName + ")"; |
|||
visitor.AddShaderChunk(precision + "4 " + GetVariableNameForNode() + " = " + body + ";", true); |
|||
} |
|||
|
|||
public override void CollectPreviewMaterialProperties(List<PreviewProperty> properties) |
|||
{ |
|||
properties.Add(GetPreviewProperty()); |
|||
} |
|||
|
|||
public override void GeneratePropertyUsages(ShaderGenerator visitor, GenerationMode generationMode) |
|||
{ |
|||
visitor.AddShaderChunk("sampler2D _CameraMotionVectorTexture;", true); |
|||
} |
|||
|
|||
public override PreviewProperty GetPreviewProperty() |
|||
{ |
|||
return new PreviewProperty |
|||
{ |
|||
m_Name = propertyName, |
|||
m_PropType = PropertyType.Texture, |
|||
m_Texture = defaultTexture |
|||
}; |
|||
} |
|||
|
|||
public override string GetVariableNameForSlot(int slotId) |
|||
{ |
|||
return GetVariableNameForNode(); |
|||
} |
|||
|
|||
public override PropertyType propertyType { get { return PropertyType.Texture; } } |
|||
|
|||
public bool RequiresMeshUV(UVChannel channel) |
|||
{ |
|||
if (channel != UVChannel.uv0) |
|||
{ |
|||
return false; |
|||
} |
|||
|
|||
var uvSlot = FindInputSlot<MaterialSlot>(UvSlotId); |
|||
if (uvSlot == null) |
|||
return true; |
|||
|
|||
var edges = owner.GetEdges(uvSlot.slotReference).ToList(); |
|||
return edges.Count == 0; |
|||
} |
|||
} |
|||
} |
撰写
预览
正在加载...
取消
保存
Reference in new issue