GitHub
7 年前
当前提交
5363a614
共有 17 个文件被更改,包括 704 次插入 和 360 次删除
-
206MaterialGraphProject/Assets/PartyPreview.ShaderGraph
-
22MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/AbstractMaterialGraphEditWindow.cs
-
120MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/MaterialGraphPresenter.cs
-
61MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/GraphEditorView.cs
-
51MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/MaterialGraphView.cs
-
241MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/MaterialNodeView.cs
-
7MaterialGraphProject/Assets/UnityShaderEditor/Editor/Util/GraphTypeMapper.cs
-
13MaterialGraphProject/ProjectSettings/DynamicsManager.asset
-
16MaterialGraphProject/ProjectSettings/Physics2DSettings.asset
-
39MaterialGraphProject/ProjectSettings/ProjectSettings.asset
-
28MaterialGraphProject/Assets/New Shader Graph.ShaderGraph
-
9MaterialGraphProject/Assets/New Shader Graph.ShaderGraph.meta
-
84MaterialGraphProject/GeneratedShader.shader
-
12MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/MaterialNodePresenter.cs.meta
-
147MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/MaterialNodePresenter.cs
-
8MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Nodes.meta
206
MaterialGraphProject/Assets/PartyPreview.ShaderGraph
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
|
|||
using System; |
|||
using UnityEditor.Experimental.UIElements.GraphView; |
|||
using UnityEngine; |
|||
public class GraphTypeMapper : BaseTypeFactory<INode, ScriptableObject> |
|||
public class GraphTypeMapper : BaseTypeFactory<INode, GraphElement> |
|||
protected override ScriptableObject InternalCreate(Type valueType) |
|||
protected override GraphElement InternalCreate(Type valueType) |
|||
return ScriptableObject.CreateInstance(valueType); |
|||
return (GraphElement) Activator.CreateInstance(valueType); |
|||
} |
|||
} |
|||
} |
28
MaterialGraphProject/Assets/New Shader Graph.ShaderGraph
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
|
|||
fileFormatVersion: 2 |
|||
guid: bc622a74b3c2c0d4db4c564bf551b9b5 |
|||
ShaderImporter: |
|||
externalObjects: {} |
|||
defaultTextures: [] |
|||
nonModifiableTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
Shader "hidden/preview/Fractal_70AE3FBF" |
|||
{ |
|||
Properties |
|||
{ |
|||
} |
|||
CGINCLUDE |
|||
#include "UnityCG.cginc" |
|||
void Unity_Fractal_float(float2 uv, float2 pan, float zoom, float aspect, out float 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; |
|||
} |
|||
struct GraphVertexInput |
|||
{ |
|||
float4 vertex : POSITION; |
|||
float3 normal : NORMAL; |
|||
float4 tangent : TANGENT; |
|||
float4 texcoord0 : TEXCOORD0; |
|||
float4 lightmapUV : TEXCOORD1; |
|||
UNITY_VERTEX_INPUT_INSTANCE_ID |
|||
}; |
|||
struct SurfaceInputs{ |
|||
half4 uv0; |
|||
}; |
|||
struct SurfaceDescription{ |
|||
float Fractal_70AE3FBF_result; |
|||
}; |
|||
float4 Fractal_70AE3FBF_uv; |
|||
float4 Fractal_70AE3FBF_pan; |
|||
float Fractal_70AE3FBF_zoom; |
|||
float Fractal_70AE3FBF_aspect; |
|||
GraphVertexInput PopulateVertexData(GraphVertexInput v){ |
|||
return v; |
|||
} |
|||
SurfaceDescription PopulateSurfaceData(SurfaceInputs IN) { |
|||
half4 uv0 = IN.uv0; |
|||
float Fractal_70AE3FBF_result; |
|||
Unity_Fractal_float(uv0, Fractal_70AE3FBF_pan, Fractal_70AE3FBF_zoom, Fractal_70AE3FBF_aspect, Fractal_70AE3FBF_result); |
|||
SurfaceDescription surface = (SurfaceDescription)0; |
|||
surface.Fractal_70AE3FBF_result = Fractal_70AE3FBF_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; |
|||
half4 uv0 : TEXCOORD; |
|||
}; |
|||
GraphVertexOutput vert (GraphVertexInput v) |
|||
{ |
|||
v = PopulateVertexData(v); |
|||
GraphVertexOutput o; |
|||
o.position = UnityObjectToClipPos(v.vertex); |
|||
o.uv0 = v.texcoord0; |
|||
return o; |
|||
} |
|||
fixed4 frag (GraphVertexOutput IN) : SV_Target |
|||
{ |
|||
float4 uv0 = IN.uv0; |
|||
SurfaceInputs surfaceInput = (SurfaceInputs)0;; |
|||
surfaceInput.uv0 =uv0; |
|||
SurfaceDescription surf = PopulateSurfaceData(surfaceInput); |
|||
return half4(surf.Fractal_70AE3FBF_result, surf.Fractal_70AE3FBF_result, surf.Fractal_70AE3FBF_result, 1.0); |
|||
} |
|||
ENDCG |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 6d66b7c0ed7187d4f9ebae2c7f8d3167 |
|||
timeCreated: 1476707367 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using UnityEditor.Experimental.UIElements.GraphView; |
|||
using UnityEngine.Graphing; |
|||
using UnityEngine.MaterialGraph; |
|||
using UnityEngine; |
|||
|
|||
namespace UnityEditor.MaterialGraph.Drawing |
|||
{ |
|||
[Serializable] |
|||
public class MaterialNodePresenter : NodePresenter, IDisposable |
|||
{ |
|||
public AbstractMaterialNode node { get; private set; } |
|||
|
|||
[SerializeField] |
|||
protected List<GraphControlPresenter> m_Controls = new List<GraphControlPresenter>(); |
|||
|
|||
public List<GraphControlPresenter> controls |
|||
{ |
|||
get { return m_Controls; } |
|||
} |
|||
|
|||
[SerializeField] |
|||
int m_Version; |
|||
PreviewData m_Preview; |
|||
|
|||
public Texture previewTexture { get; private set; } |
|||
|
|||
public override bool expanded |
|||
{ |
|||
get { return base.expanded; } |
|||
set |
|||
{ |
|||
if (base.expanded != value) |
|||
{ |
|||
base.expanded = value; |
|||
var ds = node.drawState; |
|||
ds.expanded = value; |
|||
node.drawState = ds; |
|||
} |
|||
} |
|||
} |
|||
|
|||
public virtual void OnModified(ModificationScope scope) |
|||
{ |
|||
m_Version++; |
|||
|
|||
expanded = node.drawState.expanded; |
|||
|
|||
if (scope == ModificationScope.Topological) |
|||
{ |
|||
var slots = node.GetSlots<ISlot>().ToList(); |
|||
|
|||
inputAnchors.RemoveAll(data => !slots.Contains(((GraphAnchorPresenter)data).slot)); |
|||
outputAnchors.RemoveAll(data => !slots.Contains(((GraphAnchorPresenter)data).slot)); |
|||
|
|||
AddSlots(slots.Except(inputAnchors.Concat(outputAnchors).Select(data => ((GraphAnchorPresenter)data).slot))); |
|||
|
|||
inputAnchors.Sort((x, y) => slots.IndexOf(((GraphAnchorPresenter)x).slot) - slots.IndexOf(((GraphAnchorPresenter)y).slot)); |
|||
outputAnchors.Sort((x, y) => slots.IndexOf(((GraphAnchorPresenter)x).slot) - slots.IndexOf(((GraphAnchorPresenter)y).slot)); |
|||
} |
|||
} |
|||
|
|||
public override void CommitChanges() |
|||
{ |
|||
var drawState = node.drawState; |
|||
drawState.position = position; |
|||
node.drawState = drawState; |
|||
} |
|||
|
|||
protected virtual IEnumerable<GraphControlPresenter> GetControlData() |
|||
{ |
|||
return Enumerable.Empty<GraphControlPresenter>(); |
|||
} |
|||
|
|||
protected void AddSlots(IEnumerable<ISlot> slots) |
|||
{ |
|||
foreach (var slot in slots) |
|||
{ |
|||
if (slot.hidden) |
|||
continue; |
|||
|
|||
var data = CreateInstance<GraphAnchorPresenter>(); |
|||
data.capabilities &= ~Capabilities.Movable; |
|||
data.Initialize(slot); |
|||
|
|||
if (slot.isOutputSlot) |
|||
{ |
|||
outputAnchors.Add(data); |
|||
} |
|||
else |
|||
{ |
|||
inputAnchors.Add(data); |
|||
} |
|||
} |
|||
} |
|||
|
|||
protected MaterialNodePresenter() |
|||
{} |
|||
|
|||
public virtual void Initialize(INode inNode, PreviewSystem previewSystem) |
|||
{ |
|||
node = inNode as AbstractMaterialNode; |
|||
|
|||
if (node == null) |
|||
return; |
|||
|
|||
title = inNode.name; |
|||
expanded = node.drawState.expanded; |
|||
|
|||
AddSlots(node.GetSlots<ISlot>()); |
|||
|
|||
var controlData = GetControlData(); |
|||
controls.AddRange(controlData); |
|||
|
|||
position = new Rect(node.drawState.position.x, node.drawState.position.y, 0, 0); |
|||
|
|||
m_Version = 0; |
|||
|
|||
m_Preview = previewSystem.GetPreview(inNode); |
|||
m_Preview.onPreviewChanged += OnPreviewChanged; |
|||
|
|||
node.onReplaced += OnReplaced; |
|||
} |
|||
|
|||
void OnReplaced(INode previous, INode current) |
|||
{ |
|||
node = current as AbstractMaterialNode; |
|||
} |
|||
|
|||
void OnPreviewChanged() |
|||
{ |
|||
previewTexture = m_Preview.texture; |
|||
m_Version++; |
|||
} |
|||
|
|||
public void Dispose() |
|||
{ |
|||
if (m_Preview != null) |
|||
{ |
|||
m_Preview.onPreviewChanged -= OnPreviewChanged; |
|||
m_Preview = null; |
|||
} |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 7e4695133ddd49cf97b1629ca5537e5b |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue