GitHub
7 年前
当前提交
5f6271d2
共有 135 个文件被更改,包括 1999 次插入 和 870 次删除
-
6MaterialGraphProject/Assets/NewNodes/Editor/ToggleNodePresenter.cs
-
19MaterialGraphProject/Assets/NewNodes/Keep/ConstantsNode.cs
-
9MaterialGraphProject/Assets/NewNodes/Keep/HeightToNormalNode.cs
-
2MaterialGraphProject/Assets/NewNodes/Keep/LightProbeNode.cs
-
10MaterialGraphProject/Assets/NewNodes/Keep/ParallaxNode.cs
-
4MaterialGraphProject/Assets/NewNodes/Keep/ReflectionProbeNode.cs
-
58MaterialGraphProject/Assets/NewNodes/Keep/SamplerStateNode.cs
-
6MaterialGraphProject/Assets/NewNodes/Keep/TangentToWorldNode.cs
-
12MaterialGraphProject/Assets/NewNodes/Keep/TransformNode.cs
-
6MaterialGraphProject/Assets/NewNodes/Kill/MultiLayerParallaxNode.cs
-
6MaterialGraphProject/Assets/NewNodes/Kill/POMNode.cs
-
2MaterialGraphProject/Assets/NewNodes/Kill/SphericalIndentationNode.cs
-
4MaterialGraphProject/Assets/NewNodes/Kill/ToggleNode.cs
-
2MaterialGraphProject/Assets/UnityShaderEditor/Editor/AssetCallbacks/CreateShaderGraph.cs
-
59MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/AbstractMaterialGraphEditWindow.cs
-
24MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/GraphInspectorPresenter.cs
-
15MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/GraphInspectorPresenter.cs.meta
-
122MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/GraphInspectorView.cs
-
4MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/SurfaceMasterNodeEditorView.cs
-
2MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/NodeInspectors/PropertyNodeInspector.cs
-
4MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/NodeInspectors/SurfaceMasterNodeInspector.cs
-
7MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/GraphEditorPresenter.cs
-
12MaterialGraphProject/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
-
32MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Nodes/MasterNodePresenter.cs
-
10MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Nodes/SamplerStateNodePresenter.cs
-
31MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Nodes/SurfaceMasterNodePresenter.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
-
5MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Nodes/Vector1NodePresenter.cs
-
19MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/PropertyNodePresenter.cs
-
26MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/PreviewSystem.cs
-
9MaterialGraphProject/Assets/UnityShaderEditor/Editor/Importers/ShaderGraphImporter.cs
-
4MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/IntegrationTests/PropertyNodeTests.cs
-
6MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/IntegrationTests/ShaderGenerationTest.cs
-
4MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/UnitTests/AbstractMaterialGraphTests.cs
-
4MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/UnitTests/MaterialNodeTests.cs
-
8MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/UnitTests/MaterialSlotTests.cs
-
4MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/UnitTests/PixelShaderNodeTests.cs
-
4MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/UnitTests/PropertyChunkTests.cs
-
18MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/UnitTests/PropertyGeneratorTests.cs
-
10MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/UnitTests/PropertyNodeTests.cs
-
353MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Graphs/AbstractMaterialGraph.cs
-
51MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Graphs/MaterialGraph.cs
-
55MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Graphs/MaterialSlot.cs
-
5MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Interfaces/IGenerateProperties.cs
-
4MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Interfaces/IMasterNode.cs
-
2MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Interfaces/IMayRequireNormal.cs
-
14MaterialGraphProject/Assets/UnityShaderEditor/Runtime/LightweightPipeline/AbstractLightweightPBRMasterNode.cs
-
8MaterialGraphProject/Assets/UnityShaderEditor/Runtime/LightweightPipeline/LightweightFastBlinnMasterNode.cs
-
4MaterialGraphProject/Assets/UnityShaderEditor/Runtime/LightweightPipeline/LightweightMetallicMasterNode.cs
-
4MaterialGraphProject/Assets/UnityShaderEditor/Runtime/LightweightPipeline/LightweightSpecularMasterNode.cs
-
10MaterialGraphProject/Assets/UnityShaderEditor/Runtime/LightweightPipeline/LightweightUnlitMasterNode.cs
-
16MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/AbstractMaterialNode.cs
-
156MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/HLSLNode.cs
-
45MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/ColorNode.cs
-
8MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Geometry/WorldSpaceBitangentNode.cs
-
12MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Geometry/WorldSpacePositionNode.cs
-
14MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Geometry/WorldSpaceTangentNode.cs
-
2MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Matrix/Matrix2Node.cs
-
4MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Texture/CubemapNode.cs
-
6MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Texture/TextureLODNode.cs
-
74MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Vector/Vector1Node.cs
-
52MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Vector/Vector2Node.cs
-
53MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Vector/Vector3Node.cs
-
48MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Vector/Vector4Node.cs
-
245MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/PropertyNode.cs
-
13MaterialGraphProject/Assets/UnityShaderEditor/Runtime/SubGraph/SubGraph.cs
-
41MaterialGraphProject/Assets/UnityShaderEditor/Runtime/SubGraph/SubGraphInputNode.cs
-
76MaterialGraphProject/Assets/UnityShaderEditor/Runtime/SubGraph/SubGraphNode.cs
-
16MaterialGraphProject/Assets/UnityShaderEditor/Runtime/SurfaceModel/AbstractSurfaceMasterNode.cs
-
16MaterialGraphProject/Assets/UnityShaderEditor/Runtime/SurfaceModel/ExportTextureMasterNode.cs
-
4MaterialGraphProject/Assets/UnityShaderEditor/Runtime/SurfaceModel/MetallicMasterNode.cs
-
4MaterialGraphProject/Assets/UnityShaderEditor/Runtime/SurfaceModel/SpecularMasterNode.cs
-
4MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Util/CubemapPropertyChunk.cs
-
322MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Util/ShaderGenerator.cs
-
10MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Util/TextureType.cs
-
87MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Graphs/AbstractShaderProperty.cs
-
3MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Graphs/AbstractShaderProperty.cs.meta
-
67MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Graphs/ColorShaderProperty.cs
-
3MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Graphs/ColorShaderProperty.cs.meta
-
54MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Graphs/FloatShaderProperty.cs
-
3MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Graphs/FloatShaderProperty.cs.meta
-
17MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Graphs/IShaderProperty.cs
-
3MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Graphs/IShaderProperty.cs.meta
-
34MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Graphs/SamplerStateShaderProperty.cs
-
3MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Graphs/SamplerStateShaderProperty.cs.meta
-
44MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Graphs/SerializableTexture.cs
-
3MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Graphs/SerializableTexture.cs.meta
-
25MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Graphs/ShaderGraphRequirements.cs
-
3MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Graphs/ShaderGraphRequirements.cs.meta
-
45MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Graphs/TextureSamplerState.cs
-
3MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Graphs/TextureSamplerState.cs.meta
-
61MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Graphs/TextureShaderProperty.cs
-
3MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Graphs/TextureShaderProperty.cs.meta
-
24MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Graphs/Vector2ShaderProperty.cs
-
3MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Graphs/Vector2ShaderProperty.cs.meta
-
23MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Graphs/Vector3ShaderProperty.cs
|
|||
fileFormatVersion: 2 |
|||
guid: 215d826e4a644dc0bde2fa9ba68f4096 |
|||
timeCreated: 1502956093 |
|||
fileFormatVersion: 2 |
|||
guid: d8c67032914554203be73439532c83b8 |
|||
timeCreated: 1502956093 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Collections.Generic; |
|||
|
|||
void GeneratePropertyBlock(PropertyGenerator visitor, GenerationMode generationMode); |
|||
void GeneratePropertyUsages(ShaderGenerator visitor, GenerationMode generationMode); |
|||
void CollectShaderProperties(PropertyCollector properties, GenerationMode generationMode); |
|||
} |
|||
} |
|
|||
using System.Collections.Generic; |
|||
using System; |
|||
using System.Linq; |
|||
public abstract class PropertyNode : AbstractMaterialNode |
|||
[Title("Property Node")] |
|||
public class PropertyNode : AbstractMaterialNode, IGeneratesBodyCode, IMayRequireMeshUV |
|||
public enum ExposedState |
|||
private Guid m_PropertyGuid; |
|||
|
|||
[SerializeField] 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; |
|||
|
|||
public const int UVInput = 6; |
|||
|
|||
public PropertyNode() |
|||
Exposed, |
|||
NotExposed |
|||
name = "Property"; |
|||
UpdateNodeAfterDeserialization(); |
|||
[SerializeField] |
|||
private string m_Description = string.Empty; |
|||
private void UpdateNode() |
|||
{ |
|||
var graph = owner as AbstractMaterialGraph; |
|||
var property = graph.properties.FirstOrDefault(x => x.guid == propertyGuid); |
|||
if (property == null) |
|||
return; |
|||
[SerializeField] |
|||
private ExposedState m_Exposed = ExposedState.NotExposed; |
|||
if (property is FloatShaderProperty) |
|||
{ |
|||
AddSlot(new MaterialSlot(OutputSlotId, "float", "float", SlotType.Output, SlotValueType.Vector1, Vector4.zero)); |
|||
RemoveSlotsNameNotMatching(new[] {OutputSlotId}); |
|||
} |
|||
else if (property is Vector2ShaderProperty) |
|||
{ |
|||
AddSlot(new MaterialSlot(OutputSlotId, "V2", "V2", SlotType.Output, SlotValueType.Vector2, Vector4.zero)); |
|||
RemoveSlotsNameNotMatching(new[] {OutputSlotId}); |
|||
} |
|||
else if (property is Vector3ShaderProperty) |
|||
{ |
|||
AddSlot(new MaterialSlot(OutputSlotId, "V3", "V3", SlotType.Output, SlotValueType.Vector3, Vector4.zero)); |
|||
RemoveSlotsNameNotMatching(new[] {OutputSlotId}); |
|||
} |
|||
else if (property is Vector4ShaderProperty) |
|||
{ |
|||
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)); |
|||
AddSlot(new MaterialSlot(UVInput, "UV", "UV", SlotType.Input, SlotValueType.Vector2, Vector4.zero)); |
|||
RemoveSlotsNameNotMatching(new[] {OutputSlotId, ROutputSlotId, GOutputSlotId, BOutputSlotId, AOutputSlotId, TOutputSlotId,UVInput}); |
|||
} |
|||
} |
|||
public ExposedState exposedState |
|||
public void GenerateNodeCode(ShaderGenerator visitor, GenerationMode generationMode) |
|||
get |
|||
var graph = owner as AbstractMaterialGraph; |
|||
var property = graph.properties.FirstOrDefault(x => x.guid == propertyGuid); |
|||
if (property == null) |
|||
return; |
|||
|
|||
if (property is FloatShaderProperty) |
|||
{ |
|||
var result = string.Format("{0} {1} = {2};" |
|||
, precision |
|||
, GetVariableNameForSlot(OutputSlotId) |
|||
, property.name); |
|||
visitor.AddShaderChunk(result, true); |
|||
} |
|||
else if (property is Vector2ShaderProperty) |
|||
{ |
|||
var result = string.Format("{0}2 {1} = {2};" |
|||
, precision |
|||
, GetVariableNameForSlot(OutputSlotId) |
|||
, property.name); |
|||
visitor.AddShaderChunk(result, true); |
|||
} |
|||
else if (property is Vector3ShaderProperty) |
|||
if (owner is SubGraph) |
|||
return ExposedState.NotExposed; |
|||
|
|||
return m_Exposed; |
|||
var result = string.Format("{0}3 {1} = {2};" |
|||
, precision |
|||
, GetVariableNameForSlot(OutputSlotId) |
|||
, property.name); |
|||
visitor.AddShaderChunk(result, true); |
|||
} |
|||
else if (property is Vector4ShaderProperty) |
|||
{ |
|||
var result = string.Format("{0}4 {1} = {2};" |
|||
, precision |
|||
, GetVariableNameForSlot(OutputSlotId) |
|||
, property.name); |
|||
visitor.AddShaderChunk(result, true); |
|||
} |
|||
else if (property is ColorShaderProperty) |
|||
{ |
|||
var result = string.Format("{0}4 {1} = {2};" |
|||
, precision |
|||
, GetVariableNameForSlot(OutputSlotId) |
|||
, property.name); |
|||
visitor.AddShaderChunk(result, true); |
|||
set |
|||
else if (property is TextureShaderProperty) |
|||
if (m_Exposed == value) |
|||
return; |
|||
//UV input slot
|
|||
var uvSlot = FindInputSlot<MaterialSlot>(UVInput); |
|||
var uvName = string.Format("{0}.xy", UVChannel.uv0.GetUVName()); |
|||
var edgesUV = owner.GetEdges(uvSlot.slotReference); |
|||
if (edgesUV.Any()) |
|||
uvName = GetSlotValue(UVInput, generationMode); |
|||
m_Exposed = value; |
|||
//Sampler input slot
|
|||
var result = string.Format("{0}4 {1} = UNITY_SAMPLE_TEX2D({2},{3});" |
|||
, precision |
|||
, GetVariableNameForSlot(OutputSlotId) |
|||
, property.name |
|||
, uvName); |
|||
visitor.AddShaderChunk(result, true); |
|||
visitor.AddShaderChunk(string.Format("{0} {1} = {2}.r;", precision, GetVariableNameForSlot(ROutputSlotId), GetVariableNameForSlot(OutputSlotId)), true); |
|||
visitor.AddShaderChunk(string.Format("{0} {1} = {2}.g;", precision, GetVariableNameForSlot(GOutputSlotId), GetVariableNameForSlot(OutputSlotId)), true); |
|||
visitor.AddShaderChunk(string.Format("{0} {1} = {2}.b;", precision, GetVariableNameForSlot(BOutputSlotId), GetVariableNameForSlot(OutputSlotId)), true); |
|||
visitor.AddShaderChunk(string.Format("{0} {1} = {2}.a;", precision, GetVariableNameForSlot(AOutputSlotId), GetVariableNameForSlot(OutputSlotId)), true); |
|||
public string description |
|||
public bool RequiresMeshUV(UVChannel channel) |
|||
get |
|||
{ |
|||
return string.IsNullOrEmpty(m_Description) ? name : m_Description; |
|||
} |
|||
set { m_Description = value; } |
|||
if (channel != UVChannel.uv0) |
|||
return false; |
|||
|
|||
var uvSlot = FindInputSlot<MaterialSlot>(UVInput); |
|||
if (uvSlot == null) |
|||
return true; |
|||
|
|||
var edges = owner.GetEdges(uvSlot.slotReference).ToList(); |
|||
return edges.Count == 0; |
|||
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()); |
|||
if (slotId != TOutputSlotId) |
|||
return base.GetVariableNameForSlot(slotId); |
|||
|
|||
var graph = owner as AbstractMaterialGraph; |
|||
var property = graph.properties.FirstOrDefault(x => x.guid == propertyGuid); |
|||
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 == propertyGuid)) |
|||
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); |
|||
|
|||
modified |= base.OnGUI(); |
|||
return modified; |
|||
}*/ |
|||
base.OnAfterDeserialize(); |
|||
if (!string.IsNullOrEmpty(m_PropertyGuidSerialized)) |
|||
m_PropertyGuid = new Guid(m_PropertyGuidSerialized); |
|||
} |
|||
} |
|||
} |
|
|||
namespace UnityEngine.MaterialGraph |
|||
{ |
|||
public enum TextureType |
|||
{ |
|||
White, |
|||
Gray, |
|||
Black, |
|||
Bump |
|||
} |
|||
} |
|
|||
using System; |
|||
|
|||
namespace UnityEngine.MaterialGraph |
|||
{ |
|||
[Serializable] |
|||
public abstract class AbstractShaderProperty<T> : ISerializationCallbackReceiver, IShaderProperty |
|||
{ |
|||
[SerializeField] |
|||
private T m_Value; |
|||
|
|||
[SerializeField] |
|||
private string m_Description; |
|||
|
|||
[SerializeField] |
|||
private string m_Name; |
|||
|
|||
[NonSerialized] |
|||
private Guid m_Guid; |
|||
|
|||
[SerializeField] |
|||
private string m_GuidSerialized; |
|||
|
|||
[SerializeField] |
|||
private bool m_GeneratePropertyBlock = true; |
|||
|
|||
protected AbstractShaderProperty() |
|||
{ |
|||
m_Guid = Guid.NewGuid(); |
|||
} |
|||
|
|||
public T value |
|||
{ |
|||
get { return m_Value; } |
|||
set { m_Value = value; } |
|||
} |
|||
|
|||
public string name |
|||
{ |
|||
get |
|||
{ |
|||
if (string.IsNullOrEmpty(m_Name)) |
|||
return m_Guid.ToString(); |
|||
return m_Name; |
|||
} |
|||
set { m_Name = value; } |
|||
} |
|||
|
|||
public string description |
|||
{ |
|||
get |
|||
{ |
|||
return string.IsNullOrEmpty(m_Description) ? name : m_Description; |
|||
} |
|||
set { m_Description = value; } |
|||
} |
|||
|
|||
public abstract PropertyType propertyType { get; } |
|||
|
|||
public Guid guid |
|||
{ |
|||
get { return m_Guid; } |
|||
} |
|||
|
|||
public bool generatePropertyBlock |
|||
{ |
|||
get { return m_GeneratePropertyBlock; } |
|||
set { m_GeneratePropertyBlock = value; } |
|||
} |
|||
|
|||
public abstract string GetPropertyBlockString(); |
|||
public abstract string GetPropertyDeclarationString(); |
|||
public abstract PreviewProperty GetPreviewMaterialProperty(); |
|||
|
|||
public virtual void OnBeforeSerialize() |
|||
{ |
|||
m_GuidSerialized = m_Guid.ToString(); |
|||
} |
|||
|
|||
public virtual void OnAfterDeserialize() |
|||
{ |
|||
if (!string.IsNullOrEmpty(m_GuidSerialized)) |
|||
m_Guid = new Guid(m_GuidSerialized); |
|||
else |
|||
m_Guid = Guid.NewGuid(); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: b1411039ed1342fa8efff6fa8a4c179d |
|||
timeCreated: 1505346915 |
|
|||
using System; |
|||
using System.Text; |
|||
|
|||
namespace UnityEngine.MaterialGraph |
|||
{ |
|||
[Serializable] |
|||
public class ColorShaderProperty : AbstractShaderProperty<Color> |
|||
{ |
|||
[SerializeField] |
|||
private bool m_HDR; |
|||
|
|||
public bool HDR |
|||
{ |
|||
get { return m_HDR; } |
|||
set |
|||
{ |
|||
if (m_HDR == value) |
|||
return; |
|||
|
|||
m_HDR = value; |
|||
} |
|||
} |
|||
|
|||
public override PropertyType propertyType |
|||
{ |
|||
get { return PropertyType.Color; } |
|||
} |
|||
|
|||
public override string GetPropertyBlockString() |
|||
{ |
|||
if (!generatePropertyBlock) |
|||
return string.Empty; |
|||
|
|||
var result = new StringBuilder(); |
|||
if (HDR) |
|||
result.Append("[HDR]"); |
|||
result.Append(name); |
|||
result.Append("(\""); |
|||
result.Append(description); |
|||
result.Append("\", Color) = ("); |
|||
result.Append(value.r); |
|||
result.Append(","); |
|||
result.Append(value.g); |
|||
result.Append(","); |
|||
result.Append(value.b); |
|||
result.Append(","); |
|||
result.Append(value.a); |
|||
result.Append(")"); |
|||
return result.ToString(); |
|||
} |
|||
|
|||
public override string GetPropertyDeclarationString() |
|||
{ |
|||
return "float4 " + name + ";"; |
|||
} |
|||
|
|||
public override PreviewProperty GetPreviewMaterialProperty() |
|||
{ |
|||
return new PreviewProperty |
|||
{ |
|||
m_Name = name, |
|||
m_PropType = PropertyType.Color, |
|||
m_Color = value |
|||
}; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 47cf9e64b21b48b09320f42eb82ac3c3 |
|||
timeCreated: 1505346940 |
|
|||
using System; |
|||
using System.Text; |
|||
|
|||
namespace UnityEngine.MaterialGraph |
|||
{ |
|||
[Serializable] |
|||
public class FloatShaderProperty : AbstractShaderProperty<float> |
|||
{ |
|||
public override PropertyType propertyType |
|||
{ |
|||
get { return PropertyType.Float; } |
|||
} |
|||
|
|||
public override string GetPropertyBlockString() |
|||
{ |
|||
var result = new StringBuilder(); |
|||
// if (m_FloatType == FloatPropertyChunk.FloatType.Toggle)
|
|||
// result.Append("[Toggle]");
|
|||
// else if (m_FloatType == FloatPropertyChunk.FloatType.PowerSlider)
|
|||
// result.Append("[PowerSlider(" + m_rangeValues.z + ")]");
|
|||
result.Append(name); |
|||
result.Append("(\""); |
|||
result.Append(description); |
|||
|
|||
//if (m_FloatType == FloatPropertyChunk.FloatType.Float || m_FloatType == FloatPropertyChunk.FloatType.Toggle)
|
|||
//{
|
|||
result.Append("\", Float) = "); |
|||
/* } |
|||
else if (m_FloatType == FloatPropertyChunk.FloatType.Range || m_FloatType == FloatPropertyChunk.FloatType.PowerSlider) |
|||
{ |
|||
result.Append("\", Range("); |
|||
result.Append(m_rangeValues.x + ", " + m_rangeValues.y); |
|||
result.Append(")) = "); |
|||
}*/ |
|||
result.Append(value); |
|||
return result.ToString(); |
|||
} |
|||
|
|||
public override string GetPropertyDeclarationString() |
|||
{ |
|||
return "float " + name + ";"; |
|||
} |
|||
|
|||
public override PreviewProperty GetPreviewMaterialProperty() |
|||
{ |
|||
return new PreviewProperty() |
|||
{ |
|||
m_Name = name, |
|||
m_PropType = PropertyType.Float, |
|||
m_Float = value |
|||
}; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 572cce24ed76430db4c21dfe82d01252 |
|||
timeCreated: 1505346922 |
|
|||
using System; |
|||
|
|||
namespace UnityEngine.MaterialGraph |
|||
{ |
|||
public interface IShaderProperty |
|||
{ |
|||
string name { get; set; } |
|||
string description { get; set; } |
|||
PropertyType propertyType { get; } |
|||
Guid guid { get; } |
|||
bool generatePropertyBlock { get; set; } |
|||
|
|||
string GetPropertyBlockString(); |
|||
string GetPropertyDeclarationString(); |
|||
PreviewProperty GetPreviewMaterialProperty(); |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 7594463b49eb4d70a1b938f328f0c0b0 |
|||
timeCreated: 1505346909 |
|
|||
using System; |
|||
|
|||
namespace UnityEngine.MaterialGraph |
|||
{ |
|||
class SamplerStateShaderProperty : AbstractShaderProperty<TextureSamplerState> |
|||
{ |
|||
public override PropertyType propertyType |
|||
{ |
|||
get { return PropertyType.SamplerState; } |
|||
} |
|||
|
|||
public override string GetPropertyBlockString() |
|||
{ |
|||
return string.Empty; |
|||
} |
|||
|
|||
public override string GetPropertyDeclarationString() |
|||
{ |
|||
string ss = name + "_" |
|||
+ Enum.GetName(typeof(TextureSamplerState.FilterMode), value.filter) + "_" |
|||
+ Enum.GetName(typeof(TextureSamplerState.WrapMode), value.wrap) + "_sampler;"; |
|||
|
|||
return string.Format(@"
|
|||
#ifdef UNITY_COMPILER_HLSL |
|||
SamplerState {0}; |
|||
#endif", ss);
|
|||
} |
|||
|
|||
public override PreviewProperty GetPreviewMaterialProperty() |
|||
{ |
|||
return null; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: b48a2e97e3e24303833a0062f90f4f13 |
|||
timeCreated: 1505436387 |
|
|||
using System; |
|||
using UnityEditor; |
|||
|
|||
namespace UnityEngine.MaterialGraph |
|||
{ |
|||
[Serializable] |
|||
public class SerializableTexture |
|||
{ |
|||
[SerializeField] private string m_SerializedTexture; |
|||
|
|||
[Serializable] |
|||
private class TextureHelper |
|||
{ |
|||
public Texture texture; |
|||
} |
|||
|
|||
#if UNITY_EDITOR
|
|||
public Texture texture |
|||
{ |
|||
get |
|||
{ |
|||
if (string.IsNullOrEmpty(m_SerializedTexture)) |
|||
return null; |
|||
|
|||
var tex = new TextureHelper(); |
|||
EditorJsonUtility.FromJsonOverwrite(m_SerializedTexture, tex); |
|||
return tex.texture; |
|||
} |
|||
set |
|||
{ |
|||
if (texture == value) |
|||
return; |
|||
|
|||
var tex = new TextureHelper(); |
|||
tex.texture = value; |
|||
m_SerializedTexture = EditorJsonUtility.ToJson(tex, true); |
|||
} |
|||
} |
|||
#else
|
|||
public Texture defaultTexture {get; set; } |
|||
#endif
|
|||
|
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: a4a4ff926ce74b059400bb049aefcba2 |
|||
timeCreated: 1505346945 |
|
|||
using System.Collections.Generic; |
|||
|
|||
namespace UnityEngine.MaterialGraph |
|||
{ |
|||
public struct ShaderGraphRequirements |
|||
{ |
|||
public NeededCoordinateSpace requiresNormal; |
|||
public NeededCoordinateSpace requiresBitangent; |
|||
public NeededCoordinateSpace requiresTangent; |
|||
public NeededCoordinateSpace requiresViewDir; |
|||
public NeededCoordinateSpace requiresPosition; |
|||
public bool requiresScreenPosition; |
|||
public bool requiresVertexColor; |
|||
public List<UVChannel> requiresMeshUVs; |
|||
|
|||
public bool NeedsTangentSpace() |
|||
{ |
|||
var compoundSpaces = requiresBitangent | requiresNormal | requiresPosition |
|||
| requiresTangent | requiresViewDir | requiresPosition |
|||
| requiresNormal; |
|||
|
|||
return (compoundSpaces & NeededCoordinateSpace.Tangent) > 0; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: b80c0c5cd7f940d7bc0f37b22c454d40 |
|||
timeCreated: 1505698038 |
|
|||
namespace UnityEngine.MaterialGraph |
|||
{ |
|||
public class TextureSamplerState |
|||
{ |
|||
public enum FilterMode |
|||
{ |
|||
Linear, |
|||
Point |
|||
} |
|||
|
|||
public enum WrapMode |
|||
{ |
|||
Repeat, |
|||
Clamp |
|||
} |
|||
|
|||
[SerializeField] private FilterMode m_filter = FilterMode.Linear; |
|||
|
|||
public FilterMode filter |
|||
{ |
|||
get { return m_filter; } |
|||
set |
|||
{ |
|||
if (m_filter == value) |
|||
return; |
|||
|
|||
m_filter = value; |
|||
} |
|||
} |
|||
|
|||
[SerializeField] private WrapMode m_wrap = WrapMode.Repeat; |
|||
|
|||
public WrapMode wrap |
|||
{ |
|||
get { return m_wrap; } |
|||
set |
|||
{ |
|||
if (m_wrap == value) |
|||
return; |
|||
|
|||
m_wrap = value; |
|||
} |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: a0238123ffe44c05bc05acf347c4d52d |
|||
timeCreated: 1505436371 |
|
|||
using System; |
|||
using System.Text; |
|||
|
|||
namespace UnityEngine.MaterialGraph |
|||
{ |
|||
[Serializable] |
|||
public class TextureShaderProperty : AbstractShaderProperty<SerializableTexture> |
|||
{ |
|||
[SerializeField] |
|||
private bool m_Modifiable; |
|||
|
|||
public TextureShaderProperty() |
|||
{ |
|||
value = new SerializableTexture(); |
|||
} |
|||
|
|||
public override PropertyType propertyType |
|||
{ |
|||
get { return PropertyType.Texture; } |
|||
} |
|||
|
|||
public bool modifiable |
|||
{ |
|||
get { return m_Modifiable; } |
|||
set { m_Modifiable = value; } |
|||
} |
|||
|
|||
public override string GetPropertyBlockString() |
|||
{ |
|||
var result = new StringBuilder(); |
|||
if (!m_Modifiable) |
|||
{ |
|||
result.Append("[HideInInspector] "); |
|||
result.Append("[NonModifiableTextureData] "); |
|||
} |
|||
result.Append("[NoScaleOffset] "); |
|||
|
|||
result.Append(name); |
|||
result.Append("(\""); |
|||
result.Append(description); |
|||
result.Append("\", 2D) = \"white\" {}"); |
|||
return result.ToString(); |
|||
} |
|||
|
|||
public override string GetPropertyDeclarationString() |
|||
{ |
|||
return "UNITY_DECLARE_TEX2D(" + name + ");"; |
|||
} |
|||
|
|||
|
|||
public override PreviewProperty GetPreviewMaterialProperty() |
|||
{ |
|||
return new PreviewProperty() |
|||
{ |
|||
m_Name = name, |
|||
m_PropType = PropertyType.Texture, |
|||
m_Texture = value.texture |
|||
}; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 08e62564fb95471d9580619b660c6531 |
|||
timeCreated: 1505346949 |
|
|||
using System; |
|||
|
|||
namespace UnityEngine.MaterialGraph |
|||
{ |
|||
[Serializable] |
|||
public class Vector2ShaderProperty : VectorShaderProperty |
|||
{ |
|||
public override PropertyType propertyType |
|||
{ |
|||
get { return PropertyType.Vector2; } |
|||
} |
|||
|
|||
public override PreviewProperty GetPreviewMaterialProperty() |
|||
{ |
|||
return new PreviewProperty() |
|||
{ |
|||
m_Name = name, |
|||
m_PropType = PropertyType.Vector2, |
|||
m_Vector4 = value |
|||
}; |
|||
} |
|||
|
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: dbd5691737554a15ab0b098fca999382 |
|||
timeCreated: 1505346926 |
|
|||
using System; |
|||
|
|||
namespace UnityEngine.MaterialGraph |
|||
{ |
|||
[Serializable] |
|||
public class Vector3ShaderProperty : VectorShaderProperty |
|||
{ |
|||
public override PropertyType propertyType |
|||
{ |
|||
get { return PropertyType.Vector3; } |
|||
} |
|||
|
|||
public override PreviewProperty GetPreviewMaterialProperty() |
|||
{ |
|||
return new PreviewProperty() |
|||
{ |
|||
m_Name = name, |
|||
m_PropType = PropertyType.Vector3, |
|||
m_Vector4 = value |
|||
}; |
|||
} |
|||
} |
|||
} |
部分文件因为文件数量过多而无法显示
撰写
预览
正在加载...
取消
保存
Reference in new issue