浏览代码

Fixed compatibale anchor finding.

/main
damian 7 年前
当前提交
815e2106
共有 2 个文件被更改,包括 72 次插入19 次删除
  1. 51
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/MaterialGraphView.cs
  2. 40
      MaterialGraphProject/GeneratedShader.shader

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


evt.StopPropagation();
}
public override List<NodeAnchor> GetCompatibleAnchors(NodeAnchor startAnchor, NodeAdapter nodeAdapter)
{
var compatibleAnchors = new List<NodeAnchor>();
var startAnchorPresenter = startAnchor.presenter as GraphAnchorPresenter;
if (startAnchorPresenter == null)
return compatibleAnchors;
var startSlot = startAnchorPresenter.slot as MaterialSlot;
if (startSlot == null)
return compatibleAnchors;
var goingBackwards = startSlot.isOutputSlot;
var startStage = startSlot.shaderStage;
if (startStage == ShaderStage.Dynamic)
startStage = NodeUtils.FindEffectiveShaderStage(startSlot.owner, startSlot.isOutputSlot);
foreach (var anchor in anchors.ToList())
{
var candidateAnchorPresenter = anchor.presenter as GraphAnchorPresenter;
if (candidateAnchorPresenter == null)
continue;
if (!candidateAnchorPresenter.IsConnectable())
continue;
if (candidateAnchorPresenter.orientation != startAnchor.orientation)
continue;
if (candidateAnchorPresenter.direction == startAnchor.direction)
continue;
if (nodeAdapter.GetAdapter(candidateAnchorPresenter.source, startAnchor.source) == null)
continue;
var candidateSlot = candidateAnchorPresenter.slot as MaterialSlot;
if (candidateSlot == null)
continue;
if (candidateSlot.owner == startSlot.owner)
continue;
if (!startSlot.IsCompatibleWithInputSlotType(candidateSlot.valueType))
continue;
if (startStage != ShaderStage.Dynamic)
{
var candidateStage = candidateSlot.shaderStage;
if (candidateStage == ShaderStage.Dynamic)
candidateStage = NodeUtils.FindEffectiveShaderStage(candidateSlot.owner, !startSlot.isOutputSlot);
if (candidateStage != ShaderStage.Dynamic && candidateStage != startStage)
continue;
}
compatibleAnchors.Add(anchor);
}
return compatibleAnchors;
}
class AddNodeCreationObject
{
public Vector2 m_Pos;

40
MaterialGraphProject/GeneratedShader.shader


Shader "hidden/preview/Fractal_DDEE6FBB"
Shader "hidden/preview/_E2A7472C"
{
Properties
{

void Unity_Fractal_float(float2 uv, float2 pan, float zoom, float aspect, out float result)
void Unity_AACheckerboard_float(float2 uv, float4 colorA, float4 colorB, float3 aaTweak, float2 frequency, out float4 result)
const int Iterations = 128;
float2 c = (uv - 0.5) * zoom * float2(1, aspect) - pan;
float2 v = 0;
for (int n = 0; n < Iterations && dot(v,v) < 4; n++)
{
v = float2(v.x * v.x - v.y * v.y, v.x * v.y * 2) + c;
}
result = (dot(v, v) > 4) ? (float)n / (float)Iterations : 0;
float4 derivatives = float4(ddx(uv), ddy(uv));
float2 duv_length = sqrt(float2(dot(derivatives.xz, derivatives.xz), dot(derivatives.yw, derivatives.yw)));
float width = 0.5f;
float2 distance3 = 2.0f * abs(frac(uv.xy * frequency) - 0.5f) - width;
float2 scale = aaTweak.x / duv_length.xy;
float2 blend_out = saturate((scale - aaTweak.zz) / (aaTweak.yy - aaTweak.zz));
float2 vector_alpha = clamp(distance3 * scale.xy * blend_out.xy, -1.0f, 1.0f);
float alpha = saturate(0.5f + 0.5f * vector_alpha.x * vector_alpha.y);
result= lerp(colorA, colorB, alpha.xxxx);
}
struct GraphVertexInput
{

half4 uv0;
};
struct SurfaceDescription{
float Fractal_DDEE6FBB_result;
float4 _E2A7472C_result;
float4 Fractal_DDEE6FBB_uv;
float4 Fractal_DDEE6FBB_pan;
float Fractal_DDEE6FBB_zoom;
float Fractal_DDEE6FBB_aspect;
float4 _E2A7472C_uv;
float4 _E2A7472C_colorA;
float4 _E2A7472C_colorB;
float4 _E2A7472C_aaTweak;
float4 _E2A7472C_frequency;
float Fractal_DDEE6FBB_result;
Unity_Fractal_float(uv0, Fractal_DDEE6FBB_pan, Fractal_DDEE6FBB_zoom, Fractal_DDEE6FBB_aspect, Fractal_DDEE6FBB_result);
float4 _E2A7472C_result;
Unity_AACheckerboard_float(uv0, _E2A7472C_colorA, _E2A7472C_colorB, _E2A7472C_aaTweak, _E2A7472C_frequency, _E2A7472C_result);
surface.Fractal_DDEE6FBB_result = Fractal_DDEE6FBB_result;
surface._E2A7472C_result = _E2A7472C_result;
return surface;
}
ENDCG

SurfaceInputs surfaceInput = (SurfaceInputs)0;;
surfaceInput.uv0 =uv0;
SurfaceDescription surf = PopulateSurfaceData(surfaceInput);
return half4(surf.Fractal_DDEE6FBB_result, surf.Fractal_DDEE6FBB_result, surf.Fractal_DDEE6FBB_result, 1.0);
return half4(surf._E2A7472C_result.x, surf._E2A7472C_result.y, surf._E2A7472C_result.z, 1.0);
}
ENDCG
}
正在加载...
取消
保存