浏览代码

Merge remote-tracking branch 'origin/master' into graphview-styling-updates

# Conflicts:
#	MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/MaterialNodeView.cs
#	MaterialGraphProject/Assets/UnityShaderEditor/Editor/Resources/Styles/MaterialGraph.uss
#	MaterialGraphProject/UnityPackageManager/manifest.json
/main
mathieum-unity 7 年前
当前提交
d7f591a9
共有 25 个文件被更改,包括 610 次插入236 次删除
  1. 1
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Implementation/SerializableGraphObject.cs
  2. 322
      MaterialGraphProject/Assets/PartyPreview.ShaderGraph
  3. 14
      MaterialGraphProject/Assets/SRP/ScriptableRenderPipeline/Core/TextureCache.cs
  4. 105
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/AbstractMaterialGraph.cs
  5. 18
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/SlotValue.cs
  6. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/SubGraph/LayeredShaderGraph.cs
  7. 16
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Util/ShaderGenerator.cs
  8. 11
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/GraphInspectorView.cs
  9. 12
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/NodeEditorHeaderView.cs
  10. 7
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/MaterialGraphEditWindow.cs
  11. 12
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/PreviewManager.cs
  12. 4
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/GradientEdge.cs
  13. 14
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/GraphEditorView.cs
  14. 9
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/MaterialNodeView.cs
  15. 36
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/PreviewTextureView.cs
  16. 8
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/ToolbarView.cs
  17. 15
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Resources/Shaders/Checkerboard.shader
  18. 4
      MaterialGraphProject/Assets/graphs_PartyPreview.mat
  19. 2
      MaterialGraphProject/ProjectSettings/ProjectVersion.txt
  20. 193
      MaterialGraphProject/Assets/Beachball.ShaderGraph
  21. 7
      MaterialGraphProject/Assets/Beachball.ShaderGraph.meta
  22. 22
      MaterialGraphProject/Assets/Beachball.mat
  23. 8
      MaterialGraphProject/Assets/Beachball.mat.meta
  24. 4
      MaterialGraphProject/UnityPackageManager/manifest.json

1
MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Implementation/SerializableGraphObject.cs


public bool isDirty
{
get { return m_IsDirty; }
set { m_IsDirty = value; }
}
public void RegisterCompleteObjectUndo(string name)

322
MaterialGraphProject/Assets/PartyPreview.ShaderGraph
文件差异内容过多而无法显示
查看文件

14
MaterialGraphProject/Assets/SRP/ScriptableRenderPipeline/Core/TextureCache.cs


if (mismatch)
{
if (!Graphics.ConvertTexture(texture, 0, m_Cache, sliceIndex))
if (!UnityEngine.Graphics.ConvertTexture(texture, 0, m_Cache, sliceIndex))
{
Debug.LogErrorFormat(texture, "Unable to convert texture \"{0}\" to match renderloop settings ({1}x{2} {3})",
texture.name, m_Cache.width, m_Cache.height, m_Cache.format);

{
Graphics.CopyTexture(texture, 0, m_Cache, sliceIndex);
UnityEngine.Graphics.CopyTexture(texture, 0, m_Cache, sliceIndex);
}
}

for (int f = 0; f < 6; f++)
{
if (!Graphics.ConvertTexture(texture, f, m_Cache, 6 * sliceIndex + f))
if (!UnityEngine.Graphics.ConvertTexture(texture, f, m_Cache, 6 * sliceIndex + f))
{
failed = true;
break;

else
{
for (int f = 0; f < 6; f++)
Graphics.CopyTexture(texture, f, m_Cache, 6 * sliceIndex + f);
UnityEngine.Graphics.CopyTexture(texture, f, m_Cache, 6 * sliceIndex + f);
}
}
}

for (int m = 0; m < m_NumPanoMipLevels; m++)
{
m_CubeBlitMaterial.SetInt(m_CubeMipLevelPropName, Mathf.Min(m_NumMipLevels - 1, m));
Graphics.SetRenderTarget(m_StagingRTs[m]);
Graphics.Blit(null, m_CubeBlitMaterial, 0);
UnityEngine.Graphics.SetRenderTarget(m_StagingRTs[m]);
UnityEngine.Graphics.Blit(null, m_CubeBlitMaterial, 0);
Graphics.CopyTexture(m_StagingRTs[m], 0, 0, m_CacheNoCubeArray, sliceIndex, m);
UnityEngine.Graphics.CopyTexture(m_StagingRTs[m], 0, 0, m_CacheNoCubeArray, sliceIndex, m);
}
}

