当前提交
8a87c992
共有 87 个文件被更改,包括 1016 次插入 和 1026 次删除
-
9MaterialGraphProject/Assets/NewNodes/Keep/HeightToNormalNode.cs
-
58MaterialGraphProject/Assets/NewNodes/Keep/SamplerStateNode.cs
-
2MaterialGraphProject/Assets/UnityShaderEditor/Editor/AssetCallbacks/CreateShaderGraph.cs
-
50MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/AbstractMaterialGraphEditWindow.cs
-
19MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/Presenters/GraphInspectorPresenter.cs
-
4MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/Presenters/SurfaceMasterNodeEditorPresenter.cs
-
59MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/Views/GraphInspectorView.cs
-
4MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/Views/SurfaceMasterNodeEditorView.cs
-
2MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/MaterialGraphPreviewGenerator.cs
-
4MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/NodeInspectors/SurfaceMasterNodeInspector.cs
-
7MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/GraphEditorPresenter.cs
-
2MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/MaterialGraphPresenter.cs
-
18MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/NodePreviewPresenter.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
-
5MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Nodes/Vector1NodePresenter.cs
-
8MaterialGraphProject/Assets/UnityShaderEditor/Editor/Importers/ShaderGraphImporter.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
-
273MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Graphs/AbstractMaterialGraph.cs
-
63MaterialGraphProject/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
-
7MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/AbstractMaterialNode.cs
-
11MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/ColorNode.cs
-
2MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Matrix/Matrix2Node.cs
-
25MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Vector/Vector1Node.cs
-
9MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Vector/Vector2Node.cs
-
10MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Vector/Vector3Node.cs
-
9MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Vector/Vector4Node.cs
-
4MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/PropertyNode.cs
-
13MaterialGraphProject/Assets/UnityShaderEditor/Runtime/SubGraph/SubGraph.cs
-
41MaterialGraphProject/Assets/UnityShaderEditor/Runtime/SubGraph/SubGraphInputNode.cs
-
16MaterialGraphProject/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
-
14MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Util/ShaderGenerator.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
-
45MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Graphs/TextureSamplerState.cs
-
3MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Graphs/TextureSamplerState.cs.meta
-
63MaterialGraphProject/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
-
3MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Graphs/Vector3ShaderProperty.cs.meta
-
23MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Graphs/Vector4ShaderProperty.cs
-
3MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Graphs/Vector4ShaderProperty.cs.meta
-
32MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Graphs/VectorShaderProperty.cs
-
3MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Graphs/VectorShaderProperty.cs.meta
-
32MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/MasterNode.cs
-
69MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Util/PropertyCollector.cs
-
56MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/AbstractMasterNode.cs
-
12MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Util/ColorPropertyChunk.cs.meta
-
12MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Util/FloatPropertyChunk.cs.meta
-
27MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Util/PropertyChunk.cs
-
12MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Util/PropertyChunk.cs.meta
-
57MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Util/PropertyGenerator.cs
-
12MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Util/TexturePropertyChunk.cs.meta
-
38MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Util/VectorPropertyChunk.cs
-
12MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Util/VectorPropertyChunk.cs.meta
-
48MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Util/ColorPropertyChunk.cs
-
70MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Util/FloatPropertyChunk.cs
-
59MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Util/TexturePropertyChunk.cs
-
0/MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/MasterNode.cs.meta
-
0/MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Util/PropertyCollector.cs.meta
|
|||
using System.Collections.Generic; |
|||
|
|||
void GeneratePropertyBlock(PropertyGenerator visitor, GenerationMode generationMode); |
|||
void GeneratePropertyUsages(ShaderGenerator visitor, GenerationMode generationMode); |
|||
void CollectShaderProperties(PropertyCollector properties, GenerationMode generationMode); |
|||
} |
|||
} |
|
|||
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 |
|
|||
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) = \""); |
|||
result.Append(Enum.GetName(typeof(TextureType), value.texture).ToLower()); |
|||
result.Append("\" {}"); |
|||
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 |
|||
}; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 34a68571f5ae4ebe8221824597dc0675 |
|||
timeCreated: 1505346931 |
|
|||
using System; |
|||
|
|||
namespace UnityEngine.MaterialGraph |
|||
{ |
|||
[Serializable] |
|||
public class Vector4ShaderProperty : VectorShaderProperty |
|||
{ |
|||
public override PropertyType propertyType |
|||
{ |
|||
get { return PropertyType.Vector4; } |
|||
} |
|||
|
|||
public override PreviewProperty GetPreviewMaterialProperty() |
|||
{ |
|||
return new PreviewProperty() |
|||
{ |
|||
m_Name = name, |
|||
m_PropType = PropertyType.Vector4, |
|||
m_Vector4 = value |
|||
}; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 3989871719194dbdba09613ac74761b3 |
|||
timeCreated: 1505346935 |
|
|||
using System; |
|||
using System.Text; |
|||
|
|||
namespace UnityEngine.MaterialGraph |
|||
{ |
|||
[Serializable] |
|||
public abstract class VectorShaderProperty : AbstractShaderProperty<Vector4> |
|||
{ |
|||
public override string GetPropertyBlockString() |
|||
{ |
|||
var result = new StringBuilder(); |
|||
result.Append(name); |
|||
result.Append("(\""); |
|||
result.Append(description); |
|||
result.Append("\", Vector) = ("); |
|||
result.Append(value.x); |
|||
result.Append(","); |
|||
result.Append(value.y); |
|||
result.Append(","); |
|||
result.Append(value.z); |
|||
result.Append(","); |
|||
result.Append(value.w); |
|||
result.Append(")"); |
|||
return result.ToString(); |
|||
} |
|||
|
|||
public override string GetPropertyDeclarationString() |
|||
{ |
|||
return "float4 " + name + ";"; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 4f83ebb04c5c4df184601ef18aa7d89d |
|||
timeCreated: 1505408377 |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using UnityEngine.Graphing; |
|||
|
|||
namespace UnityEngine.MaterialGraph |
|||
{ |
|||
[Serializable] |
|||
public class MasterNode : AbstractMaterialNode |
|||
{ |
|||
protected override bool generateDefaultInputs { get { return false; } } |
|||
|
|||
public override IEnumerable<ISlot> GetInputsWithNoConnection() |
|||
{ |
|||
return new List<ISlot>(); |
|||
} |
|||
|
|||
public override bool hasPreview |
|||
{ |
|||
get { return true; } |
|||
} |
|||
|
|||
public override bool allowedInSubGraph |
|||
{ |
|||
get { return false; } |
|||
} |
|||
|
|||
public virtual bool has3DPreview() |
|||
{ |
|||
return true; |
|||
} |
|||
} |
|||
} |
|
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
|
|||
namespace UnityEngine.MaterialGraph |
|||
{ |
|||
public class PropertyCollector |
|||
{ |
|||
public struct TextureInfo |
|||
{ |
|||
public string name; |
|||
public int textureId; |
|||
public bool modifiable; |
|||
} |
|||
|
|||
private readonly List<IShaderProperty> m_Properties = new List<IShaderProperty>(); |
|||
|
|||
public void AddShaderProperty(IShaderProperty chunk) |
|||
{ |
|||
if (m_Properties.Any(x => x.name == chunk.name)) |
|||
return; |
|||
m_Properties.Add(chunk); |
|||
} |
|||
|
|||
public string GetPropertiesBlock(int baseIndentLevel) |
|||
{ |
|||
var sb = new StringBuilder(); |
|||
foreach (var prop in m_Properties) |
|||
{ |
|||
for (var i = 0; i < baseIndentLevel; i++) |
|||
sb.Append("\t"); |
|||
sb.AppendLine(prop.GetPropertyBlockString()); |
|||
} |
|||
return sb.ToString(); |
|||
} |
|||
|
|||
public string GetPropertiesDeclaration(int baseIndentLevel) |
|||
{ |
|||
var sb = new StringBuilder(); |
|||
foreach (var prop in m_Properties) |
|||
{ |
|||
for (var i = 0; i < baseIndentLevel; i++) |
|||
sb.Append("\t"); |
|||
sb.AppendLine(prop.GetPropertyDeclarationString()); |
|||
} |
|||
return sb.ToString(); |
|||
} |
|||
|
|||
public List<TextureInfo> GetConfiguredTexutres() |
|||
{ |
|||
var result = new List<TextureInfo>(); |
|||
|
|||
foreach (var prop in m_Properties.OfType<TextureShaderProperty>()) |
|||
{ |
|||
if (prop.name != null) |
|||
{ |
|||
var textureInfo = new TextureInfo |
|||
{ |
|||
name = prop.name, |
|||
textureId = prop.value.texture != null ? prop.value.texture.GetInstanceID() : 0, |
|||
modifiable = prop.modifiable |
|||
}; |
|||
result.Add(textureInfo); |
|||
} |
|||
} |
|||
return result; |
|||
} |
|||
} |
|||
} |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using UnityEngine.Graphing; |
|||
|
|||
namespace UnityEngine.MaterialGraph |
|||
{ |
|||
[Serializable] |
|||
public abstract class AbstractMasterNode : AbstractMaterialNode, IMasterNode |
|||
{ |
|||
protected override bool generateDefaultInputs { get { return false; } } |
|||
|
|||
public override IEnumerable<ISlot> GetInputsWithNoConnection() |
|||
{ |
|||
return new List<ISlot>(); |
|||
} |
|||
|
|||
public override bool hasPreview |
|||
{ |
|||
get { return true; } |
|||
} |
|||
|
|||
public override bool allowedInSubGraph |
|||
{ |
|||
get { return false; } |
|||
} |
|||
|
|||
public bool isActiveMaster |
|||
{ |
|||
get |
|||
{ |
|||
var graph = owner as MaterialGraph; |
|||
return graph != null && graph.masterNode == this; |
|||
} |
|||
set |
|||
{ |
|||
var graph = owner as MaterialGraph; |
|||
if (graph == null || value == isActiveMaster) |
|||
return; |
|||
graph.masterNode = value ? this : null; |
|||
} |
|||
} |
|||
|
|||
public bool canBeActiveMaster |
|||
{ |
|||
get { return owner is MaterialGraph; } |
|||
} |
|||
|
|||
public abstract string GetFullShader(GenerationMode mode, string name, out List<PropertyGenerator.TextureInfo> configuredTextures); |
|||
public abstract string GetSubShader(GenerationMode mode, PropertyGenerator shaderPropertiesVisitor); |
|||
|
|||
public virtual bool has3DPreview() |
|||
{ |
|||
return true; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: c55a60f83c47c3940b74e5a1f53d69aa |
|||
timeCreated: 1469695793 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 5165619d6635ec146aa7014ac39356cd |
|||
timeCreated: 1469695793 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
namespace UnityEngine.MaterialGraph |
|||
{ |
|||
public abstract class PropertyChunk |
|||
{ |
|||
public enum HideState |
|||
{ |
|||
Hidden, |
|||
Visible |
|||
} |
|||
|
|||
private readonly string m_PropertyName; |
|||
private readonly string m_PropertyDescription; |
|||
private readonly HideState m_HideState; |
|||
|
|||
protected PropertyChunk(string propertyName, string propertyDescription, HideState hideState) |
|||
{ |
|||
m_PropertyName = propertyName; |
|||
m_PropertyDescription = propertyDescription; |
|||
m_HideState = hideState; |
|||
} |
|||
|
|||
public abstract string GetPropertyString(); |
|||
public string propertyName { get { return m_PropertyName; } } |
|||
public string propertyDescription { get { return m_PropertyDescription; } } |
|||
public HideState hideState { get { return m_HideState; } } |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: e3bc93a0908e88743a7f24757b2a85f4 |
|||
timeCreated: 1469695793 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
|
|||
namespace UnityEngine.MaterialGraph |
|||
{ |
|||
public class PropertyGenerator |
|||
{ |
|||
public struct TextureInfo |
|||
{ |
|||
public string name; |
|||
public int textureId; |
|||
public TexturePropertyChunk.ModifiableState modifiable; |
|||
} |
|||
|
|||
private readonly List<PropertyChunk> m_Properties = new List<PropertyChunk>(); |
|||
|
|||
public void AddShaderProperty(PropertyChunk chunk) |
|||
{ |
|||
if (m_Properties.Any(x => x.propertyName == chunk.propertyName)) |
|||
return; |
|||
m_Properties.Add(chunk); |
|||
} |
|||
|
|||
public string GetShaderString(int baseIndentLevel) |
|||
{ |
|||
var sb = new StringBuilder(); |
|||
foreach (var prop in m_Properties) |
|||
{ |
|||
for (var i = 0; i < baseIndentLevel; i++) |
|||
sb.Append("\t"); |
|||
sb.AppendLine(prop.GetPropertyString()); |
|||
} |
|||
return sb.ToString(); |
|||
} |
|||
|
|||
public List<TextureInfo> GetConfiguredTexutres() |
|||
{ |
|||
var result = new List<TextureInfo>(); |
|||
|
|||
foreach (var prop in m_Properties.OfType<TexturePropertyChunk>()) |
|||
{ |
|||
if (prop.propertyName != null) |
|||
{ |
|||
var textureInfo = new TextureInfo |
|||
{ |
|||
name = prop.propertyName, |
|||
textureId = prop.defaultTexture != null ? prop.defaultTexture.GetInstanceID() : 0, |
|||
modifiable = prop.modifiableState |
|||
}; |
|||
result.Add(textureInfo); |
|||
} |
|||
} |
|||
return result; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 2ac615170ebfd804eb0e5dbd753d73e9 |
|||
timeCreated: 1469695793 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Text; |
|||
|
|||
namespace UnityEngine.MaterialGraph |
|||
{ |
|||
public class VectorPropertyChunk : PropertyChunk |
|||
{ |
|||
private readonly Vector4 m_DefaultVector; |
|||
|
|||
public VectorPropertyChunk(string propertyName, string propertyDescription, Vector4 defaultVector, HideState hideState) |
|||
: base(propertyName, propertyDescription, hideState) |
|||
{ |
|||
m_DefaultVector = defaultVector; |
|||
} |
|||
|
|||
public Vector4 defaultValue |
|||
{ |
|||
get { return m_DefaultVector; } |
|||
} |
|||
|
|||
public override string GetPropertyString() |
|||
{ |
|||
var result = new StringBuilder(); |
|||
result.Append(propertyName); |
|||
result.Append("(\""); |
|||
result.Append(propertyDescription); |
|||
result.Append("\", Vector) = ("); |
|||
result.Append(defaultValue.x); |
|||
result.Append(","); |
|||
result.Append(defaultValue.y); |
|||
result.Append(","); |
|||
result.Append(defaultValue.z); |
|||
result.Append(","); |
|||
result.Append(defaultValue.w); |
|||
result.Append(")"); |
|||
return result.ToString(); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: f215325849c67a741994a3bade6cdda6 |
|||
timeCreated: 1469695793 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Text; |
|||
|
|||
namespace UnityEngine.MaterialGraph |
|||
{ |
|||
public class ColorPropertyChunk : PropertyChunk |
|||
{ |
|||
public enum ColorType |
|||
{ |
|||
Default, |
|||
HDR |
|||
} |
|||
|
|||
private Color m_DefaultColor; |
|||
private ColorType m_colorType; |
|||
|
|||
public ColorPropertyChunk(string propertyName, string propertyDescription, Color defaultColor, ColorType colorType, HideState hideState) |
|||
: base(propertyName, propertyDescription, hideState) |
|||
{ |
|||
m_colorType = colorType; |
|||
m_DefaultColor = defaultColor; |
|||
} |
|||
|
|||
public Color defaultColor |
|||
{ |
|||
get { return m_DefaultColor; } |
|||
} |
|||
|
|||
public override string GetPropertyString() |
|||
{ |
|||
var result = new StringBuilder(); |
|||
if (m_colorType == ColorType.HDR) |
|||
result.Append("[HDR]"); |
|||
result.Append(propertyName); |
|||
result.Append("(\""); |
|||
result.Append(propertyDescription); |
|||
result.Append("\", Color) = ("); |
|||
result.Append(defaultColor.r); |
|||
result.Append(","); |
|||
result.Append(defaultColor.g); |
|||
result.Append(","); |
|||
result.Append(defaultColor.b); |
|||
result.Append(","); |
|||
result.Append(defaultColor.a); |
|||
result.Append(")"); |
|||
return result.ToString(); |
|||
} |
|||
} |
|||
} |
|
|||
using System.Text; |
|||
|
|||
namespace UnityEngine.MaterialGraph |
|||
{ |
|||
public class FloatPropertyChunk : PropertyChunk |
|||
{ |
|||
public enum FloatType |
|||
{ |
|||
Float, |
|||
Toggle, |
|||
Range, |
|||
PowerSlider |
|||
} |
|||
|
|||
private readonly float m_DefaultValue; |
|||
private readonly FloatType m_FloatType; |
|||
private readonly Vector3 m_rangeValues; |
|||
|
|||
public FloatPropertyChunk(string propertyName, string propertyDescription, float defaultValue, HideState hideState) |
|||
: base(propertyName, propertyDescription, hideState) |
|||
{ |
|||
m_DefaultValue = defaultValue; |
|||
} |
|||
|
|||
public FloatPropertyChunk(string propertyName, string propertyDescription, float defaultValue, FloatType floatType, HideState hideState) |
|||
: base(propertyName, propertyDescription, hideState) |
|||
{ |
|||
m_FloatType = floatType; |
|||
m_DefaultValue = defaultValue; |
|||
} |
|||
|
|||
public FloatPropertyChunk(string propertyName, string propertyDescription, float defaultValue, FloatType floatType, Vector3 rangeValues, HideState hideState) |
|||
: base(propertyName, propertyDescription, hideState) |
|||
{ |
|||
m_FloatType = floatType; |
|||
m_rangeValues = rangeValues; |
|||
m_DefaultValue = defaultValue; |
|||
} |
|||
|
|||
public float defaultValue |
|||
{ |
|||
get { return m_DefaultValue; } |
|||
} |
|||
|
|||
public override string GetPropertyString() |
|||
{ |
|||
var result = new StringBuilder(); |
|||
if (m_FloatType == FloatType.Toggle) |
|||
result.Append("[Toggle]"); |
|||
else if (m_FloatType == FloatType.PowerSlider) |
|||
result.Append("[PowerSlider(" + m_rangeValues.z + ")]"); |
|||
result.Append(propertyName); |
|||
result.Append("(\""); |
|||
result.Append(propertyDescription); |
|||
|
|||
if (m_FloatType == FloatType.Float || m_FloatType == FloatType.Toggle) |
|||
{ |
|||
result.Append("\", Float) = "); |
|||
} |
|||
else if (m_FloatType == FloatType.Range || m_FloatType == FloatType.PowerSlider) |
|||
{ |
|||
result.Append("\", Range("); |
|||
result.Append(m_rangeValues.x + ", " + m_rangeValues.y); |
|||
result.Append(")) = "); |
|||
} |
|||
result.Append(defaultValue); |
|||
return result.ToString(); |
|||
} |
|||
} |
|||
} |
|
|||
using System; |
|||
using System.Text; |
|||
|
|||
namespace UnityEngine.MaterialGraph |
|||
{ |
|||
public class TexturePropertyChunk : PropertyChunk |
|||
{ |
|||
public enum ModifiableState |
|||
{ |
|||
Modifiable, |
|||
NonModifiable |
|||
} |
|||
|
|||
private readonly Texture m_DefaultTexture; |
|||
private readonly TextureType m_DefaultTextureType; |
|||
private readonly ModifiableState m_Modifiable; |
|||
|
|||
public TexturePropertyChunk(string propertyName, string propertyDescription, Texture defaultTexture, TextureType defaultTextureType, HideState hidden, ModifiableState modifiableState) |
|||
: base(propertyName, propertyDescription, hidden) |
|||
{ |
|||
m_DefaultTexture = defaultTexture; |
|||
m_DefaultTextureType = defaultTextureType; |
|||
m_Modifiable = modifiableState; |
|||
} |
|||
|
|||
public override string GetPropertyString() |
|||
{ |
|||
var result = new StringBuilder(); |
|||
if (hideState == HideState.Hidden) |
|||
result.Append("[HideInInspector] "); |
|||
if (m_Modifiable == ModifiableState.NonModifiable) |
|||
result.Append("[NonModifiableTextureData] "); |
|||
result.Append("[NoScaleOffset] "); |
|||
|
|||
result.Append(propertyName); |
|||
result.Append("(\""); |
|||
result.Append(propertyDescription); |
|||
result.Append("\", 2D) = \""); |
|||
result.Append(Enum.GetName(typeof(TextureType), m_DefaultTextureType).ToLower()); |
|||
result.Append("\" {}"); |
|||
return result.ToString(); |
|||
} |
|||
|
|||
public Texture defaultTexture |
|||
{ |
|||
get |
|||
{ |
|||
return m_DefaultTexture; |
|||
} |
|||
} |
|||
public ModifiableState modifiableState |
|||
{ |
|||
get |
|||
{ |
|||
return m_Modifiable; |
|||
} |
|||
} |
|||
} |
|||
} |
撰写
预览
正在加载...
取消
保存
Reference in new issue