浏览代码

[Mat Graph]Remove light functions and instead have multiple master nodes.

/main
Tim Cooper 8 年前
当前提交
39086dd7
共有 15 个文件被更改,包括 157 次插入254 次删除
  1. 4
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/DrawData/NodePreviewDrawData.cs
  2. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/MaterialGraphView.cs
  3. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/IntegrationTests/ShaderGenerationTest.cs
  4. 14
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/UnitTests/AbstractMaterialGraphTests.cs
  5. 4
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/UnitTests/Function1InputTests.cs
  6. 4
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/UnitTests/Function2InputTests.cs
  7. 4
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/UnitTests/Function3InputTests.cs
  8. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/UnitTests/MaterialGraphTests.cs
  9. 10
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/UnitTests/PixelShaderNodeTests.cs
  10. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Graphs/MaterialGraph.cs
  11. 57
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Graphs/PixelGraph.cs
  12. 275
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/PixelShaderNode.cs
  13. 22
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Util/ShaderGenerator.cs
  14. 9
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Light.meta

4
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/DrawData/NodePreviewDrawData.cs


protected virtual string GetPreviewShaderString()
{
// TODO: this is a workaround right now.
if (m_Node is PixelShaderNode)
if (m_Node is AbstractMasterNode)
var localNode = (PixelShaderNode)m_Node;
var localNode = (AbstractMasterNode)m_Node;
if (localNode == null)
return string.Empty;

2
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/MaterialGraphView.cs


return null;
List<PropertyGenerator.TextureInfo> configuredTextures;
var shaderString = ShaderGenerator.GenerateSurfaceShader(materialGraph.pixelMasterNode, new MaterialOptions(), materialGraph.name, false, out configuredTextures);
var shaderString = ShaderGenerator.GenerateSurfaceShader(materialGraph.masterNode, new MaterialOptions(), materialGraph.name, false, out configuredTextures);
File.WriteAllText(path, shaderString);
AssetDatabase.Refresh(); // Investigate if this is optimal

2
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/IntegrationTests/ShaderGenerationTest.cs


// Generate the shader
List<PropertyGenerator.TextureInfo> configuredTextures;
var shaderString = ShaderGenerator.GenerateSurfaceShader(materialGraph.pixelMasterNode, graphAsset.options, materialGraph.name, false, out configuredTextures);
var shaderString = ShaderGenerator.GenerateSurfaceShader(materialGraph.masterNode, graphAsset.options, materialGraph.name, false, out configuredTextures);
m_Shader = ShaderUtil.CreateShaderAsset(shaderString);
m_Shader.hideFlags = HideFlags.HideAndDontSave;
Assert.IsNotNull(m_Shader, "Shader Generation Failed");

14
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/UnitTests/AbstractMaterialGraphTests.cs


var graph = new PixelGraph();
Assert.AreEqual(0, graph.GetNodes<AbstractMaterialNode>().Count());
var psn = new PixelShaderNode();
var psn = new MetallicMasterNode();
Assert.IsInstanceOf(typeof(PixelShaderNode), graph.GetNodes<AbstractMaterialNode>().FirstOrDefault());
Assert.IsNotNull(graph.pixelMasterNode);
Assert.AreEqual(1, graph.activeNodes.Count());
Assert.IsInstanceOf(typeof(MetallicMasterNode), graph.GetNodes<AbstractMaterialNode>().FirstOrDefault());
Assert.IsNotNull(graph.masterNode);
Assert.AreEqual(1, graph.GetNodes<INode>().Count());
public void TestCanOnlyAddOnePixelShaderNode()
public void TestCanAddOnePixelShaderNode()
var psn = new PixelShaderNode();
var psn = new MetallicMasterNode();
var psn2 = new PixelShaderNode();
var psn2 = new MetallicMasterNode();
graph.AddNode(psn2);
Assert.AreEqual(0, graph.edges.Count());
Assert.AreEqual(1, graph.GetNodes<AbstractMaterialNode>().Count());

4
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/UnitTests/Function1InputTests.cs


m_Graph.AddNode(m_InputOne);
m_Graph.AddNode(m_TestNode);
m_Graph.AddNode(new PixelShaderNode());
m_Graph.AddNode(new MetallicMasterNode());
m_Graph.Connect(m_TestNode.GetSlotReference(Function1Input.OutputSlotId), m_Graph.pixelMasterNode.GetSlotReference(BaseLightFunction.NormalSlotId));
m_Graph.Connect(m_TestNode.GetSlotReference(Function1Input.OutputSlotId), m_Graph.masterNode.GetSlotReference(MetallicMasterNode.NormalSlotId));
}
[Test]

4
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/UnitTests/Function2InputTests.cs


m_Graph.AddNode(m_InputOne);
m_Graph.AddNode(m_InputTwo);
m_Graph.AddNode(m_TestNode);
m_Graph.AddNode(new PixelShaderNode());
m_Graph.AddNode(new MetallicMasterNode());
m_InputOne.value = 0.2f;
m_InputTwo.value = 0.3f;

m_Graph.Connect(m_TestNode.GetSlotReference(Function2Input.OutputSlotId), m_Graph.pixelMasterNode.GetSlotReference(BaseLightFunction.NormalSlotId));
m_Graph.Connect(m_TestNode.GetSlotReference(Function2Input.OutputSlotId), m_Graph.masterNode.GetSlotReference(MetallicMasterNode.NormalSlotId));
}
[Test]

4
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/UnitTests/Function3InputTests.cs


m_Graph.AddNode(m_InputTwo);
m_Graph.AddNode(m_InputThree);
m_Graph.AddNode(m_TestNode);
m_Graph.AddNode(new PixelShaderNode());
m_Graph.AddNode(new MetallicMasterNode());
m_InputOne.value = 0.2f;
m_InputTwo.value = 0.3f;

m_Graph.Connect(m_InputTwo.GetSlotReference(Vector1Node.OutputSlotId), m_TestNode.GetSlotReference(Function3Input.InputSlot2Id));
m_Graph.Connect(m_InputThree.GetSlotReference(Vector1Node.OutputSlotId), m_TestNode.GetSlotReference(Function3Input.InputSlot3Id));
m_Graph.Connect(m_TestNode.GetSlotReference(Function3Input.OutputSlotId), m_Graph.pixelMasterNode.GetSlotReference(BaseLightFunction.NormalSlotId));
m_Graph.Connect(m_TestNode.GetSlotReference(Function3Input.OutputSlotId), m_Graph.masterNode.GetSlotReference(MetallicMasterNode.NormalSlotId));
}
[Test]

2
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/UnitTests/MaterialGraphTests.cs


graph.PostCreate();
Assert.AreEqual(1, graph.currentGraph.GetNodes<AbstractMaterialNode>().Count());
Assert.IsInstanceOf(typeof(PixelShaderNode), graph.currentGraph.GetNodes<AbstractMaterialNode>().FirstOrDefault());
Assert.IsInstanceOf(typeof(MetallicMasterNode), graph.currentGraph.GetNodes<AbstractMaterialNode>().FirstOrDefault());
}
}
}

10
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/UnitTests/PixelShaderNodeTests.cs


using System;
using System.Linq;
using NUnit.Framework;
using UnityEngine;
using UnityEngine.Graphing;