105
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/AbstractMaterialGraph.cs


return GetShader(null, GenerationMode.Preview, "hidden/preview", out configuredTextures, out previewMode, out outputIdProperty, ids);
}
protected static void GenerateSurfaceDescriptionStruct(ShaderGenerator surfaceDescriptionStruct, List<MaterialSlot> slots)
protected static void GenerateSurfaceDescriptionStruct(ShaderGenerator surfaceDescriptionStruct, List<MaterialSlot> slots, bool isMaster)
foreach (var slot in slots)
if (isMaster)
if (slot.isInputSlot)
surfaceDescriptionStruct.AddShaderChunk(string.Format("{0} {1};", AbstractMaterialNode.ConvertConcreteSlotValueTypeToString(AbstractMaterialNode.OutputPrecision.@float, slot.concreteValueType), slot.shaderOutputName), false);
else
surfaceDescriptionStruct.AddShaderChunk(string.Format("{0} {1};", AbstractMaterialNode.ConvertConcreteSlotValueTypeToString(AbstractMaterialNode.OutputPrecision.@float, slot.concreteValueType), ((AbstractMaterialNode) slot.owner).GetVariableNameForSlot(slot.id)), false);
}
surfaceDescriptionStruct.Deindent();
surfaceDescriptionStruct.AddShaderChunk("};", false);
foreach (var slot in slots)
{
if (slot.isInputSlot)
surfaceDescriptionStruct.AddShaderChunk(string.Format("{0} {1};", AbstractMaterialNode.ConvertConcreteSlotValueTypeToString(AbstractMaterialNode.OutputPrecision.@float, slot.concreteValueType), slot.shaderOutputName), false);
else
surfaceDescriptionStruct.AddShaderChunk(string.Format("{0} {1};", AbstractMaterialNode.ConvertConcreteSlotValueTypeToString(AbstractMaterialNode.OutputPrecision.@float, slot.concreteValueType), ((AbstractMaterialNode) slot.owner).GetVariableNameForSlot(slot.id)), false);
}
surfaceDescriptionStruct.Deindent();
surfaceDescriptionStruct.AddShaderChunk("};", false);
surfaceDescriptionStruct.AddShaderChunk("void ScaleSurfaceDescription(inout SurfaceDescription surface, float scale){", false);
surfaceDescriptionStruct.Indent();
foreach (var slot in slots)
{
if (slot.isInputSlot)
surfaceDescriptionStruct.AddShaderChunk(string.Format("surface.{0} = scale * surface.{0};", slot.shaderOutputName), false);
else
surfaceDescriptionStruct.AddShaderChunk(string.Format("surface.{0} = scale * surface.{0};", ((AbstractMaterialNode) slot.owner).GetVariableNameForSlot(slot.id)), false);
}
surfaceDescriptionStruct.Deindent();
surfaceDescriptionStruct.AddShaderChunk("};", false);
surfaceDescriptionStruct.AddShaderChunk("void ScaleSurfaceDescription(inout SurfaceDescription surface, float scale){", false);
surfaceDescriptionStruct.Indent();
foreach (var slot in slots)
{
if (slot.isInputSlot)
surfaceDescriptionStruct.AddShaderChunk(string.Format("surface.{0} = scale * surface.{0};", slot.shaderOutputName), false);
else
surfaceDescriptionStruct.AddShaderChunk(string.Format("surface.{0} = scale * surface.{0};", ((AbstractMaterialNode) slot.owner).GetVariableNameForSlot(slot.id)), false);
surfaceDescriptionStruct.AddShaderChunk("void AddSurfaceDescription(inout SurfaceDescription base, in SurfaceDescription add){", false);
surfaceDescriptionStruct.Indent();
foreach (var slot in slots)
{
if (slot.isInputSlot)
surfaceDescriptionStruct.AddShaderChunk(string.Format("base.{0} = base.{0} + add.{0};", slot.shaderOutputName), false);
else
surfaceDescriptionStruct.AddShaderChunk(string.Format("base.{0} = base.{0} + add.{0};", ((AbstractMaterialNode) slot.owner).GetVariableNameForSlot(slot.id)), false);
}
surfaceDescriptionStruct.Deindent();
surfaceDescriptionStruct.AddShaderChunk("};", false);
surfaceDescriptionStruct.AddShaderChunk("void AddSurfaceDescription(inout SurfaceDescription base, in SurfaceDescription add){", false);
surfaceDescriptionStruct.Indent();
foreach (var slot in slots)
else
if (slot.isInputSlot)
surfaceDescriptionStruct.AddShaderChunk(string.Format("base.{0} = base.{0} + add.{0};", slot.shaderOutputName), false);
else
surfaceDescriptionStruct.AddShaderChunk(string.Format("base.{0} = base.{0} + add.{0};", ((AbstractMaterialNode) slot.owner).GetVariableNameForSlot(slot.id)), false);
surfaceDescriptionStruct.AddShaderChunk("float4 PreviewOutput;", false);
}
surfaceDescriptionStruct.Deindent();
surfaceDescriptionStruct.AddShaderChunk("};", false);

