浏览代码

Fixed compatibleAnchors checks for when starting on a no-presenter anchor.

/main
damian 7 年前
当前提交
33ee05ff
共有 4 个文件被更改,包括 33 次插入90 次删除
  1. 9
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/MaterialGraphPresenter.cs
  2. 10
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Nodes/Vector2NodePresenter.cs
  3. 17
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/MaterialGraphView.cs
  4. 87
      MaterialGraphProject/GeneratedShader.shader

9
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/MaterialGraphPresenter.cs


return;
}
if (change.node is Vector2Node)
{
var nodeView = new Vector2NodeView();
change.node.onModified += OnNodeChanged;
nodeView.Initialize(change.node, m_PreviewSystem);
m_GraphView.AddElement(nodeView);
return;
}
if (change.node is FractalNode)
{
var nodeView = new MaterialNodeView();

10
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Nodes/Vector2NodePresenter.cs


return new List<GraphControlPresenter>(base.GetControlData()) { instance };
}
}
public class Vector2NodeView : PropertyNodeView
{
protected override IEnumerable<GraphControlPresenter> GetControlData()
{
var instance = ScriptableObject.CreateInstance<Vector2ControlPresenter>();
instance.Initialize(node);
return new List<GraphControlPresenter>(base.GetControlData()) { instance };
}
}
}

17
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/MaterialGraphView.cs


public override List<NodeAnchor> GetCompatibleAnchors(NodeAnchor startAnchor, NodeAdapter nodeAdapter)
{
var compatibleAnchors = new List<NodeAnchor>();
MaterialSlot startSlot = null;
if (startAnchorPresenter == null)
return compatibleAnchors;
var startSlot = startAnchorPresenter.slot as MaterialSlot;
if (startAnchorPresenter != null && startAnchor.dependsOnPresenter)
{
startSlot = startAnchorPresenter.slot as MaterialSlot;
}
else
{
startSlot = startAnchor.userData as MaterialSlot;
}
if (startSlot == null)
return compatibleAnchors;

MaterialSlot candidateSlot = null;
var candidateAnchorPresenter = candidateAnchor.presenter as GraphAnchorPresenter;
if (candidateAnchorPresenter != null)
if (candidateAnchorPresenter != null && candidateAnchor.dependsOnPresenter)
{
if (!candidateAnchorPresenter.IsConnectable())
continue;

87
MaterialGraphProject/GeneratedShader.shader


Shader "hidden/preview/Gradient_BB2657E7"
{
Properties
{
}
CGINCLUDE
#include "UnityCG.cginc"
void Unity_Gradient_BB2657E7_float(float value, out float4 result)
{
float3 color0=float3(1,1,1);
float colorp0=0;
float3 color1=float3(1,1,1);
float colorp1=1;
float3 gradcolor = color0;
float colorLerpPosition0=smoothstep(colorp0,colorp1,value);
gradcolor = lerp(gradcolor,color1,colorLerpPosition0);
float alpha0=1;
float alphap0=0;
float alpha1=1;
float alphap1=1;
float gradalpha = alpha0;
float alphaLerpPosition0=smoothstep(alphap0,alphap1,value);
gradalpha = lerp(gradalpha,alpha1,alphaLerpPosition0);
result = float4(gradcolor,gradalpha);
}
struct GraphVertexInput
{
float4 vertex : POSITION;
float3 normal : NORMAL;
float4 tangent : TANGENT;
float4 texcoord0 : TEXCOORD0;
float4 lightmapUV : TEXCOORD1;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct SurfaceInputs{
};
struct SurfaceDescription{
float4 Gradient_BB2657E7_result;
};
float Gradient_BB2657E7_value;
GraphVertexInput PopulateVertexData(GraphVertexInput v){
return v;
}
SurfaceDescription PopulateSurfaceData(SurfaceInputs IN) {
float4 Gradient_BB2657E7_result;
Unity_Gradient_BB2657E7_float(Gradient_BB2657E7_value, Gradient_BB2657E7_result);
SurfaceDescription surface = (SurfaceDescription)0;
surface.Gradient_BB2657E7_result = Gradient_BB2657E7_result;
return surface;
}
ENDCG
SubShader
{
Tags { "RenderType"="Opaque" }
LOD 100
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct GraphVertexOutput
{
float4 position : POSITION;
};
GraphVertexOutput vert (GraphVertexInput v)
{
v = PopulateVertexData(v);
GraphVertexOutput o;
o.position = UnityObjectToClipPos(v.vertex);
return o;
}
fixed4 frag (GraphVertexOutput IN) : SV_Target
{
SurfaceInputs surfaceInput = (SurfaceInputs)0;;
SurfaceDescription surf = PopulateSurfaceData(surfaceInput);
return half4(surf.Gradient_BB2657E7_result.x, surf.Gradient_BB2657E7_result.y, surf.Gradient_BB2657E7_result.z, 1.0);
}
ENDCG
}
}
}
null
正在加载...
取消
保存