private PixelGraph m_Graph;
private Vector1Node m_InputOne;
private AbsoluteNode m_Abs;
private PixelShaderNode m_PixelNode;
private MetallicMasterNode m_PixelNode;
//TODO: Do not check in
/*
[TestFixtureSetUp]
public void RunBeforeAnyTests()
{

m_Graph = new PixelGraph();
m_InputOne = new Vector1Node();
m_Abs = new AbsoluteNode();
m_PixelNode = new PixelShaderNode();
m_PixelNode.lightFunction = new PBRMetalicLightFunction();
m_Graph.AddNode(m_InputOne);
m_Graph.AddNode(m_PixelNode);

m_Graph.Connect(m_InputOne.GetSlotReference(Vector1Node.OutputSlotId), m_Abs.GetSlotReference(Function1Input.InputSlotId));
m_Graph.Connect(m_Abs.GetSlotReference(Function1Input.OutputSlotId), m_PixelNode.GetSlotReference(PBRMetalicLightFunction.AlbedoSlotId));
}
[Test]
public void TestNodeGeneratesLightFuntionProperly()
{

var lightingFuncs = PixelShaderNode.GetLightFunctions();
Assert.AreEqual(1, lightingFuncs.OfType<PBRMetalicLightFunction>().Count());
Assert.AreEqual(1, lightingFuncs.OfType<PBRSpecularLightFunction>().Count());
}
}*/
}
}

2
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Graphs/MaterialGraph.cs


public void PostCreate()
{
m_PixelGraph.AddNode(new PixelShaderNode());
//m_PixelGraph.AddNode(new PixelShaderNode());
}
}
}

57
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Graphs/PixelGraph.cs


using System;
using System.Collections.Generic;
using UnityEngine.Graphing;
namespace UnityEngine.MaterialGraph
{

[NonSerialized]
private PixelShaderNode m_PixelMasterNode;
public PixelShaderNode pixelMasterNode
public AbstractMasterNode masterNode
get
{
// find existing node
if (m_PixelMasterNode == null)
m_PixelMasterNode = GetNodes<AbstractMaterialNode>().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>();
}
get { return GetNodes<AbstractMasterNode>().FirstOrDefault(); }
get { return "Graph_ " + pixelMasterNode.GetVariableNameForNode(); }
get { return "Graph_ " + masterNode.GetVariableNameForNode(); }
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 Material GetMaterial()
{
if (pixelMasterNode == null)
return null;
var material = pixelMasterNode.previewMaterial;
AbstractMaterialNode.UpdateMaterialProperties(pixelMasterNode, material);
return material;
}*/
}
}

275
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/PixelShaderNode.cs