ShaderGraphRequirements requirements,
GenerationMode mode,
string functionName = "PopulateSurfaceData",
string surfaceDescriptionName = "SurfaceDescription")
string surfaceDescriptionName = "SurfaceDescription",
FloatShaderProperty outputIdProperty = null,
Dictionary<Guid, int> ids = null)
{
if (graph == null)
return;

surfaceDescriptionFunction.AddShaderChunk(string.Format("{0} surface = ({0})0;", surfaceDescriptionName), false);
foreach (CoordinateSpace space in Enum.GetValues(typeof(CoordinateSpace)))
{

graph.CollectShaderProperties(shaderProperties, mode);
var currentId = -1;
foreach (var activeNode in activeNodeList.OfType<AbstractMaterialNode>())
{
if (activeNode is IGeneratesFunction)

if (masterNode == null && activeNode.hasPreview)
{
var outputSlot = activeNode.GetOutputSlots<MaterialSlot>().FirstOrDefault();
if (outputSlot != null)
{
currentId++;
ids[activeNode.guid] = currentId;
surfaceDescriptionFunction.AddShaderChunk(string.Format("if ({0} == {1}) {{ surface.PreviewOutput = {2}; return surface; }}", outputIdProperty.referenceName, currentId, ShaderGenerator.AdaptNodeOutputForPreview(activeNode, outputSlot.id, activeNode.GetVariableNameForSlot(outputSlot.id))), false);
}
}
surfaceDescriptionFunction.AddShaderChunk(string.Format("{0} surface = ({0})0;", surfaceDescriptionName), false);
var surfaceDescriptionNodes = masterNode == null ? activeNodeList.OfType<AbstractMaterialNode>() : masterNode.ToEnumerable();
foreach (var node in surfaceDescriptionNodes)
if (masterNode != null)
if (node is IMasterNode)
if (masterNode is IMasterNode)
foreach (var input in node.GetInputSlots<MaterialSlot>())
foreach (var input in masterNode.GetInputSlots<MaterialSlot>())
{
var foundEdges = graph.GetEdges(input.slotReference).ToArray();
if (foundEdges.Any())

}
}
}
else
else if (masterNode.hasPreview)
if (node.hasPreview)
{
foreach (var slot in node.GetOutputSlots<MaterialSlot>())
surfaceDescriptionFunction.AddShaderChunk(string.Format("surface.{0} = {0};", node.GetVariableNameForSlot(slot.id)), true);
}
foreach (var slot in masterNode.GetOutputSlots<MaterialSlot>())
surfaceDescriptionFunction.AddShaderChunk(string.Format("surface.{0} = {0};", masterNode.GetVariableNameForSlot(slot.id)), true);
surfaceDescriptionFunction.AddShaderChunk("return surface;", false);
surfaceDescriptionFunction.Deindent();

else
slots.AddRange(activeNode.GetOutputSlots<MaterialSlot>());
}
GenerateSurfaceDescriptionStruct(surfaceDescriptionStruct, slots);
GenerateSurfaceDescriptionStruct(surfaceDescriptionStruct, slots, !isUber);
var shaderProperties = new PropertyCollector();
outputIdProperty = new FloatShaderProperty

shaderFunctionVisitor,
shaderProperties,
requirements,
mode);
mode,
outputIdProperty: outputIdProperty,
ids: ids);
var finalShader = new ShaderGenerator();
finalShader.AddShaderChunk(string.Format(@"Shader ""{0}""", name), false);

}
else
{
finalShader.AddShaderChunk(ShaderGenerator.GetPreviewSubShader(activeNodeList, node, requirements, outputIdProperty, ids), false);
finalShader.AddShaderChunk(ShaderGenerator.GetPreviewSubShader(node, requirements), false);
}
ListPool<INode>.Release(activeNodeList);

18
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/SlotValue.cs


return ChannelCount.Zero;
}
}
static readonly string[] k_ConcreteSlotValueTypeClassNames =
{
null,
"typeMatrix",
"typeMatrix",
"typeMatrix",
"typeTexture2D",
"typeFloat4",
"typeFloat3",
"typeFloat2",
"typeFloat1"
};
public static string ToClassName(this ConcreteSlotValueType type)
{
return k_ConcreteSlotValueTypeClassNames[(int)type];
}
}
}

2
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/SubGraph/LayeredShaderGraph.cs


}
var masterNode = baseGraph.masterNode;
GenerateSurfaceDescriptionStruct(surfaceDescriptionStruct, ((AbstractMaterialNode) masterNode).GetInputSlots<MaterialSlot>().ToList());
GenerateSurfaceDescriptionStruct(surfaceDescriptionStruct, ((AbstractMaterialNode) masterNode).GetInputSlots<MaterialSlot>().ToList(), true);
foreach (var layer in layerMap)
{

16
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Util/ShaderGenerator.cs


ConvertBetweenSpace(from.ToVariableName(type), from, CoordinateSpace.Tangent, inputType, from)), false);
}
public static string GetPreviewSubShader(List<INode> activeNodeList, AbstractMaterialNode node, ShaderGraphRequirements shaderGraphRequirements, FloatShaderProperty outputIdProperty, Dictionary<Guid, int> ids)
public static string GetPreviewSubShader(AbstractMaterialNode node, ShaderGraphRequirements shaderGraphRequirements)
{
var interpolators = new ShaderGenerator();
var vertexShader = new ShaderGenerator();

CoordinateSpace.World);
var outputs = new ShaderGenerator();
var currentId = -1;
if (node != null)
{
var outputSlot = node.GetOutputSlots<MaterialSlot>().FirstOrDefault();

}
else
{
foreach (var activeNode in activeNodeList.OfType<AbstractMaterialNode>())
{
var outputSlot = activeNode.GetOutputSlots<MaterialSlot>().FirstOrDefault();
if (activeNode.hasPreview && outputSlot != null)
{
currentId++;
ids[activeNode.guid] = currentId;
var result = string.Format("surf.{0}", activeNode.GetVariableNameForSlot(outputSlot.id));
outputs.AddShaderChunk(string.Format("if ({0} == {1}) return {2}; else ", outputIdProperty.referenceName, currentId, AdaptNodeOutputForPreview(activeNode, outputSlot.id, result)), false);
}
}
outputs.AddShaderChunk("return 0;", false);
outputs.AddShaderChunk("return surf.PreviewOutput;", false);
}
var res = subShaderTemplate.Replace("${Interpolators}", interpolators.GetShaderString(0));

11
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/GraphInspectorView.cs


