Tim Cooper
9 年前
当前提交
25971c00
共有 25 个文件被更改,包括 105 次插入 和 600 次删除
-
8MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/DrawableNode.cs
-
28MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/GraphEditWindow.cs
-
16MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Runtime/Implementation/SerializableGraph.cs
-
14MaterialGraphProject/Assets/UnityShaderEditor/Editor/AssetCallbacks/CreateShaderSubGraph.cs
-
2MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/MaterialGraphEditWindow.cs
-
7MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/NodeDrawers/AbstractMaterialNodeUI.cs
-
2MaterialGraphProject/Assets/UnityShaderEditor/Runtime/SubGraph/SubGraphInputNode.cs
-
2MaterialGraphProject/Assets/UnityShaderEditor/Runtime/SubGraph/SubGraphOutputNode.cs
-
4MaterialGraphProject/Assets/UnityShaderEditor/Runtime/SubGraph/AbstractSubGraphIONode.cs
-
36MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/NodeDrawers/SubGraphIONodeUI.cs
-
12MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/NodeDrawers/SubGraphIONodeUI.cs.meta
-
56MaterialGraphProject/Assets/UnityShaderEditor/Runtime/AbstractMaterialGraph.cs
-
12MaterialGraphProject/Assets/UnityShaderEditor/Runtime/AbstractMaterialGraph.cs.meta
-
12MaterialGraphProject/Assets/UnityShaderEditor/Runtime/MaterialGraph.cs.meta
-
12MaterialGraphProject/Assets/UnityShaderEditor/Runtime/MaterialGraphAsset.cs.meta
-
12MaterialGraphProject/Assets/UnityShaderEditor/Runtime/MaterialOptions.cs.meta
-
12MaterialGraphProject/Assets/UnityShaderEditor/Runtime/PixelGraph.cs.meta
-
12MaterialGraphProject/Assets/UnityShaderEditor/Runtime/TitleAttribute.cs.meta
-
97MaterialGraphProject/Assets/UnityShaderEditor/Runtime/MaterialGraph.cs
-
36MaterialGraphProject/Assets/UnityShaderEditor/Runtime/MaterialGraphAsset.cs
-
201MaterialGraphProject/Assets/UnityShaderEditor/Runtime/MaterialOptions.cs
-
101MaterialGraphProject/Assets/UnityShaderEditor/Runtime/PixelGraph.cs
-
11MaterialGraphProject/Assets/UnityShaderEditor/Runtime/TitleAttribute.cs
-
0/MaterialGraphProject/Assets/UnityShaderEditor/Runtime/SubGraph/AbstractSubGraphIONode.cs.meta
-
0/MaterialGraphProject/Assets/UnityShaderEditor/Runtime/SubGraph/AbstractSubGraphIONode.cs
|
|||
using System.IO; |
|||
using UnityEditor.ProjectWindowCallback; |
|||
using UnityEngine.MaterialGraph; |
|||
/*public class CreateShaderSubGraph : EndNameEditActionCallback |
|||
public class CreateShaderSubGraph : EndNameEditAction |
|||
[MenuItem("Assets/Create/Shader Sub-Graph", false, 209)] |
|||
[MenuItem("Assets/Create/Shader Sub Graph", false, 208)] |
|||
"New Shader SubGraph.ShaderSubGraph", null, null); |
|||
"New Shader Sub-Graph.ShaderSubGraph", null, null); |
|||
var graph = CreateInstance<MaterialSubGraph>(); |
|||
var graph = CreateInstance<MaterialSubGraphAsset>(); |
|||
graph.AddSubAssetsToAsset(); |
|||
graph.PostCreate(); |
|||
}*/ |
|||
} |
|||
} |
|
|||
using UnityEditor.Graphing; |
|||
using UnityEditor.Graphing.Drawing; |
|||
using UnityEngine; |
|||
using UnityEngine.Graphing; |
|||
using UnityEngine.MaterialGraph; |
|||
|
|||
namespace UnityEditor.MaterialGraph |
|||
{ |
|||
[CustomNodeUI(typeof(AbstractSubGraphIONode))] |
|||
public class SubGraphIONodeUI : ICustomNodeUi |
|||
{ |
|||
private AbstractSubGraphIONode m_Node; |
|||
|
|||
public float GetNodeUiHeight(float width) |
|||
{ |
|||
return EditorGUIUtility.singleLineHeight; |
|||
} |
|||
|
|||
public GUIModificationType Render(Rect area) |
|||
{ |
|||
return GUIModificationType.None; |
|||
} |
|||
|
|||
|
|||
public void SetNode(INode node) |
|||
{ |
|||
if (node is AbstractSubGraphIONode) |
|||
m_Node = (AbstractSubGraphIONode) node; |
|||
} |
|||
|
|||
public float GetNodeWidth() |
|||
{ |
|||
return 100; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 266aca8675f91a74bb0441f8bcf8acb8 |
|||
timeCreated: 1465809586 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using UnityEngine.Graphing; |
|||
|
|||
namespace UnityEngine.MaterialGraph |
|||
{ |
|||
[Serializable] |
|||
public abstract class AbstractMaterialGraph : SerializableGraph |
|||
{ |
|||
|
|||
public IEnumerable<AbstractMaterialNode> materialNodes |
|||
{ |
|||
get { return nodes.OfType<AbstractMaterialNode>(); } |
|||
} |
|||
|
|||
public bool requiresRepaint |
|||
{ |
|||
get { return nodes.Any(x => x is IRequiresTime); } |
|||
} |
|||
|
|||
public override void AddNode(INode node) |
|||
{ |
|||
if (node is AbstractMaterialNode) |
|||
{ |
|||
base.AddNode(node); |
|||
} |
|||
else |
|||
{ |
|||
Debug.LogWarningFormat("Trying to add node {0} to Material graph, but it is not a {1}", node, typeof(AbstractMaterialNode)); |
|||
} |
|||
} |
|||
|
|||
public override bool RequiresConstantRepaint() |
|||
{ |
|||
return nodes.OfType<IRequiresTime>().Any(); |
|||
} |
|||
|
|||
/*public PreviewRenderUtility previewUtility |
|||
{ |
|||
get |
|||
{ |
|||
if (m_PreviewUtility == null) |
|||
{ |
|||
m_PreviewUtility = new PreviewRenderUtility(); |
|||
EditorUtility.SetCameraAnimateMaterials(m_PreviewUtility.m_Camera, true); |
|||
} |
|||
|
|||
return m_PreviewUtility; |
|||
} |
|||
} |
|||
|
|||
[NonSerialized] |
|||
private PreviewRenderUtility m_PreviewUtility;*/ |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 2b0e8711e6be02b46b0f59cdc792d962 |
|||
timeCreated: 1464601236 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: fb1baf5d764fd6543ae40a4772ed0299 |
|||
timeCreated: 1464601237 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 562bd27a5e73fc64d80a1d9d936ffbd5 |
|||
timeCreated: 1464601236 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 8ca34891049f83b43ba622e89782529d |
|||
timeCreated: 1464601236 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 2d360593fcc8fe74495305ba643d8770 |
|||
timeCreated: 1464601236 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 5c804f35a96ccb9408f04f818773a159 |
|||
timeCreated: 1464601236 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.IO; |
|||
using System.Linq; |
|||
|
|||
namespace UnityEngine.MaterialGraph |
|||
{ |
|||
[Serializable] |
|||
public class MaterialGraph |
|||
{ |
|||
[SerializeField] |
|||
private MaterialOptions m_MaterialOptions = new MaterialOptions(); |
|||
|
|||
[SerializeField] |
|||
private PixelGraph m_PixelGraph; |
|||
|
|||
[SerializeField] |
|||
private string m_Name; |
|||
|
|||
public string name |
|||
{ |
|||
get { return m_Name; } |
|||
set { m_Name = value; } |
|||
} |
|||
|
|||
public MaterialGraph() |
|||
{ |
|||
m_PixelGraph = new PixelGraph(); |
|||
} |
|||
|
|||
public MaterialOptions materialOptions |
|||
{ |
|||
get { return m_MaterialOptions; } |
|||
} |
|||
|
|||
public AbstractMaterialGraph currentGraph |
|||
{ |
|||
get { return m_PixelGraph; } |
|||
} |
|||
|
|||
/* |
|||
public Material GetMaterial() |
|||
{ |
|||
if (m_PixelGraph == null) |
|||
return null; |
|||
|
|||
return m_PixelGraph.GetMaterial(); |
|||
} |
|||
|
|||
public void ExportShader(string path) |
|||
{ |
|||
List<PropertyGenerator.TextureInfo> configuredTextures; |
|||
var shaderString = ShaderGenerator.GenerateSurfaceShader(this, name, false, out configuredTextures); |
|||
File.WriteAllText(path, shaderString); |
|||
AssetDatabase.Refresh(); // Investigate if this is optimal
|
|||
|
|||
var shader = AssetDatabase.LoadAssetAtPath(path, typeof(Shader)) as Shader; |
|||
if (shader == null) |
|||
return; |
|||
|
|||
var shaderImporter = AssetImporter.GetAtPath(path) as ShaderImporter; |
|||
if (shaderImporter == null) |
|||
return; |
|||
|
|||
var textureNames = new List<string>(); |
|||
var textures = new List<Texture>(); |
|||
foreach (var textureInfo in configuredTextures.Where(x => x.modifiable)) |
|||
{ |
|||
var texture = EditorUtility.InstanceIDToObject(textureInfo.textureId) as Texture; |
|||
if (texture == null) |
|||
continue; |
|||
textureNames.Add(textureInfo.name); |
|||
textures.Add(texture); |
|||
} |
|||
shaderImporter.SetDefaultTextures(textureNames.ToArray(), textures.ToArray()); |
|||
|
|||
textureNames.Clear(); |
|||
textures.Clear(); |
|||
foreach (var textureInfo in configuredTextures.Where(x => !x.modifiable)) |
|||
{ |
|||
var texture = EditorUtility.InstanceIDToObject(textureInfo.textureId) as Texture; |
|||
if (texture == null) |
|||
continue; |
|||
textureNames.Add(textureInfo.name); |
|||
textures.Add(texture); |
|||
} |
|||
shaderImporter.SetNonModifiableTextures(textureNames.ToArray(), textures.ToArray()); |
|||
|
|||
shaderImporter.SaveAndReimport(); |
|||
}*/ |
|||
|
|||
public void PostCreate() |
|||
{ |
|||
m_PixelGraph.AddNode(new PixelShaderNode(m_PixelGraph)); |
|||
} |
|||
} |
|||
} |
|
|||
using System.Linq; |
|||
using UnityEngine.Graphing; |
|||
|
|||
namespace UnityEngine.MaterialGraph |
|||
{ |
|||
public class MaterialGraphAsset : ScriptableObject, IGraphAsset |
|||
{ |
|||
[SerializeField] |
|||
private MaterialGraph m_MaterialGraph; |
|||
|
|||
public IGraph graph |
|||
{ |
|||
get { return m_MaterialGraph.currentGraph; } |
|||
} |
|||
|
|||
public bool shouldRepaint |
|||
{ |
|||
get { return graph.nodes.OfType<IRequiresTime>().Any(); } |
|||
} |
|||
|
|||
public ScriptableObject GetScriptableObject() |
|||
{ |
|||
return this; |
|||
} |
|||
|
|||
public Material GetMaterial() |
|||
{ |
|||
return null; |
|||
} |
|||
|
|||
public void PostCreate() |
|||
{ |
|||
m_MaterialGraph.PostCreate(); |
|||
} |
|||
} |
|||
} |
|
|||
using System; |
|||
using UnityEngine; |
|||
|
|||
namespace UnityEngine.MaterialGraph |
|||
{ |
|||
[Serializable] |
|||
public class MaterialOptions |
|||
{ |
|||
public enum BlendMode |
|||
{ |
|||
One, |
|||
Zero, |
|||
SrcColor, |
|||
SrcAlpha, |
|||
DstColor, |
|||
DstAlpha, |
|||
OneMinusSrcColor, |
|||
OneMinusSrcAlpha, |
|||
OneMinusDstColor, |
|||
OneMinusDstAlpha, |
|||
} |
|||
|
|||
public enum CullMode |
|||
{ |
|||
Back, |
|||
Front, |
|||
Off |
|||
} |
|||
|
|||
public enum ZTest |
|||
{ |
|||
Less, |
|||
Greater, |
|||
LEqual, |
|||
GEqual, |
|||
Equal, |
|||
NotEqual, |
|||
Always |
|||
} |
|||
|
|||
public enum ZWrite |
|||
{ |
|||
On, |
|||
Off |
|||
} |
|||
|
|||
public enum RenderQueue |
|||
{ |
|||
Background, |
|||
Geometry, |
|||
Transparent, |
|||
Overlay, |
|||
} |
|||
|
|||
public enum RenderType |
|||
{ |
|||
Opaque, |
|||
Transparent, |
|||
TransparentCutout, |
|||
Background, |
|||
Overlay |
|||
} |
|||
|
|||
[SerializeField] |
|||
private BlendMode m_SrcBlend; |
|||
|
|||
[SerializeField] |
|||
private BlendMode m_DstBlend; |
|||
|
|||
[SerializeField] |
|||
private CullMode m_CullMode; |
|||
|
|||
[SerializeField] |
|||
private ZTest m_ZTest; |
|||
|
|||
[SerializeField] |
|||
private ZWrite m_ZWrite; |
|||
|
|||
[SerializeField] |
|||
private RenderQueue m_RenderQueue; |
|||
|
|||
[SerializeField] |
|||
private RenderType m_RenderType; |
|||
|
|||
[SerializeField] |
|||
private bool m_ShadowPass; |
|||
|
|||
[SerializeField] |
|||
private bool m_FullForwardShadows; |
|||
|
|||
[SerializeField] |
|||
private bool m_NoAmbient; |
|||
|
|||
[SerializeField] |
|||
private bool m_NoVertexLights; |
|||
|
|||
[SerializeField] |
|||
private bool m_NoLightmaps; |
|||
|
|||
[SerializeField] |
|||
private bool m_NoDirLightmap; |
|||
|
|||
[SerializeField] |
|||
private bool m_NoForwardAdd; |
|||
|
|||
[SerializeField] |
|||
private bool m_ApproxView; |
|||
|
|||
[SerializeField] |
|||
private bool m_HalfAsView; |
|||
|
|||
[SerializeField] |
|||
private bool m_Expanded; |
|||
|
|||
public void Init() |
|||
{ |
|||
srcBlend = BlendMode.One; |
|||
dstBlend = BlendMode.Zero; |
|||
cullMode = CullMode.Back; |
|||
zTest = ZTest.LEqual; |
|||
zWrite = ZWrite.On; |
|||
renderQueue = RenderQueue.Geometry; |
|||
renderType = RenderType.Opaque; |
|||
shadowPass = false; |
|||
fullForwardShadows = false; |
|||
noAmbient = false; |
|||
noVertexLights = false; |
|||
noLightmaps = false; |
|||
noDirLightmap = false; |
|||
noForwardAdd = false; |
|||
approxView = false; |
|||
halfAsView = false; |
|||
} |
|||
|
|||
public void GetTags(ShaderGenerator visitor) |
|||
{ |
|||
visitor.AddShaderChunk("Tags {", false); |
|||
visitor.Indent(); |
|||
visitor.AddShaderChunk("\"RenderType\"=\"" + renderType + "\"", false); |
|||
visitor.AddShaderChunk("\"Queue\"=\"" + renderQueue + "\"", false); |
|||
visitor.Deindent(); |
|||
visitor.AddShaderChunk("}", false); |
|||
} |
|||
|
|||
public void GetBlend(ShaderGenerator visitor) |
|||
{ |
|||
visitor.AddShaderChunk("Blend " + srcBlend + " " + dstBlend, false); |
|||
} |
|||
|
|||
public void GetCull(ShaderGenerator visitor) |
|||
{ |
|||
visitor.AddShaderChunk("Cull " + cullMode, false); |
|||
} |
|||
|
|||
public void GetDepthWrite(ShaderGenerator visitor) |
|||
{ |
|||
visitor.AddShaderChunk("ZWrite " + zWrite, false); |
|||
} |
|||
|
|||
public void GetDepthTest(ShaderGenerator visitor) |
|||
{ |
|||
visitor.AddShaderChunk("ZTest " + zTest, false); |
|||
} |
|||
|
|||
/*private Vector2 m_ScrollPos; |
|||
public void DoGUI() |
|||
{ |
|||
GUILayout.BeginVertical(); |
|||
m_Expanded = MaterialGraphStyles.Header("Options", m_Expanded); |
|||
|
|||
if (m_Expanded) |
|||
{ |
|||
srcBlend = (BlendMode) EditorGUILayout.EnumPopup("Src Blend", srcBlend); |
|||
dstBlend = (BlendMode) EditorGUILayout.EnumPopup("Dst Blend", dstBlend); |
|||
cullMode = (CullMode) EditorGUILayout.EnumPopup("Cull Mode", cullMode); |
|||
zTest = (ZTest) EditorGUILayout.EnumPopup("Z Test", zTest); |
|||
zWrite = (ZWrite) EditorGUILayout.EnumPopup("Z Write", zWrite); |
|||
renderQueue = (RenderQueue) EditorGUILayout.EnumPopup("Render Queue", renderQueue); |
|||
renderType = (RenderType) EditorGUILayout.EnumPopup("Render Type", renderType); |
|||
} |
|||
GUILayout.EndVertical(); |
|||
}*/ |
|||
|
|||
public BlendMode srcBlend { get { return m_SrcBlend; } set { m_SrcBlend = value; } } |
|||
public BlendMode dstBlend { get { return m_DstBlend; } set { m_DstBlend = value; } } |
|||
public CullMode cullMode { get { return m_CullMode; } set { m_CullMode = value; } } |
|||
public ZTest zTest { get { return m_ZTest; } set { m_ZTest = value; } } |
|||
public ZWrite zWrite { get { return m_ZWrite; } set { m_ZWrite = value; } } |
|||
public RenderQueue renderQueue { get { return m_RenderQueue; } set { m_RenderQueue = value; } } |
|||
public RenderType renderType { get { return m_RenderType; } set { m_RenderType = value; } } |
|||
public bool shadowPass { get { return m_ShadowPass; } set { m_ShadowPass = value; } } |
|||
public bool fullForwardShadows { get { return m_FullForwardShadows; } set { m_FullForwardShadows = value; } } |
|||
public bool noAmbient { get { return m_NoAmbient; } set { m_NoAmbient = value; } } |
|||
public bool noVertexLights { get { return m_NoVertexLights; } set { m_NoVertexLights = value; } } |
|||
public bool noLightmaps { get { return m_NoLightmaps; } set { m_NoLightmaps = value; } } |
|||
public bool noDirLightmap { get { return m_NoDirLightmap; } set { m_NoDirLightmap = value; } } |
|||
public bool noForwardAdd { get { return m_NoForwardAdd; } set { m_NoForwardAdd = value; } } |
|||
public bool approxView { get { return m_ApproxView; } set { m_ApproxView = value; } } |
|||
public bool halfAsView { get { return m_HalfAsView; } set { m_HalfAsView = value; } } |
|||
} |
|||
} |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using UnityEngine.Graphing; |
|||
|
|||
namespace UnityEngine.MaterialGraph |
|||
{ |
|||
[Serializable] |
|||
public class PixelGraph : AbstractMaterialGraph |
|||
{ |
|||
[NonSerialized] |
|||
private PixelShaderNode m_PixelMasterNode; |
|||
|
|||
public PixelShaderNode pixelMasterNode |
|||
{ |
|||
get |
|||
{ |
|||
// find existing node
|
|||
if (m_PixelMasterNode == null) |
|||
m_PixelMasterNode = nodes.FirstOrDefault(x => x.GetType() == typeof(PixelShaderNode)) as PixelShaderNode; |
|||
|
|||
return m_PixelMasterNode; |
|||
} |
|||
} |
|||
|
|||
[NonSerialized] |
|||
private List<INode> m_ActiveNodes = new List<INode>(); |
|||
public IEnumerable<AbstractMaterialNode> activeNodes |
|||
{ |
|||
get |
|||
{ |
|||
m_ActiveNodes.Clear(); |
|||
NodeUtils.DepthFirstCollectNodesFromNode(m_ActiveNodes, pixelMasterNode); |
|||
return m_ActiveNodes.OfType<AbstractMaterialNode>(); |
|||
} |
|||
} |
|||
|
|||
public override void OnAfterDeserialize() |
|||
{ |
|||
base.OnAfterDeserialize(); |
|||
m_PixelMasterNode = null; |
|||
} |
|||
|
|||
public override void AddNode(INode node) |
|||
{ |
|||
if (pixelMasterNode != null && node is PixelShaderNode) |
|||
{ |
|||
Debug.LogWarning("Attempting to add second PixelShaderNode to PixelGraph. This is not allowed."); |
|||
return; |
|||
} |
|||
base.AddNode(node); |
|||
} |
|||
|
|||
public static void GenerateSurfaceShader( |
|||
PixelShaderNode pixelNode, |
|||
ShaderGenerator shaderBody, |
|||
ShaderGenerator inputStruct, |
|||
ShaderGenerator lightFunction, |
|||
ShaderGenerator surfaceOutput, |
|||
ShaderGenerator nodeFunction, |
|||
PropertyGenerator shaderProperties, |
|||
ShaderGenerator propertyUsages, |
|||
ShaderGenerator vertexShader, |
|||
bool isPreview) |
|||
{ |
|||
pixelNode.GenerateLightFunction(lightFunction); |
|||
pixelNode.GenerateSurfaceOutput(surfaceOutput); |
|||
|
|||
var genMode = isPreview ? GenerationMode.Preview3D : GenerationMode.SurfaceShader; |
|||
|
|||
var activeNodes = new List<INode>(); |
|||
NodeUtils.DepthFirstCollectNodesFromNode(activeNodes, pixelNode); |
|||
var activeMaterialNodes = activeNodes.OfType<AbstractMaterialNode>(); |
|||
|
|||
foreach (var node in activeMaterialNodes) |
|||
{ |
|||
if (node is IGeneratesFunction) (node as IGeneratesFunction).GenerateNodeFunction(nodeFunction, genMode); |
|||
if (node is IGeneratesVertexToFragmentBlock) (node as IGeneratesVertexToFragmentBlock).GenerateVertexToFragmentBlock(inputStruct, genMode); |
|||
if (node is IGeneratesVertexShaderBlock) (node as IGeneratesVertexShaderBlock).GenerateVertexShaderBlock(vertexShader, genMode); |
|||
|
|||
if (node is IGenerateProperties) |
|||
{ |
|||
(node as IGenerateProperties).GeneratePropertyBlock(shaderProperties, genMode); |
|||
(node as IGenerateProperties).GeneratePropertyUsages(propertyUsages, genMode, ConcreteSlotValueType.Vector4); |
|||
} |
|||
} |
|||
|
|||
pixelNode.GenerateNodeCode(shaderBody, genMode); |
|||
} |
|||
/* |
|||
public Material GetMaterial() |
|||
{ |
|||
if (pixelMasterNode == null) |
|||
return null; |
|||
|
|||
var material = pixelMasterNode.previewMaterial; |
|||
AbstractMaterialNode.UpdateMaterialProperties(pixelMasterNode, material); |
|||
return material; |
|||
}*/ |
|||
} |
|||
} |
|
|||
using System; |
|||
|
|||
namespace UnityEngine.MaterialGraph |
|||
{ |
|||
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Method | AttributeTargets.Class | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue)] |
|||
public class TitleAttribute : Attribute |
|||
{ |
|||
public string m_Title; |
|||
public TitleAttribute(string title) { m_Title = title; } |
|||
} |
|||
} |
撰写
预览
正在加载...
取消
保存
Reference in new issue