using System;
using System.Collections.Generic;
using System.Reflection;
[Serializable]
[Title("Pixel Shader Node")]
public class PixelShaderNode : AbstractMaterialNode, IGeneratesBodyCode
[Serializable][Title("Math/Add Node")]
public abstract class AbstractSurfaceMasterNode : AbstractMasterNode
[SerializeField]
private SerializationHelper.JSONSerializedElement m_SerializedLightFunction;
[NonSerialized]
private BaseLightFunction m_LightFunction = new PBRMetalicLightFunction();
private static List<BaseLightFunction> s_LightFunctions;
public BaseLightFunction lightFunction
{
get { return m_LightFunction; }
set
{
if (m_LightFunction == value)
return;
m_LightFunction = value;
UpdateNodeAfterDeserialization();
}
}
public PixelShaderNode()
{
name = "PixelMaster";
UpdateNodeAfterDeserialization();
}
public sealed override void UpdateNodeAfterDeserialization()
{
m_LightFunction.DoSlotsForConfiguration(this);
}
protected override bool generateDefaultInputs { get { return false; } }
// public override bool canDeleteNode { get { return false; } }
public static List<BaseLightFunction> GetLightFunctions()
{
if (s_LightFunctions == null)
{
s_LightFunctions = new List<BaseLightFunction>();
foreach (Type type in Assembly.GetAssembly(typeof(BaseLightFunction)).GetTypes())
{
if (type.IsClass && !type.IsAbstract && (type.IsSubclassOf(typeof(BaseLightFunction))))
{
var func = Activator.CreateInstance(type) as BaseLightFunction;
s_LightFunctions.Add(func);
}
}
}
return s_LightFunctions;
}
public virtual void GenerateLightFunction(ShaderGenerator visitor)
{
lightFunction.GenerateLightFunctionName(visitor);
lightFunction.GenerateLightFunctionBody(visitor);
}
public const string AlbedoSlotName = "Albedo";
public const string NormalSlotName = "Normal";
public const string EmissionSlotName = "Emission";
public const string SmoothnessSlotName = "Smoothness";
public const string OcclusionSlotName = "Occlusion";
public const string AlphaSlotName = "Alpha";
public void GenerateSurfaceOutput(ShaderGenerator visitor)
{
lightFunction.GenerateSurfaceOutputStructureName(visitor);
}
public const int AlbedoSlotId = 0;
public const int NormalSlotId = 1;
public const int EmissionSlotId = 3;
public const int SmoothnessSlotId = 4;
public const int OcclusionSlotId = 5;
public const int AlphaSlotId = 6;
public void GenerateNodeCode(ShaderGenerator shaderBody, GenerationMode generationMode)
public override void GenerateNodeCode(ShaderGenerator shaderBody, GenerationMode generationMode)
var firstPassSlotId = lightFunction.GetFirstPassSlotId();
// do the normal slot first so that it can be used later in the shader :)
var firstPassSlot = FindInputSlot<MaterialSlot>(firstPassSlotId);
NodeUtils.DepthFirstCollectNodesFromNode(nodes, this, firstPassSlotId, NodeUtils.IncludeSelf.Exclude);
for (int index = 0; index < nodes.Count; index++)
{
var node = nodes[index];
if (node is IGeneratesBodyCode)
(node as IGeneratesBodyCode).GenerateNodeCode(shaderBody, generationMode);
}
foreach (var edge in owner.GetEdges(firstPassSlot.slotReference))
{
var outputRef = edge.outputSlot;
var fromNode = owner.GetNodeFromGuid<AbstractMaterialNode>(outputRef.nodeGuid);
if (fromNode == null)
continue;
shaderBody.AddShaderChunk("o." + firstPassSlot.shaderOutputName + " = " + fromNode.GetVariableNameForSlot(outputRef.slotId) + ";", true);
}
// track the last index of nodes... they have already been processed :)
int pass2StartIndex = nodes.Count;
for (var i = pass2StartIndex; i < nodes.Count; i++)
for (var i = 0; i < nodes.Count; i++)
{
var node = nodes[i];
if (node is IGeneratesBodyCode)

foreach (var slot in GetInputSlots<MaterialSlot>())
{
if (slot == firstPassSlot)
continue;
foreach (var edge in owner.GetEdges(slot.slotReference))
{
var outputRef = edge.outputSlot;

}
}
}
}
/* public override float GetNodeUIHeight(float width)
{
return EditorGUIUtility.singleLineHeight;
}
[Serializable]
[Title("Master/Metallic")]
public class MetallicMasterNode : AbstractSurfaceMasterNode
{
public const string MetallicSlotName = "Metallic";
public const int MetallicSlotId = 2;
public override GUIModificationType NodeUI(Rect drawArea)
{
var lightFunctions = GetLightFunctions();
var lightFunction = GetLightFunction();
public const string LightFunctionName = "Standard";
public const string SurfaceOutputStructureName = "SurfaceOutputStandard";
public MetallicMasterNode()
{
name = "MetallicMasterNode";
UpdateNodeAfterDeserialization();
}
int lightFuncIndex = 0;
if (lightFunction != null)
lightFuncIndex = lightFunctions.IndexOf(lightFunction);
public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new MaterialSlot(AlbedoSlotId, AlbedoSlotName, AlbedoSlotName, SlotType.Input, SlotValueType.Vector3, Vector4.zero));
AddSlot(new MaterialSlot(NormalSlotId, NormalSlotName, NormalSlotName, SlotType.Input, SlotValueType.Vector3, Vector4.zero));
AddSlot(new MaterialSlot(EmissionSlotId, EmissionSlotName, EmissionSlotName, SlotType.Input, SlotValueType.Vector3, Vector4.zero));
AddSlot(new MaterialSlot(MetallicSlotId, MetallicSlotName, MetallicSlotName, SlotType.Input, SlotValueType.Vector1, Vector4.zero));
AddSlot(new MaterialSlot(SmoothnessSlotId, SmoothnessSlotName, SmoothnessSlotName, SlotType.Input, SlotValueType.Vector1, Vector4.zero));
AddSlot(new MaterialSlot(OcclusionSlotId, OcclusionSlotName, OcclusionSlotName, SlotType.Input, SlotValueType.Vector1, Vector4.zero));
AddSlot(new MaterialSlot(AlphaSlotId, AlphaSlotName, AlphaSlotName, SlotType.Input, SlotValueType.Vector1, Vector4.zero));
EditorGUI.BeginChangeCheck();
lightFuncIndex = EditorGUI.Popup(new Rect(drawArea.x, drawArea.y, drawArea.width, EditorGUIUtility.singleLineHeight), lightFuncIndex, lightFunctions.Select(x => x.GetLightFunctionName()).ToArray(), EditorStyles.popup);
lightFunctionClassName = lightFunctions[lightFuncIndex].GetType().ToString();
if (EditorGUI.EndChangeCheck())
{
var function = GetLightFunction();
function.DoSlotsForConfiguration(this);
owner.ValidateGraph();
return GUIModificationType.ModelChanged;
}
return GUIModificationType.None;
}*/
// clear out slot names that do not match the slots
// we support
RemoveSlotsNameNotMatching(
new[]
{
AlbedoSlotId,
NormalSlotId,
EmissionSlotId,
MetallicSlotId,
SmoothnessSlotId,
OcclusionSlotId,
AlphaSlotId
});
}
public override void GenerateSurfaceOutput(ShaderGenerator surfaceOutput)
{
surfaceOutput.AddPragmaChunk(SurfaceOutputStructureName);
}
public override IEnumerable<ISlot> GetInputsWithNoConnection()
public override void GenerateLightFunction(ShaderGenerator lightFunction)
return new List<ISlot>();
lightFunction.AddPragmaChunk(LightFunctionName);
}
public override bool hasPreview
[Serializable]
[Title("Master/Specular")]
public class SpecularMasterNode : AbstractSurfaceMasterNode
{
public const string SpecularSlotName = "Specular";
public const int SpecularSlotId = 2;
public const string LightFunctionName = "StandardSpecular";
public const string SurfaceOutputStructureName = "SurfaceOutputStandardSpecular";
public SpecularMasterNode()
get { return true; }
name = "SpecularMasterNode";
UpdateNodeAfterDeserialization();
public override void OnBeforeSerialize()
public sealed override void UpdateNodeAfterDeserialization()
base.OnBeforeSerialize();
try
{
m_SerializedLightFunction = SerializationHelper.Serialize(m_LightFunction);
}
catch (Exception e)
{
Debug.LogException(e);
}
AddSlot(new MaterialSlot(AlbedoSlotId, AlbedoSlotName, AlbedoSlotName, SlotType.Input, SlotValueType.Vector3, Vector4.zero));
AddSlot(new MaterialSlot(NormalSlotId, NormalSlotName, NormalSlotName, SlotType.Input, SlotValueType.Vector3, Vector4.zero));
AddSlot(new MaterialSlot(EmissionSlotId, EmissionSlotName, EmissionSlotName, SlotType.Input, SlotValueType.Vector3, Vector4.zero));
AddSlot(new MaterialSlot(SpecularSlotId, SpecularSlotName, SpecularSlotName, SlotType.Input, SlotValueType.Vector1, Vector4.zero));
AddSlot(new MaterialSlot(SmoothnessSlotId, SmoothnessSlotName, SmoothnessSlotName, SlotType.Input, SlotValueType.Vector1, Vector4.zero));
AddSlot(new MaterialSlot(OcclusionSlotId, OcclusionSlotName, OcclusionSlotName, SlotType.Input, SlotValueType.Vector1, Vector4.zero));
AddSlot(new MaterialSlot(AlphaSlotId, AlphaSlotName, AlphaSlotName, SlotType.Input, SlotValueType.Vector1, Vector4.zero));
// clear out slot names that do not match the slots
// we support
RemoveSlotsNameNotMatching(
new[]
{
AlbedoSlotId,
NormalSlotId,
EmissionSlotId,
SpecularSlotId,
SmoothnessSlotId,
OcclusionSlotId,
AlphaSlotId
});
public override void OnAfterDeserialize()
public override void GenerateSurfaceOutput(ShaderGenerator surfaceOutput)
try
{
m_LightFunction = SerializationHelper.Deserialize<BaseLightFunction>(m_SerializedLightFunction);
}
catch (Exception e)
{
Debug.LogException(e);
}
surfaceOutput.AddPragmaChunk(SurfaceOutputStructureName);
}
base.OnAfterDeserialize();
public override void GenerateLightFunction(ShaderGenerator lightFunction)
{
lightFunction.AddPragmaChunk(LightFunctionName);
}
/*
protected override bool UpdatePreviewShader()
[Serializable]
public abstract class AbstractMasterNode : AbstractMaterialNode, IGeneratesBodyCode
{
protected override bool generateDefaultInputs { get { return false; } }
public override IEnumerable<ISlot> GetInputsWithNoConnection()
if (hasError)
return false;
return new List<ISlot>();
}
var shaderName = "Hidden/PreviewShader/" + name + "_" + guid.ToString().Replace("-","_");
List<PropertyGenerator.TextureInfo> defaultTextures;
//TODO: Fix me
var resultShader = string.Empty;//ShaderGenerator.GenerateSurfaceShader(materialGraphOwner.owner, shaderName, true, out defaultTextures);
m_GeneratedShaderMode = PreviewMode.Preview3D;
hasError = !InternalUpdatePreviewShader(resultShader);
return true;
}*/
public override bool hasPreview
{
get { return true; }
}
public abstract void GenerateNodeCode(ShaderGenerator visitor, GenerationMode generationMode);
public abstract void GenerateSurfaceOutput (ShaderGenerator surfaceOutput);
public abstract void GenerateLightFunction(ShaderGenerator lightFunction);
}
}