{
var headerContainer = new VisualElement {name = "header"};
{
headerContainer.Add(new VisualElement {name = "title", text = assetName});
headerContainer.Add(new Label(assetName) {name = "title"});
}
topContainer.Add(headerContainer);

{
var header = new VisualElement {name = "header"};
{
var title = new VisualElement {name = "title", text = "Properties"};
var title = new Label("Properties") {name = "title"};
header.Add(title);
var addPropertyButton = new Button(OnAddProperty) {text = "Add", name = "addButton"};

{
var header = new VisualElement {name = "header"};
{
var title = new VisualElement {name = "title", text = "Layers"};
var title = new Label("Layers") {name = "title"};
header.Add(title);
var addLayerButton = new Button(OnAddLayer) {text = "Add", name = "addButton"};

m_ContentContainer.Clear();
if (m_SelectedNodes.Count > 1)
{
var element = new VisualElement
var element = new Label(string.Format("{0} nodes selected.", m_SelectedNodes.Count))
name = "selectionCount",
text = string.Format("{0} nodes selected.", m_SelectedNodes.Count)
name = "selectionCount"
};
m_ContentContainer.Add(element);
}

12
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/NodeEditorHeaderView.cs


{
public class NodeEditorHeaderView : VisualElement
{
VisualElement m_Title;
VisualElement m_Type;
Label m_Title;
Label m_Type;
m_Title = new VisualElement { name = "title", text = "" };
m_Title = new Label("") { name = "title" };
Add(new VisualElement { name = "preType", text = "(" });
m_Type = new VisualElement { name = "type", text = "" };
Add(new Label("(") { name = "preType" });
m_Type = new Label("") { name = "type" };
Add(new VisualElement { name = "postType", text = ")" });
Add(new Label(")") { name = "postType" });
}
public string title

7
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/MaterialGraphEditWindow.cs


{
if (m_GraphEditorView != null)
{
rootVisualContainer.Remove(m_GraphEditorView);
m_GraphEditorView.RemoveFromHierarchy();
m_GraphEditorView.Dispose();
}
m_GraphEditorView = value;

m_GraphEditorView.onConvertToSubgraphClick += ToSubGraph;
m_GraphEditorView.onShowInProjectClick += PingAsset;
rootVisualContainer.Add(graphEditorView);
rootVisualContainer.parent.clippingOptions = VisualElement.ClippingOptions.ClipContents;
this.GetRootVisualContainer().Add(graphEditorView);
this.GetRootVisualContainer().parent.clippingOptions = VisualElement.ClippingOptions.ClipContents;
}
}
}

if (m_GraphObject.graph.GetType() == typeof(MasterRemapGraph))
UpdateAbstractSubgraphOnDisk<MasterRemapGraph>(path);
graphObject.isDirty = false;
var windows = Resources.FindObjectsOfTypeAll<MaterialGraphEditWindow>();
foreach (var materialGraphEditWindow in windows)
{

12
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/PreviewManager.cs


using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;

using UnityEditor.Graphing;
using UnityEditor.ShaderGraph;
using UnityEngine.Rendering;
using Debug = UnityEngine.Debug;
using Object = UnityEngine.Object;
namespace UnityEditor.ShaderGraph.Drawing

try
{
var sw = new Stopwatch();
sw.Start();
var i = 0;
EditorUtility.DisplayProgressBar("Shader Graph", string.Format("Compiling preview shaders ({0}/{1})", i, count), 0f);
foreach (var node in masterNodes)

i++;
EditorUtility.DisplayProgressBar("Shader Graph", string.Format("Compiling preview shaders ({0}/{1})", i, count), 0f);
}
sw.Stop();
Debug.LogFormat("Compiled preview shaders in {0} seconds", sw.Elapsed.TotalSeconds);
}
finally
{

// Fill MaterialPropertyBlock
m_PreviewPropertyBlock.Clear();
var outputIdName = m_OutputIdProperty != null ? m_OutputIdProperty.referenceName : null;
m_PreviewPropertyBlock.SetFloat(outputIdName, -1);
foreach (var nodeGuid in m_PropertyNodeGuids)
{
var node = m_Graph.GetNodeFromGuid<AbstractMaterialNode>(nodeGuid);

}
m_PreviewProperties.Clear();
}
var outputIdName = m_OutputIdProperty != null ? m_OutputIdProperty.referenceName : null;
foreach (var nodeGuid in m_DirtyPreviews)
{

// Debug output
var message = "RecreateShader: " + node.GetVariableNameForNode() + Environment.NewLine + previewData.shaderString;
if (MaterialGraphAsset.ShaderHasError(previewData.shader))
Debug.LogWarningFormat(message);
Debug.LogWarning(message);
else
Debug.Log(message);
}

4
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/GradientEdge.cs


edgeControl.edgeWidth = edgeWidth;
edgeControl.inputColor = isGhostEdge ? ghostColor : (selected ? selectedColor : inputColor);
edgeControl.outputColor = isGhostEdge ? ghostColor : (selected ? selectedColor : outputColor);
edgeControl.startCapColor = edgeControl.outputColor;
edgeControl.endCapColor = edgeControl.inputColor;
// edgeControl.startCapColor = edgeControl.outputColor;
// edgeControl.endCapColor = edgeControl.inputColor;
}
}
}

