浏览代码

Fixed inspector and node position is now saved.

/main
damian 7 年前
当前提交
7e977d50
共有 4 个文件被更改,包括 56 次插入56 次删除
  1. 29
      MaterialGraphProject/Assets/New Shader Graph.ShaderGraph
  2. 14
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/GraphEditorView.cs
  3. 1
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/MaterialNodeView.cs
  4. 68
      MaterialGraphProject/GeneratedShader.shader

29
MaterialGraphProject/Assets/New Shader Graph.ShaderGraph
文件差异内容过多而无法显示
查看文件

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


using UnityEngine;
using UnityEngine.Experimental.UIElements;
using UnityEngine.MaterialGraph;
using UnityEngine.Graphing;
using Object = UnityEngine.Object;
namespace UnityEditor.MaterialGraph.Drawing

if (graphViewChange.edgesToCreate != null)
{
foreach (Edge edge in graphViewChange.edgesToCreate)
foreach (var edge in graphViewChange.edgesToCreate)
{
m_GraphPresenter.Connect(edge.output, edge.input);
}

/*
MathNode mathNode = element.userData as MathNode;
if (mathNode == null)
var node = element.userData as INode;
if (node == null)
mathNode.m_Position = element.layout.position;
var drawState = node.drawState;
drawState.position = element.layout;
node.drawState = drawState;
*/
return graphViewChange;
}

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


public virtual void Initialize(INode inNode, PreviewSystem previewSystem)
{
node = inNode as AbstractMaterialNode;
userData = node;
if (node == null)
return;

68
MaterialGraphProject/GeneratedShader.shader


Shader "hidden/preview/Multiply_C3CB7BE2"
Shader "hidden/preview/Fractal_70AE3FBF"
[HideInInspector] [NonModifiableTextureData] [NoScaleOffset] Texture_FD0EDC2E("Texture", 2D) = "white" {}
void Unity_Combine_float(float R, float G, float B, float A, out float4 RGBA)
{
RGBA = float4(R, G, B, A);
}
void Unity_Multiply_float(float4 first, float4 second, out float4 result)
{
result = first * second;
}
void Unity_HSVToRGB_float(float3 hsv, out float3 rgb)
{
//Reference code from:https://github.com/Unity-Technologies/PostProcessing/blob/master/PostProcessing/Resources/Shaders/ColorGrading.cginc#L175
float4 K = float4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
float3 P = abs(frac(hsv.xxx + K.xyz) * 6.0 - K.www);
rgb = hsv.z * lerp(K.xxx, saturate(P - K.xxx), hsv.y);
}
void Unity_Multiply_float(float first, float second, out float result)
void Unity_Fractal_float(float2 uv, float2 pan, float zoom, float aspect, out float result)
result = first * second;
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;
}
struct GraphVertexInput
{

half4 uv0;
};
struct SurfaceDescription{
float Multiply_C3CB7BE2_result;
float Fractal_70AE3FBF_result;
UNITY_DECLARE_TEX2D(Texture_FD0EDC2E);
float Combine_76C873_G;
float Combine_76C873_B;
float Combine_76C873_A;
float4 Property_23AD7FD4_UV;
float Multiply_C3CB7BE2_second;
float4 Fractal_70AE3FBF_uv;
float4 Fractal_70AE3FBF_pan;
float Fractal_70AE3FBF_zoom;
float Fractal_70AE3FBF_aspect;
float4 Combine_76C873_RGBA;
Unity_Combine_float(_Time.y, Combine_76C873_G, Combine_76C873_B, Combine_76C873_A, Combine_76C873_RGBA);
float4 Property_23AD7FD4_RGBA = UNITY_SAMPLE_TEX2D(Texture_FD0EDC2E,uv0.xy);
float Property_23AD7FD4_R = Property_23AD7FD4_RGBA.r;
float Property_23AD7FD4_G = Property_23AD7FD4_RGBA.g;
float Property_23AD7FD4_B = Property_23AD7FD4_RGBA.b;
float Property_23AD7FD4_A = Property_23AD7FD4_RGBA.a;
float4 Multiply_89C71AC1_result;
Unity_Multiply_float(Property_23AD7FD4_RGBA, Combine_76C873_RGBA, Multiply_89C71AC1_result);
float3 HSVtoRGB_AE8D0A0E_rgb;
Unity_HSVToRGB_float((Multiply_89C71AC1_result.xyz), HSVtoRGB_AE8D0A0E_rgb);
float Split_81BA869A_R = HSVtoRGB_AE8D0A0E_rgb[0];
float Split_81BA869A_G = HSVtoRGB_AE8D0A0E_rgb[1];
float Split_81BA869A_B = HSVtoRGB_AE8D0A0E_rgb[2];
float Split_81BA869A_A = 1.0;
float Multiply_9164EC34_result;
Unity_Multiply_float(Split_81BA869A_R, Split_81BA869A_G, Multiply_9164EC34_result);
float Multiply_841C266E_result;
Unity_Multiply_float(Multiply_9164EC34_result, Split_81BA869A_B, Multiply_841C266E_result);
float Multiply_C3CB7BE2_result;
Unity_Multiply_float(Multiply_841C266E_result, Multiply_C3CB7BE2_second, Multiply_C3CB7BE2_result);
float Fractal_70AE3FBF_result;
Unity_Fractal_float(uv0, Fractal_70AE3FBF_pan, Fractal_70AE3FBF_zoom, Fractal_70AE3FBF_aspect, Fractal_70AE3FBF_result);
surface.Multiply_C3CB7BE2_result = Multiply_C3CB7BE2_result;
surface.Fractal_70AE3FBF_result = Fractal_70AE3FBF_result;
return surface;
}
ENDCG

SurfaceInputs surfaceInput = (SurfaceInputs)0;;
surfaceInput.uv0 =uv0;
SurfaceDescription surf = PopulateSurfaceData(surfaceInput);
return half4(surf.Multiply_C3CB7BE2_result, surf.Multiply_C3CB7BE2_result, surf.Multiply_C3CB7BE2_result, 1.0);
return half4(surf.Fractal_70AE3FBF_result, surf.Fractal_70AE3FBF_result, surf.Fractal_70AE3FBF_result, 1.0);
}
ENDCG
}
正在加载...
取消
保存