22
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Util/ShaderGenerator.cs


}
private static void GenerateSurfaceShaderInternal(
PixelShaderNode pixelNode,
ShaderGenerator shaderBody,
AbstractMasterNode masterNode,
ShaderGenerator shaderBody,
ShaderGenerator nodeFunction,
PropertyGenerator shaderProperties,
ShaderGenerator propertyUsages,
ShaderGenerator vertexShader,
ShaderGenerator nodeFunction,
PropertyGenerator shaderProperties,
ShaderGenerator propertyUsages,
ShaderGenerator vertexShader,
pixelNode.GenerateLightFunction(lightFunction);
pixelNode.GenerateSurfaceOutput(surfaceOutput);
masterNode.GenerateSurfaceOutput(surfaceOutput);
masterNode.GenerateLightFunction(lightFunction);
NodeUtils.DepthFirstCollectNodesFromNode(activeNodes, pixelNode);
NodeUtils.DepthFirstCollectNodesFromNode(activeNodes, masterNode);
var activeMaterialNodes = activeNodes.OfType<AbstractMaterialNode>();
foreach (var node in activeMaterialNodes)

}
}
pixelNode.GenerateNodeCode(shaderBody, genMode);
masterNode.GenerateNodeCode(shaderBody, genMode);
public static string GenerateSurfaceShader(PixelShaderNode node, MaterialOptions options, string shaderName, bool isPreview, out List<PropertyGenerator.TextureInfo> configuredTextures)
public static string GenerateSurfaceShader(AbstractMasterNode node, MaterialOptions options, string shaderName, bool isPreview, out List<PropertyGenerator.TextureInfo> configuredTextures)
{
var templateLocation = GetTemplatePath("shader.template");

9
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Light.meta


fileFormatVersion: 2
guid: 9558d2a8413064e40b02dc7e71a6925f
folderAsset: yes
timeCreated: 1464264921
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存