14
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/GraphEditorView.cs


{
if (m_GraphView == null)
return;
var dependentNodes = new List<INode>();
NodeUtils.CollectNodesNodeFeedsInto(dependentNodes, inNode);
foreach (var node in dependentNodes)

var targetNodeView = m_GraphView.nodes.ToList().OfType<MaterialNodeView>().FirstOrDefault(x => x.node == targetNode);
var targetAnchor = targetNodeView.inputContainer.Children().OfType<Port>().FirstOrDefault(x => x.userData is ISlot && (x.userData as ISlot).Equals(targetSlot));
var edgeView = new GradientEdge
var edgeView = new Edge
edgeView.UpdateClasses(sourceSlot.concreteValueType, targetSlot.concreteValueType);
// edgeView.UpdateClasses(sourceSlot.concreteValueType, targetSlot.concreteValueType);
edgeView.output.Connect(edgeView);
edgeView.input.Connect(edgeView);
m_GraphView.AddElement(edgeView);

foreach (var anchorView in nodeView.outputContainer.Children().OfType<Port>())
{
var sourceSlot = (MaterialSlot)anchorView.userData;
foreach (var edgeView in anchorView.connections.OfType<GradientEdge>())
foreach (var edgeView in anchorView.connections.OfType<Edge>())
edgeView.UpdateClasses(sourceSlot.concreteValueType, targetSlot.concreteValueType);
// edgeView.UpdateClasses(sourceSlot.concreteValueType, targetSlot.concreteValueType);
var connectedNodeView = edgeView.input.node as MaterialNodeView;
if (connectedNodeView != null && !nodeViews.Contains(connectedNodeView))
{

var targetSlot = (MaterialSlot)anchorView.userData;
if (targetSlot.valueType != SlotValueType.Dynamic)
continue;
foreach (var edgeView in anchorView.connections.OfType<GradientEdge>())
foreach (var edgeView in anchorView.connections.OfType<Edge>())
edgeView.UpdateClasses(sourceSlot.concreteValueType, targetSlot.concreteValueType);
// edgeView.UpdateClasses(sourceSlot.concreteValueType, targetSlot.concreteValueType);
var connectedNodeView = edgeView.output.node as MaterialNodeView;
if (connectedNodeView != null && !nodeViews.Contains(connectedNodeView))
{

9
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/MaterialNodeView.cs


m_PreviewData.onPreviewChanged += UpdatePreviewTexture;
UpdatePreviewTexture();
var collapsePreviewButton = new VisualElement { name = "collapse"/*, text = "▲" */};
var collapsePreviewButton = new VisualElement { name = "collapse"};
collapsePreviewButton.Add(new VisualElement { name = "icon" });
collapsePreviewButton.AddManipulator(new Clickable(() =>
{

if (node is PreviewNode)
{
var resizeHandle = new VisualElement { name = "resize", text = "" };
var resizeHandle = new Label { name = "resize", text = "" };
resizeHandle.AddManipulator(new Draggable(OnResize));
Add(resizeHandle);

if (slot.hidden)
continue;
var port = InstantiatePort(Orientation.Horizontal, slot.isInputSlot ? Direction.Input : Direction.Output, typeof(Vector4));
port.capabilities &= ~Capabilities.Movable;
var port = InstantiatePort(Orientation.Horizontal, slot.isInputSlot ? Direction.Input : Direction.Output, null);
port.visualClass = slot.concreteValueType.ToClassName();
if (slot.isOutputSlot)
{

{
var slot = (MaterialSlot) anchor.userData;
anchor.portName = slot.displayName;
anchor.visualClass = slot.concreteValueType.ToClassName();
}
foreach (var attacher in m_Attachers)

36
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/PreviewTextureView.cs


namespace UnityEditor.ShaderGraph.Drawing
{
public sealed class PreviewTextureView : VisualElement
public sealed class PreviewTextureView : Image
Texture m_Image;
public Texture image
{
get { return m_Image; }
set
{
if (value == m_Image)
return;
m_Image = value;
Dirty(ChangeType.Repaint);
}
}
// Texture m_Image;
//
// public Texture image
// {
// get { return m_Image; }
// set
// {
// if (value == m_Image)
// return;
// m_Image = value;
// Dirty(ChangeType.Repaint);
// }
// }
public override void DoRepaint()
{
EditorGUI.DrawPreviewTexture(contentRect, image);
}
// public override void DoRepaint()
// {
// EditorGUI.DrawPreviewTexture(contentRect, image);
// }
}
}

8
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/ToolbarView.cs


namespace UnityEditor.ShaderGraph.Drawing
{
public class ToolbarView : VisualElement
public class ToolbarView : BaseTextElement
{
public ToolbarView()
{

public class ToolbarButtonView : VisualElement
public class ToolbarButtonView : BaseTextElement
{
public ToolbarButtonView()
{

public class ToolbarSeparatorView : VisualElement
public class ToolbarSeparatorView : BaseTextElement
{
public ToolbarSeparatorView()
{

public class ToolbarSpaceView : VisualElement
public class ToolbarSpaceView : BaseTextElement
{
public ToolbarSpaceView()
{

15
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Resources/Shaders/Checkerboard.shader


#include "UnityCG.cginc"
static const float rows = 32;
static const float columns = 32;
static const float4 col1 = float4(32.0/255.0, 32.0/255.0, 32.0/255.0, 1.0);
static const float4 col2 = float4(42.0/255.0, 42.0/255.0, 42.0/255.0, 1.0);
static const float rows = 24;
static const float columns = 24;
float3 col1 = float3(32.0/255.0, 32.0/255.0, 32.0/255.0);
float3 col2 = float3(42.0/255.0, 42.0/255.0, 42.0/255.0);
if (!IsGammaSpace()) {
col1 = GammaToLinearSpace(col1);
col2 = GammaToLinearSpace(col2);
}
return lerp(col1, col2, step(fmod(total, 2.0), 0.5));
return float4(lerp(col1, col2, step(fmod(total, 2.0), 0.5)), 1.0);
}
ENDCG
}

4
MaterialGraphProject/Assets/graphs_PartyPreview.mat


m_Texture: {fileID: 2800000, guid: 7296f51323ae9485a9c834c4e3d722ed, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _Texture2D_8897CB1D_Tex:
m_Texture: {fileID: 2800000, guid: 9d64a9e7ca6864704ae6b8ca7afc9d85, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- Float_D2D9489B: 3
m_Colors: []

2
MaterialGraphProject/ProjectSettings/ProjectVersion.txt


m_EditorVersion: 2018.1.0a5
m_EditorVersion: 2018.1.0a6

193
MaterialGraphProject/Assets/Beachball.ShaderGraph
文件差异内容过多而无法显示
查看文件

7
MaterialGraphProject/Assets/Beachball.ShaderGraph.meta


fileFormatVersion: 2
guid: b141c720617d37f45a2fd27af59ccf42
ScriptedImporter:
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 625f186215c104763be7675aa2d941aa, type: 3}

22
MaterialGraphProject/Assets/Beachball.mat


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: Beachball
m_Shader: {fileID: 4800000, guid: b141c720617d37f45a2fd27af59ccf42, type: 3}
m_ShaderKeywords:
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs: []
m_Floats: []
m_Colors: []

8
MaterialGraphProject/Assets/Beachball.mat.meta


fileFormatVersion: 2
guid: b232af1498b13d14db58368a73b45744
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:

4
MaterialGraphProject/UnityPackageManager/manifest.json


{
"dependencies": {
}
}
正在加载...
取消
保存