浏览代码
Merge branch 'hackweek2017' of https://github.com/stramit/MaterialGraph into hackweek2017
/main
Merge branch 'hackweek2017' of https://github.com/stramit/MaterialGraph into hackweek2017
/main
Florent Guinier
8 年前
当前提交
ec474be5
共有 253 个文件被更改,包括 2360 次插入 和 139 次删除
-
11MaterialGraphProject/Assets/Andre/New Material.mat
-
2MaterialGraphProject/Assets/Andre/New Shader Graph.ShaderGraph
-
106MaterialGraphProject/Assets/Rinaldo/BlendModeNode.cs
-
16MaterialGraphProject/Assets/Rinaldo/BlendModesEnum.cs
-
2MaterialGraphProject/Assets/Rinaldo/Editor/BlendModeNodePresenter.cs
-
2MaterialGraphProject/Assets/TestGraph.ShaderGraph
-
4MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/MaterialGraphPresenter.cs
-
7MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/NodePreviewPresenter.cs
-
8MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/LevelsNodePresenter.cs
-
21MaterialGraphProject/Assets/UnityShaderEditor/Editor/HelperShader.shader
-
10MaterialGraphProject/Assets/UnityShaderEditor/Editor/HelperShader.shader.meta
-
2MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Interfaces/IMasterNode.cs
-
5MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/AbstractMasterNode.cs
-
34MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/UV/CartesianToPolarNode.cs
-
49MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/UV/UVRotatorNode.cs
-
9MaterialGraphProject/Assets/UnityShaderEditor/Runtime/SubGraph/SubGraphNode.cs
-
50MaterialGraphProject/Assets/UnityShaderEditor/Runtime/SurfaceModel/AbstractSurfaceMasterNode.cs
-
48MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Util/ShaderGenerator.cs
-
2MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Math/Trigonometry/DegreesToRadiansNode.cs
-
2MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Math/Trigonometry/RadiansToDegreesNode.cs
-
4MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Math/Advanced/ReciprocalNode.cs
-
2MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Normal/UnpackNormalNode.cs
-
4MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Math/Basic/AddNode.cs
-
8MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Legacy/LegacyBlendNode.cs
-
4MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Math/Basic/DivNode.cs
-
4MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Math/Vector/DotNode.cs
-
4MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Math/Vector/FresnelNode.cs
-
4MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Math/Basic/MultiplyNode.cs
-
4MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Math/Vector/ReflectNode.cs
-
4MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Math/Basic/SubtractNode.cs
-
10MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Art/Adjustments/LevelsNode.cs
-
2MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Art/Conversion/HSVtoRGBNode.cs
-
2MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Art/Adjustments/HueNode.cs
-
2MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Art/Conversion/RGBtoHSVNode.cs
-
2MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Math/Range/RemapNode.cs
-
6MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Art/Adjustments/ContrastNode.cs
-
6MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Art/Conversion/RGBtoLuminanceNode.cs
-
6MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Art/Adjustments/SaturationNode.cs
-
4MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Art/Conversion/LinearToRGBNode.cs
-
2MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Art/Conversion/RGBtoLinearNode.cs
-
9MaterialGraphProject/Assets/Andre/Editor.meta
-
1MaterialGraphProject/Assets/Andre/FlowMap.ShaderGraph
-
9MaterialGraphProject/Assets/Andre/FlowMap.ShaderGraph.meta
-
83MaterialGraphProject/Assets/Andre/ToggleNode.cs
-
8MaterialGraphProject/Assets/Andre/ToggleNode.cs.meta
-
104MaterialGraphProject/Assets/Brandon/NoiseNode.cs
-
12MaterialGraphProject/Assets/Brandon/NoiseNode.cs.meta
-
50MaterialGraphProject/Assets/Eduardo/Editor/AddManyNodePresenter.cs
-
12MaterialGraphProject/Assets/Eduardo/Editor/AddManyNodePresenter.cs.meta
-
1MaterialGraphProject/Assets/Eduardo/EduardoTestGraph.ShaderGraph
-
9MaterialGraphProject/Assets/Eduardo/EduardoTestGraph.ShaderGraph.meta
-
70MaterialGraphProject/Assets/Eduardo/FunctionNAddNode.cs
-
12MaterialGraphProject/Assets/Eduardo/FunctionNAddNode.cs.meta
-
142MaterialGraphProject/Assets/Eduardo/FunctionNInNOut.cs
-
12MaterialGraphProject/Assets/Eduardo/FunctionNInNOut.cs.meta
-
56MaterialGraphProject/Assets/Rinaldo/FractalNode.cs
-
12MaterialGraphProject/Assets/Rinaldo/FractalNode.cs.meta
-
643MaterialGraphProject/Assets/TestAssets/flowmap.png
-
84MaterialGraphProject/Assets/TestAssets/flowmap.png.meta
-
9MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Art.meta
-
9MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Legacy.meta
-
9MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Math.meta
-
29MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/MatrixMultiplyNode.cs
-
12MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/MatrixMultiplyNode.cs.meta
-
29MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/MatrixTransposeNode.cs
-
12MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/MatrixTransposeNode.cs.meta
-
9MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Normal.meta
-
56MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Procedural/RepeatingDotNode.cs
-
12MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Procedural/RepeatingDotNode.cs.meta
-
101MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Procedural/VoronoiNoise.cs
-
12MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Procedural/VoronoiNoise.cs.meta
-
29MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/VectorProjectionNode.cs
-
12MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/VectorProjectionNode.cs.meta
-
29MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/VectorRejectionNode.cs
-
12MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/VectorRejectionNode.cs.meta
-
12MaterialGraphProject/Assets/Andre/Editor/ToggleNodePresenter.cs.meta
-
46MaterialGraphProject/Assets/Andre/Editor/ToggleNodePresenter.cs
-
122MaterialGraphProject/Assets/NewNodes/WIP/ParallaxNode.cs
-
12MaterialGraphProject/Assets/NewNodes/WIP/ParallaxNode.cs.meta
-
9MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Art/Adjustments.meta
-
9MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Art/Conversion.meta
-
9MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Math/Advanced.meta
-
13MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Math/Advanced/AbsoluteNode.cs
-
13MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Math/Advanced/LengthNode.cs
-
13MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Math/Advanced/NormalizeNode.cs
-
26MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Math/Advanced/PosterizeNode.cs
-
9MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Math/Basic.meta
-
13MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Math/Basic/PowerNode.cs
-
9MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Math/Interpolation.meta
2
MaterialGraphProject/Assets/Andre/New Shader Graph.ShaderGraph
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
2
MaterialGraphProject/Assets/TestGraph.ShaderGraph
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
|
|||
fileFormatVersion: 2 |
|||
guid: 9ab5e16c2083a4fe689209a8c1ae425e |
|||
timeCreated: 1495526268 |
|||
<<<<<<< HEAD |
|||
timeCreated: 1495529915 |
|||
======= |
|||
timeCreated: 1495532053 |
|||
>>>>>>> f9e75cae7d0f088d17985a220f4ca7ae3da1222a |
|||
nonModifiableTextures: [] |
|||
nonModifiableTextures: |
|||
- Texture_5537060b_db74_4900_8f2b_178ba97b7f11_Uniform: {fileID: 2800000, guid: 6e8d12f68bae2294da814f9d4c81b29a, |
|||
type: 3} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: bed9a49249fc34bf8adec9aaca294542 |
|||
folderAsset: yes |
|||
timeCreated: 1495545513 |
|||
licenseType: Pro |
|||
DefaultImporter: |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
1
MaterialGraphProject/Assets/Andre/FlowMap.ShaderGraph
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
|
|||
fileFormatVersion: 2 |
|||
guid: 78cd4aa6317ee45c1a7e853fbab1e808 |
|||
timeCreated: 1495548280 |
|||
licenseType: Pro |
|||
ScriptedImporter: |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|||
script: {fileID: 11500000, guid: 625f186215c104763be7675aa2d941aa, type: 3} |
|
|||
using UnityEngine.Graphing; |
|||
|
|||
namespace UnityEngine.MaterialGraph |
|||
{ |
|||
[Title("Input/Toggle")] |
|||
public class ToggleNode : PropertyNode, IGeneratesBodyCode |
|||
{ |
|||
[SerializeField] |
|||
private float m_Float; |
|||
private bool m_ToggleState; |
|||
|
|||
private const int kOutputSlotId = 0; |
|||
private const string kOutputSlotName = "Ouput"; |
|||
|
|||
public ToggleNode() |
|||
{ |
|||
name = "Toggle"; |
|||
UpdateNodeAfterDeserialization(); |
|||
} |
|||
|
|||
/* public override bool hasPreview |
|||
{ |
|||
get { return true; } |
|||
}*/ |
|||
|
|||
public sealed override void UpdateNodeAfterDeserialization() |
|||
{ |
|||
AddSlot(new MaterialSlot(kOutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, SlotValueType.Vector1, Vector2.zero)); |
|||
RemoveSlotsNameNotMatching(new[] { kOutputSlotId }); |
|||
} |
|||
|
|||
public override PropertyType propertyType |
|||
{ |
|||
get { return PropertyType.Float; } |
|||
} |
|||
|
|||
public bool value |
|||
{ |
|||
get { return m_ToggleState; } |
|||
set |
|||
{ |
|||
if (m_ToggleState == value) |
|||
return; |
|||
|
|||
m_ToggleState = value; |
|||
if (onModified != null) |
|||
{ |
|||
onModified(this, ModificationScope.Node); |
|||
} |
|||
} |
|||
} |
|||
|
|||
public override void GeneratePropertyBlock(PropertyGenerator visitor, GenerationMode generationMode) |
|||
{ |
|||
if (exposedState == ExposedState.Exposed) |
|||
visitor.AddShaderProperty(new FloatPropertyChunk(propertyName, description, 0f, PropertyChunk.HideState.Visible)); |
|||
} |
|||
|
|||
public override void GeneratePropertyUsages(ShaderGenerator visitor, GenerationMode generationMode) |
|||
{ |
|||
if (exposedState == ExposedState.Exposed || generationMode.IsPreview()) |
|||
visitor.AddShaderChunk(precision + " " + propertyName + ";", true); |
|||
} |
|||
|
|||
public void GenerateNodeCode(ShaderGenerator visitor, GenerationMode generationMode) |
|||
{ |
|||
if (exposedState == ExposedState.Exposed || generationMode.IsPreview()) |
|||
return; |
|||
|
|||
visitor.AddShaderChunk(value.ToString (), true); |
|||
} |
|||
|
|||
public override PreviewProperty GetPreviewProperty() |
|||
{ |
|||
return new PreviewProperty |
|||
{ |
|||
m_Name = propertyName, |
|||
m_PropType = PropertyType.Float, |
|||
m_Float = value ? 1f : 0f |
|||
}; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: fccc54ac137a8451d8011f29847e63b1 |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|
|||
namespace UnityEngine.MaterialGraph |
|||
{ |
|||
[Title("Procedural/Noise")] |
|||
public class NoiseNode : Function1Input, IGeneratesFunction |
|||
{ |
|||
public NoiseNode() |
|||
{ |
|||
name = "Noise"; |
|||
} |
|||
|
|||
protected override string GetFunctionName() |
|||
{ |
|||
return "unity_noise_" + precision; |
|||
} |
|||
|
|||
protected override string GetInputSlotName() |
|||
{ |
|||
return "UV"; |
|||
} |
|||
|
|||
protected override MaterialSlot GetInputSlot() |
|||
{ |
|||
return new MaterialSlot(InputSlotId, GetInputSlotName(), kInputSlotShaderName, UnityEngine.Graphing.SlotType.Input, SlotValueType.Vector2, Vector2.zero); |
|||
} |
|||
|
|||
protected override MaterialSlot GetOutputSlot() |
|||
{ |
|||
return new MaterialSlot(OutputSlotId, GetOutputSlotName(), kOutputSlotShaderName, UnityEngine.Graphing.SlotType.Output, SlotValueType.Vector1, Vector2.zero); |
|||
} |
|||
|
|||
public void GenerateNodeFunction(ShaderGenerator visitor, GenerationMode generationMode) |
|||
{ |
|||
var outputString = new ShaderGenerator(); |
|||
|
|||
outputString.AddShaderChunk("inline float unity_noise_randomValue (float2 uv)", false); |
|||
outputString.AddShaderChunk("{", false); |
|||
outputString.Indent(); |
|||
|
|||
outputString.AddShaderChunk("return frac(sin(dot(uv, float2(12.9898, 78.233)))*43758.5453);", false); |
|||
|
|||
outputString.Deindent(); |
|||
outputString.AddShaderChunk("}", false); |
|||
|
|||
|
|||
outputString.AddShaderChunk("inline float unity_noise_interpolate (float a, float b, float t)", false); |
|||
outputString.AddShaderChunk("{", false); |
|||
outputString.Indent(); |
|||
|
|||
outputString.AddShaderChunk("return (1.0-t)*a + (t*b);", false); |
|||
|
|||
outputString.Deindent(); |
|||
outputString.AddShaderChunk("}", false); |
|||
|
|||
outputString.AddShaderChunk("inline float unity_valueNoise (float2 uv)", false); |
|||
outputString.AddShaderChunk("{", false); |
|||
outputString.Indent(); |
|||
|
|||
outputString.AddShaderChunk("float2 i = floor(uv);", false); |
|||
outputString.AddShaderChunk("float2 f = frac(uv);", false); |
|||
outputString.AddShaderChunk("f = f * f * (3.0 - 2.0 * f);", false); |
|||
|
|||
outputString.AddShaderChunk("uv = abs(frac(uv) - 0.5);", false); |
|||
outputString.AddShaderChunk("float2 c0 = i + float2(0.0, 0.0);", false); |
|||
outputString.AddShaderChunk("float2 c1 = i + float2(1.0, 0.0);", false); |
|||
outputString.AddShaderChunk("float2 c2 = i + float2(0.0, 1.0);", false); |
|||
outputString.AddShaderChunk("float2 c3 = i + float2(1.0, 1.0);", false); |
|||
outputString.AddShaderChunk("float r0 = unity_noise_randomValue(c0);", false); |
|||
outputString.AddShaderChunk("float r1 = unity_noise_randomValue(c1);", false); |
|||
outputString.AddShaderChunk("float r2 = unity_noise_randomValue(c2);", false); |
|||
outputString.AddShaderChunk("float r3 = unity_noise_randomValue(c3);", false); |
|||
|
|||
outputString.AddShaderChunk("float bottomOfGrid = unity_noise_interpolate(r0, r1, f.x);", false); |
|||
outputString.AddShaderChunk("float topOfGrid = unity_noise_interpolate(r2, r3, f.x);", false); |
|||
outputString.AddShaderChunk("float t = unity_noise_interpolate(bottomOfGrid, topOfGrid, f.y);", false); |
|||
outputString.AddShaderChunk("return t;", false); |
|||
|
|||
outputString.Deindent(); |
|||
outputString.AddShaderChunk("}", false); |
|||
|
|||
|
|||
outputString.AddShaderChunk(GetFunctionPrototype("uv"), false); |
|||
outputString.AddShaderChunk("{", false); |
|||
outputString.Indent(); |
|||
|
|||
outputString.AddShaderChunk("float t = 0.0;", false); |
|||
outputString.AddShaderChunk("for(int i = 0; i < 3; i++)", false); |
|||
outputString.AddShaderChunk("{", false); |
|||
outputString.Indent(); |
|||
|
|||
outputString.AddShaderChunk("float freq = pow(2.0, float(i));", false); |
|||
outputString.AddShaderChunk("float amp = pow(0.5, float(3-i));", false); |
|||
outputString.AddShaderChunk("t += unity_valueNoise(float2(uv.x/freq, uv.y/freq))*amp;", false); |
|||
|
|||
outputString.Deindent(); |
|||
outputString.AddShaderChunk("}", false); |
|||
outputString.AddShaderChunk("return t;", false); |
|||
|
|||
outputString.Deindent(); |
|||
outputString.AddShaderChunk("}", false); |
|||
|
|||
visitor.AddShaderChunk(outputString.GetShaderString(0), true); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 6e05bd4324babff4498e856ab63b993c |
|||
timeCreated: 1495526233 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using UnityEngine.MaterialGraph; |
|||
using RMGUI.GraphView; |
|||
using UnityEditor.Graphing.Drawing; |
|||
using UnityEngine; |
|||
|
|||
namespace UnityEditor.MaterialGraph.Drawing |
|||
{ |
|||
[Serializable] |
|||
class AddManyContolPresenter : GraphControlPresenter |
|||
{ |
|||
|
|||
public override void OnGUIHandler() |
|||
{ |
|||
base.OnGUIHandler(); |
|||
|
|||
var addNode = node as UnityEngine.MaterialGraph.AddManyNode; |
|||
if (addNode == null) |
|||
return; |
|||
|
|||
if (GUILayout.Button("Add Input")) |
|||
{ |
|||
addNode.AddInputSlot(); |
|||
addNode.OnModified(); |
|||
} |
|||
if (GUILayout.Button("Remove Input")) |
|||
{ |
|||
addNode.RemoveInputSlot(); |
|||
addNode.OnModified(); |
|||
} |
|||
} |
|||
|
|||
public override float GetHeight() |
|||
{ |
|||
return EditorGUIUtility.singleLineHeight * 2 + 3 * EditorGUIUtility.standardVerticalSpacing; |
|||
} |
|||
} |
|||
|
|||
[Serializable] |
|||
public class AddManyNodePresenter : MaterialNodePresenter |
|||
{ |
|||
protected override IEnumerable<GraphElementPresenter> GetControlData() |
|||
{ |
|||
var instance = CreateInstance<AddManyContolPresenter>(); |
|||
instance.Initialize(node); |
|||
return new List<GraphElementPresenter> { instance }; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 0d89e5c0d48973c4ab16793131164a16 |
|||
timeCreated: 1495530357 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
1
MaterialGraphProject/Assets/Eduardo/EduardoTestGraph.ShaderGraph
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
|
|||
fileFormatVersion: 2 |
|||
guid: ec1e3c0f2bd86e8468380cdcd9455a3d |
|||
timeCreated: 1495547544 |
|||
licenseType: Pro |
|||
ScriptedImporter: |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|||
script: {fileID: 11500000, guid: 625f186215c104763be7675aa2d941aa, type: 3} |
|
|||
using UnityEngine.Graphing; |
|||
using System.Linq; |
|||
using System.Collections; |
|||
|
|||
namespace UnityEngine.MaterialGraph |
|||
{ |
|||
[Title("Math/Advanced/Adder")] |
|||
public class AddManyNode : FunctionNInNOut, IGeneratesFunction |
|||
{ |
|||
int m_nodeInputCount = 2; |
|||
|
|||
public void AddInputSlot() |
|||
{ |
|||
string inputName = "Input" + GetInputSlots<MaterialSlot>().Count().ToString(); |
|||
AddSlot(inputName, inputName, Graphing.SlotType.Input, SlotValueType.Dynamic); |
|||
} |
|||
|
|||
public AddManyNode() |
|||
{ |
|||
name = "Adder"; |
|||
for(int i = 0; i < m_nodeInputCount; ++i) |
|||
{ |
|||
AddInputSlot(); |
|||
} |
|||
|
|||
AddSlot("Sum", "finalSum", Graphing.SlotType.Output, SlotValueType.Dynamic); |
|||
UpdateNodeAfterDeserialization(); |
|||
} |
|||
|
|||
public void OnModified() |
|||
{ |
|||
if (onModified != null) |
|||
onModified(this, ModificationScope.Node); |
|||
} |
|||
|
|||
protected override string GetFunctionName() |
|||
{ |
|||
return "unity_Adder"; |
|||
} |
|||
|
|||
string GetSumOfAllInputs() |
|||
{ |
|||
string sumString = ""; |
|||
int inputsLeft = GetInputSlots<ISlot>().Count(); |
|||
|
|||
foreach (ISlot slot in GetInputSlots<ISlot>()) |
|||
{ |
|||
sumString += GetShaderOutputName(slot.id); |
|||
if (inputsLeft > 1) |
|||
sumString += " + "; |
|||
--inputsLeft; |
|||
} |
|||
|
|||
return sumString; |
|||
} |
|||
|
|||
public void GenerateNodeFunction(ShaderGenerator visitor, GenerationMode generationMode) |
|||
{ |
|||
var outputString = new ShaderGenerator(); |
|||
outputString.AddShaderChunk(GetFunctionPrototype(), false); |
|||
outputString.AddShaderChunk("{", false); |
|||
outputString.Indent(); |
|||
outputString.AddShaderChunk("finalSum = " + GetSumOfAllInputs() + ";", false); |
|||
outputString.Deindent(); |
|||
outputString.AddShaderChunk("}", false); |
|||
|
|||
visitor.AddShaderChunk(outputString.GetShaderString(0), true); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 0518e86ee51c0b844a8721050900863a |
|||
timeCreated: 1495486161 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using UnityEngine.Graphing; |
|||
using System.Linq; |
|||
using System.Collections; |
|||
using System; |
|||
|
|||
namespace UnityEngine.MaterialGraph |
|||
{ |
|||
public abstract class FunctionNInNOut : AbstractMaterialNode, IGeneratesBodyCode |
|||
{ |
|||
|
|||
public FunctionNInNOut() |
|||
{ |
|||
name = "FunctionNInNOut"; |
|||
UpdateNodeAfterDeserialization(); |
|||
} |
|||
|
|||
public override void UpdateNodeAfterDeserialization() |
|||
{ |
|||
base.UpdateNodeAfterDeserialization(); |
|||
foreach (var slot in GetSlots<MaterialSlot>()) |
|||
{ |
|||
slot.showValue = true; |
|||
} |
|||
} |
|||
|
|||
public int AddSlot(string displayName, string nameInShader, SlotType slotType, SlotValueType valueType) |
|||
{ |
|||
int nextSlotId; |
|||
if (slotType == SlotType.Output) |
|||
nextSlotId = -( GetOutputSlots<MaterialSlot>().Count() + 1 ); |
|||
else |
|||
nextSlotId = GetInputSlots<MaterialSlot>().Count() + 1; |
|||
|
|||
AddSlot(new MaterialSlot(nextSlotId, displayName, nameInShader, slotType, valueType, Vector4.zero, true)); |
|||
return nextSlotId; |
|||
} |
|||
|
|||
public void RemoveOutputSlot() |
|||
{ |
|||
var lastSlotId = -GetOutputSlots<ISlot>().Count(); |
|||
RemoveSlotById(lastSlotId); |
|||
} |
|||
|
|||
public void RemoveInputSlot() |
|||
{ |
|||
var lastSlotId = GetInputSlots<ISlot>().Count(); |
|||
RemoveSlotById(lastSlotId); |
|||
} |
|||
|
|||
private void RemoveSlotById(int slotID) |
|||
{ |
|||
if (slotID == 0) |
|||
return; |
|||
RemoveSlot(slotID); |
|||
} |
|||
|
|||
public string GetSlotTypeName(int slotId) |
|||
{ |
|||
return ConvertConcreteSlotValueTypeToString(FindSlot<MaterialSlot>(slotId).concreteValueType); |
|||
} |
|||
|
|||
protected string GetShaderOutputName(int slotId) |
|||
{ |
|||
return FindSlot<MaterialSlot>(slotId).shaderOutputName; |
|||
} |
|||
|
|||
// Must override this
|
|||
protected abstract string GetFunctionName(); |
|||
|
|||
private string GetFunctionParameters() |
|||
{ |
|||
string param = ""; |
|||
int remainingParams = GetSlots<ISlot>().Count(); |
|||
foreach (ISlot inSlot in GetSlots<ISlot>()) |
|||
{ |
|||
if (inSlot.isOutputSlot) |
|||
param += "out "; |
|||
|
|||
param += precision + GetSlotTypeName(inSlot.id) + " "; |
|||
param += GetShaderOutputName(inSlot.id); |
|||
|
|||
if (remainingParams > 1) |
|||
param += ", "; |
|||
--remainingParams; |
|||
} |
|||
|
|||
return param; |
|||
} |
|||
|
|||
private string GetFunctionCallParameters(GenerationMode generationMode) |
|||
{ |
|||
string param = ""; |
|||
int remainingParams = GetSlots<ISlot>().Count(); |
|||
foreach (ISlot inSlot in GetSlots<ISlot>()) |
|||
{ |
|||
param += GetSlotValue(inSlot.id, generationMode); |
|||
|
|||
if (remainingParams > 1) |
|||
param += ", "; |
|||
--remainingParams; |
|||
} |
|||
|
|||
return param; |
|||
} |
|||
|
|||
protected string GetFunctionPrototype() |
|||
{ |
|||
return "inline " + "void" + " " + GetFunctionName() + |
|||
" (" + |
|||
GetFunctionParameters() + |
|||
")"; |
|||
} |
|||
|
|||
private string GetFunctionCall(GenerationMode generationMode) |
|||
{ |
|||
return GetFunctionName() + |
|||
" (" + |
|||
GetFunctionCallParameters(generationMode) + |
|||
");"; |
|||
} |
|||
|
|||
private string GetOutputDeclaration() |
|||
{ |
|||
string outDeclaration = ""; |
|||
foreach (ISlot outSlot in GetOutputSlots<ISlot>()) |
|||
{ |
|||
outDeclaration += "\n " + precision + GetSlotTypeName(outSlot.id) + " " + GetVariableNameForSlot(outSlot.id) + ";\n"; |
|||
} |
|||
|
|||
return outDeclaration; |
|||
} |
|||
|
|||
public void GenerateNodeCode(ShaderGenerator visitor, GenerationMode generationMode) |
|||
{ |
|||
var outputString = new ShaderGenerator(); |
|||
outputString.AddShaderChunk(GetOutputDeclaration(), false); |
|||
outputString.AddShaderChunk(GetFunctionCall(generationMode), false); |
|||
|
|||
visitor.AddShaderChunk(outputString.GetShaderString(0), true); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: ef27c8075e4d9594eb52411936ff46cc |
|||
timeCreated: 1495483390 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using UnityEngine.Graphing; |
|||
using System.Linq; |
|||
using System.Collections; |
|||
|
|||
namespace UnityEngine.MaterialGraph |
|||
{ |
|||
[Title("Procedural/Fractal")] |
|||
public class FractalNode : FunctionNInNOut, IGeneratesFunction |
|||
{ |
|||
|
|||
public FractalNode() |
|||
{ |
|||
name = "Fractal"; |
|||
AddSlot("UV", "texCoord", Graphing.SlotType.Input, SlotValueType.Vector2); |
|||
AddSlot("Pan", "Pan", Graphing.SlotType.Input, SlotValueType.Vector2); |
|||
AddSlot("Zoom", "Zoom", Graphing.SlotType.Input, SlotValueType.Vector1); |
|||
AddSlot("Aspect", "Aspect", Graphing.SlotType.Input, SlotValueType.Vector1); |
|||
|
|||
AddSlot("FracResult", "fractalRes", Graphing.SlotType.Output, SlotValueType.Dynamic); |
|||
|
|||
UpdateNodeAfterDeserialization(); |
|||
} |
|||
|
|||
protected override string GetFunctionName() |
|||
{ |
|||
return "unity_Fractal"; |
|||
} |
|||
|
|||
public override bool hasPreview |
|||
{ |
|||
get { return true; } |
|||
} |
|||
|
|||
public void GenerateNodeFunction(ShaderGenerator visitor, GenerationMode generationMode) |
|||
{ |
|||
var outputString = new ShaderGenerator(); |
|||
outputString.AddShaderChunk(GetFunctionPrototype(), false); |
|||
outputString.AddShaderChunk("{", false); |
|||
outputString.AddShaderChunk("const int Iterations = 128;", false); |
|||
outputString.Indent(); |
|||
outputString.AddShaderChunk("float2 c = (texCoord - 0.5) * Zoom * float2(1, Aspect) - Pan;", false); |
|||
outputString.AddShaderChunk("float2 v = 0;", false); |
|||
outputString.AddShaderChunk("for (int n = 0; n < Iterations && dot(v,v) < 4; n++)", false); |
|||
outputString.AddShaderChunk("{", false); |
|||
outputString.Indent(); |
|||
outputString.AddShaderChunk("v = float2(v.x * v.x - v.y * v.y, v.x * v.y * 2) + c;", false); |
|||
outputString.Deindent(); |
|||
outputString.AddShaderChunk("}", false); |
|||
outputString.Deindent(); |
|||
outputString.AddShaderChunk("fractalRes = (dot(v, v) > 4) ? (float)n / (float)Iterations : 0;", false); |
|||
outputString.AddShaderChunk("}", false); |
|||
|
|||
visitor.AddShaderChunk(outputString.GetShaderString(0), true); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 615f125a4470571418f6e87c208ada10 |
|||
timeCreated: 1495541958 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 8a17a00c2a071472cb92f6911bb7be11 |
|||
timeCreated: 1495551094 |
|||
licenseType: Pro |
|||
TextureImporter: |
|||
fileIDToRecycleName: {} |
|||
serializedVersion: 4 |
|||
mipmaps: |
|||
mipMapMode: 0 |
|||
enableMipMap: 1 |
|||
sRGBTexture: 0 |
|||
linearTexture: 0 |
|||
fadeOut: 0 |
|||
borderMipMap: 0 |
|||
mipMapsPreserveCoverage: 0 |
|||
alphaTestReferenceValue: 0.5 |
|||
mipMapFadeDistanceStart: 1 |
|||
mipMapFadeDistanceEnd: 3 |
|||
bumpmap: |
|||
convertToNormalMap: 0 |
|||
externalNormalMap: 0 |
|||
heightScale: 0.25 |
|||
normalMapFilter: 0 |
|||
isReadable: 0 |
|||
grayScaleToAlpha: 0 |
|||
generateCubemap: 6 |
|||
cubemapConvolution: 0 |
|||
seamlessCubemap: 0 |
|||
textureFormat: 1 |
|||
maxTextureSize: 2048 |
|||
textureSettings: |
|||
serializedVersion: 2 |
|||
filterMode: -1 |
|||
aniso: -1 |
|||
mipBias: -1 |
|||
wrapU: -1 |
|||
wrapV: -1 |
|||
wrapW: -1 |
|||
nPOTScale: 1 |
|||
lightmap: 0 |
|||
compressionQuality: 50 |
|||
spriteMode: 0 |
|||
spriteExtrude: 1 |
|||
spriteMeshType: 1 |
|||
alignment: 0 |
|||
spritePivot: {x: 0.5, y: 0.5} |
|||
spriteBorder: {x: 0, y: 0, z: 0, w: 0} |
|||
spritePixelsToUnits: 100 |
|||
alphaUsage: 1 |
|||
alphaIsTransparency: 0 |
|||
spriteTessellationDetail: -1 |
|||
textureType: 0 |
|||
textureShape: 1 |
|||
maxTextureSizeSet: 0 |
|||
compressionQualitySet: 0 |
|||
textureFormatSet: 0 |
|||
platformSettings: |
|||
- buildTarget: DefaultTexturePlatform |
|||
maxTextureSize: 2048 |
|||
resizeAlgorithm: 0 |
|||
textureFormat: -1 |
|||
textureCompression: 1 |
|||
compressionQuality: 50 |
|||
crunchedCompression: 0 |
|||
allowsAlphaSplitting: 0 |
|||
overridden: 0 |
|||
- buildTarget: Standalone |
|||
maxTextureSize: 2048 |
|||
resizeAlgorithm: 0 |
|||
textureFormat: -1 |
|||
textureCompression: 1 |
|||
compressionQuality: 50 |
|||
crunchedCompression: 0 |
|||
allowsAlphaSplitting: 0 |
|||
overridden: 0 |
|||
spriteSheet: |
|||
serializedVersion: 2 |
|||
sprites: [] |
|||
outline: [] |
|||
physicsShape: [] |
|||
spritePackingTag: |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 8ee6f8ab31f6bf349a63fdd21fc88664 |
|||
folderAsset: yes |
|||
timeCreated: 1495532491 |
|||
licenseType: Pro |
|||
DefaultImporter: |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: eb0cb153896a18c4ebb6d116283dfda4 |
|||
folderAsset: yes |
|||
timeCreated: 1495532221 |
|||
licenseType: Pro |
|||
DefaultImporter: |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: e63f07e66d070412bb6e9582ca1eba72 |
|||
folderAsset: yes |
|||
timeCreated: 1495526358 |
|||
licenseType: Pro |
|||
DefaultImporter: |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
namespace UnityEngine.MaterialGraph |
|||
{ |
|||
[Title("Matrix/Multiply Node")] |
|||
public class MatrixMultiplyNode : Function2Input, IGeneratesFunction |
|||
{ |
|||
public MatrixMultiplyNode() |
|||
{ |
|||
name = "MatrixMultiplyNode"; |
|||
} |
|||
|
|||
protected override string GetFunctionName() |
|||
{ |
|||
return "unity_matrix_multiply_" + precision; |
|||
} |
|||
|
|||
public void GenerateNodeFunction(ShaderGenerator visitor, GenerationMode generationMode) |
|||
{ |
|||
var outputString = new ShaderGenerator(); |
|||
outputString.AddShaderChunk(GetFunctionPrototype("arg1", "arg2"), false); |
|||
outputString.AddShaderChunk("{", false); |
|||
outputString.Indent(); |
|||
outputString.AddShaderChunk("return mul(arg1, arg2);", false); |
|||
outputString.Deindent(); |
|||
outputString.AddShaderChunk("}", false); |
|||
|
|||
visitor.AddShaderChunk(outputString.GetShaderString(0), true); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 8eb82c17970f84fc2b84d060df718533 |
|||
timeCreated: 1495542985 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
namespace UnityEngine.MaterialGraph |
|||
{ |
|||
[Title("Matrix/Transpose Node")] |
|||
public class MatrixTransposeNode : Function1Input, IGeneratesFunction |
|||
{ |
|||
public MatrixTransposeNode() |
|||
{ |
|||
name = "MatrixTranspose"; |
|||
} |
|||
|
|||
protected override string GetFunctionName() |
|||
{ |
|||
return "unity_matrix_transpose_" + precision; |
|||
} |
|||
|
|||
public void GenerateNodeFunction(ShaderGenerator visitor, GenerationMode generationMode) |
|||
{ |
|||
var outputString = new ShaderGenerator(); |
|||
outputString.AddShaderChunk(GetFunctionPrototype("arg1"), false); |
|||
outputString.AddShaderChunk("{", false); |
|||
outputString.Indent(); |
|||
outputString.AddShaderChunk("return transpose(arg1);", false); |
|||
outputString.Deindent(); |
|||
outputString.AddShaderChunk("}", false); |
|||
|
|||
visitor.AddShaderChunk(outputString.GetShaderString(0), true); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 19da2635a60154a6793334e535a0a856 |
|||
timeCreated: 1495542985 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 8443203ba8104ff4bb0a6a0ed978034e |
|||
folderAsset: yes |
|||
timeCreated: 1495532369 |
|||
licenseType: Pro |
|||
DefaultImporter: |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
namespace UnityEngine.MaterialGraph |
|||
{ |
|||
[Title("Procedural/Repeating Dot")] |
|||
public class RepeatingDotNode : Function2Input, IGeneratesFunction |
|||
{ |
|||
public RepeatingDotNode() |
|||
{ |
|||
name = "RepeatingDot"; |
|||
} |
|||
|
|||
protected override string GetFunctionName() |
|||
{ |
|||
return "unity_repreatingdot_" + precision; |
|||
} |
|||
|
|||
protected override string GetInputSlot1Name() |
|||
{ |
|||
return "UV"; |
|||
} |
|||
|
|||
protected override string GetInputSlot2Name() |
|||
{ |
|||
return "Count"; |
|||
} |
|||
|
|||
protected override MaterialSlot GetInputSlot1() |
|||
{ |
|||
return new MaterialSlot(InputSlot1Id, GetInputSlot1Name(), kInputSlot1ShaderName, UnityEngine.Graphing.SlotType.Input, SlotValueType.Vector2, Vector2.zero); |
|||
} |
|||
|
|||
protected override MaterialSlot GetInputSlot2() |
|||
{ |
|||
return new MaterialSlot(InputSlot2Id, GetInputSlot2Name(), kInputSlot2ShaderName, UnityEngine.Graphing.SlotType.Input, SlotValueType.Vector1, Vector4.zero); |
|||
} |
|||
|
|||
protected override MaterialSlot GetOutputSlot() |
|||
{ |
|||
return new MaterialSlot(OutputSlotId, GetOutputSlotName(), kOutputSlotShaderName, UnityEngine.Graphing.SlotType.Output, SlotValueType.Vector1, Vector2.zero); |
|||
} |
|||
|
|||
public void GenerateNodeFunction(ShaderGenerator visitor, GenerationMode generationMode) |
|||
{ |
|||
var outputString = new ShaderGenerator(); |
|||
outputString.AddShaderChunk(GetFunctionPrototype("uv", "count"), false); |
|||
outputString.AddShaderChunk("{", false); |
|||
outputString.Indent(); |
|||
outputString.AddShaderChunk("uv *= 2.0 - 1.0;", false); |
|||
outputString.AddShaderChunk("uv = fmod(uv * count, 1.0) * 2.0 - 1.0;", false); |
|||
outputString.AddShaderChunk("return length(uv);", false); |
|||
outputString.Deindent(); |
|||
outputString.AddShaderChunk("}", false); |
|||
|
|||
visitor.AddShaderChunk(outputString.GetShaderString(0), true); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: c65ff5e45f92e3b498f3ec3aa63b9598 |
|||
timeCreated: 1495550756 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
namespace UnityEngine.MaterialGraph |
|||
{ |
|||
[Title("Procedural/Voronoi Noise")] |
|||
public class VoronoiNoiseNode : Function2Input, IGeneratesFunction |
|||
{ |
|||
public VoronoiNoiseNode() |
|||
{ |
|||
name = "VoronoiNoise"; |
|||
} |
|||
|
|||
protected override string GetFunctionName() |
|||
{ |
|||
return "unity_voronoinoise_" + precision; |
|||
} |
|||
|
|||
protected override string GetInputSlot1Name() |
|||
{ |
|||
return "UV"; |
|||
} |
|||
|
|||
protected override MaterialSlot GetInputSlot1() |
|||
{ |
|||
return new MaterialSlot(InputSlot1Id, GetInputSlot1Name(), kInputSlot1ShaderName, UnityEngine.Graphing.SlotType.Input, SlotValueType.Vector2, Vector2.zero); |
|||
} |
|||
|
|||
protected override string GetInputSlot2Name() |
|||
{ |
|||
return "AngleOffset"; |
|||
} |
|||
|
|||
protected override MaterialSlot GetInputSlot2() |
|||
{ |
|||
return new MaterialSlot(InputSlot2Id, GetInputSlot2Name(), kInputSlot2ShaderName, UnityEngine.Graphing.SlotType.Input, SlotValueType.Vector1, Vector2.zero); |
|||
} |
|||
|
|||
protected override MaterialSlot GetOutputSlot() |
|||
{ |
|||
return new MaterialSlot(OutputSlotId, GetOutputSlotName(), kOutputSlotShaderName, UnityEngine.Graphing.SlotType.Output, SlotValueType.Vector1, Vector2.zero); |
|||
} |
|||
|
|||
public void GenerateNodeFunction(ShaderGenerator visitor, GenerationMode generationMode) |
|||
{ |
|||
var outputString = new ShaderGenerator(); |
|||
|
|||
outputString.AddShaderChunk("inline float2 unity_voronoi_noise_randomVector (float2 uv, float offset)", false); |
|||
outputString.AddShaderChunk("{", false); |
|||
outputString.Indent(); |
|||
|
|||
outputString.AddShaderChunk("float2x2 m = float2x2(15.27, 47.63, 99.41, 89.98);", false); |
|||
outputString.AddShaderChunk("uv = frac(sin(mul(uv, m)) * 46839.32);", false); |
|||
outputString.AddShaderChunk("return float2(sin(uv.y*+offset)*0.5+0.5, cos(uv.x*offset)*0.5+0.5);", false); |
|||
|
|||
outputString.Deindent(); |
|||
outputString.AddShaderChunk("}", false); |
|||
|
|||
outputString.AddShaderChunk(GetFunctionPrototype("uv", "angleOffset"), false); |
|||
outputString.AddShaderChunk("{", false); |
|||
outputString.Indent(); |
|||
|
|||
outputString.AddShaderChunk("float2 g = floor(uv);", false); |
|||
outputString.AddShaderChunk("float2 f = frac(uv);", false); |
|||
outputString.AddShaderChunk("float t = 8.0;", false); |
|||
outputString.AddShaderChunk("float3 res = float3(8.0, 0.0, 0.0);", false); |
|||
|
|||
|
|||
outputString.AddShaderChunk("for(int y=-1; y<=1; y++)", false); |
|||
outputString.AddShaderChunk("{", false); |
|||
outputString.Indent(); |
|||
|
|||
outputString.AddShaderChunk("for(int x=-1; x<=1; x++)", false); |
|||
outputString.AddShaderChunk("{", false); |
|||
outputString.Indent(); |
|||
|
|||
outputString.AddShaderChunk("float2 lattice = float2(x,y);", false); |
|||
outputString.AddShaderChunk("float2 offset = unity_voronoi_noise_randomVector(lattice + g, angleOffset);", false); |
|||
outputString.AddShaderChunk("float d = distance(lattice + offset, f);", false); |
|||
outputString.AddShaderChunk("if(d < res.x)", false); |
|||
outputString.AddShaderChunk("{", false); |
|||
outputString.Indent(); |
|||
|
|||
outputString.AddShaderChunk("res = float3(d, offset.x, offset.y);", false); |
|||
|
|||
outputString.Deindent(); |
|||
outputString.AddShaderChunk("}", false); |
|||
|
|||
outputString.Deindent(); |
|||
outputString.AddShaderChunk("}", false); |
|||
|
|||
outputString.Deindent(); |
|||
outputString.AddShaderChunk("}", false); |
|||
|
|||
outputString.AddShaderChunk("return res.x;", false); |
|||
|
|||
|
|||
outputString.Deindent(); |
|||
outputString.AddShaderChunk("}", false); |
|||
|
|||
visitor.AddShaderChunk(outputString.GetShaderString(0), true); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 38694b8d93b01e049ad6dafebebb60ba |
|||
timeCreated: 1495535565 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
namespace UnityEngine.MaterialGraph |
|||
{ |
|||
[Title("Vector/Projection Node")] |
|||
public class VectorProjectionNode : Function2Input, IGeneratesFunction |
|||
{ |
|||
public VectorProjectionNode() |
|||
{ |
|||
name = "VectorProjection"; |
|||
} |
|||
|
|||
protected override string GetFunctionName() |
|||
{ |
|||
return "unity_vector_projection_" + precision; |
|||
} |
|||
|
|||
public void GenerateNodeFunction(ShaderGenerator visitor, GenerationMode generationMode) |
|||
{ |
|||
var outputString = new ShaderGenerator(); |
|||
outputString.AddShaderChunk(GetFunctionPrototype("arg1", "arg2"), false); |
|||
outputString.AddShaderChunk("{", false); |
|||
outputString.Indent(); |
|||
outputString.AddShaderChunk("return arg2 * dot(arg1, arg2) / dot(arg2, arg2);", false); |
|||
outputString.Deindent(); |
|||
outputString.AddShaderChunk("}", false); |
|||
|
|||
visitor.AddShaderChunk(outputString.GetShaderString(0), true); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 7cf458b51c72d4045a820965b8037b9b |
|||
timeCreated: 1495542985 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
namespace UnityEngine.MaterialGraph |
|||
{ |
|||
[Title("Vector/Rejection Node")] |
|||
public class VectorRejectionNode : Function2Input, IGeneratesFunction |
|||
{ |
|||
public VectorRejectionNode() |
|||
{ |
|||
name = "VectorRejection"; |
|||
} |
|||
|
|||
protected override string GetFunctionName() |
|||
{ |
|||
return "unity_vector_rejection_" + precision; |
|||
} |
|||
|
|||
public void GenerateNodeFunction(ShaderGenerator visitor, GenerationMode generationMode) |
|||
{ |
|||
var outputString = new ShaderGenerator(); |
|||
outputString.AddShaderChunk(GetFunctionPrototype("arg1", "arg2"), false); |
|||
outputString.AddShaderChunk("{", false); |
|||
outputString.Indent(); |
|||
outputString.AddShaderChunk("return arg1 - (arg2 * dot(arg1, arg2) / dot(arg2, arg2));", false); |
|||
outputString.Deindent(); |
|||
outputString.AddShaderChunk("}", false); |
|||
|
|||
visitor.AddShaderChunk(outputString.GetShaderString(0), true); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 831bc8761a9c9493aac513acc02d3577 |
|||
timeCreated: 1495542985 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 55391b421fcbe4e60bf16325132025ff |
|||
timeCreated: 1495456482 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using RMGUI.GraphView; |
|||
using UnityEditor.Graphing.Drawing; |
|||
using UnityEngine; |
|||
using UnityEngine.MaterialGraph; |
|||
|
|||
namespace UnityEditor.MaterialGraph.Drawing |
|||
{ |
|||
[Serializable] |
|||
class ToggleNodeControlPresenter : GraphControlPresenter |
|||
{ |
|||
public override void OnGUIHandler() |
|||
{ |
|||
base.OnGUIHandler(); |
|||
|
|||
var cNode = node as ToggleNode; |
|||
if (cNode == null) |
|||
return; |
|||
|
|||
cNode.value = EditorGUILayout.Toggle(cNode.value); |
|||
cNode.exposedState = (PropertyNode.ExposedState)EditorGUILayout.EnumPopup(new GUIContent("Exposed"), cNode.exposedState); |
|||
} |
|||
|
|||
/* public override float GetHeight() |
|||
{ |
|||
return EditorGUIUtility.singleLineHeight + 2 * EditorGUIUtility.standardVerticalSpacing; |
|||
} |
|||
*/ |
|||
public override float GetHeight() |
|||
{ |
|||
return 2 * (EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing) + EditorGUIUtility.standardVerticalSpacing; |
|||
} |
|||
} |
|||
|
|||
[Serializable] |
|||
public class ToggleNodePresenter : MaterialNodePresenter |
|||
{ |
|||
protected override IEnumerable<GraphElementPresenter> GetControlData() |
|||
{ |
|||
var instance = CreateInstance<ToggleNodeControlPresenter>(); |
|||
instance.Initialize(node); |
|||
return new List<GraphElementPresenter> { instance }; |
|||
} |
|||
} |
|||
} |
|
|||
using UnityEngine.Graphing; |
|||
|
|||
namespace UnityEngine.MaterialGraph |
|||
{ |
|||
interface IMayRequireViewDirectionTangentSpace |
|||
{ |
|||
bool RequiresViewDirectionTangentSpace(); |
|||
} |
|||
|
|||
[Title("UV/Parallax")] |
|||
public class ParallaxNode : AbstractMaterialNode, IGeneratesBodyCode, IGeneratesFunction, IMayRequireMeshUV, IMayRequireViewDirectionTangentSpace |
|||
{ |
|||
protected const string kInputSlot1ShaderName = "Depth"; |
|||
protected const string kOutputSlotShaderName = "UV"; |
|||
|
|||
public const int InputSlot1Id = 0; |
|||
public const int OutputSlotId = 1; |
|||
|
|||
public override bool hasPreview |
|||
{ |
|||
get { return true; } |
|||
} |
|||
|
|||
public override PreviewMode previewMode |
|||
{ |
|||
get |
|||
{ |
|||
return PreviewMode.Preview3D; |
|||
} |
|||
} |
|||
|
|||
public ParallaxNode() |
|||
{ |
|||
name = "Parallax"; |
|||
UpdateNodeAfterDeserialization(); |
|||
} |
|||
|
|||
public string GetFunctionName() |
|||
{ |
|||
return "unity_parallax_" + precision; |
|||
} |
|||
|
|||
public sealed override void UpdateNodeAfterDeserialization() |
|||
{ |
|||
AddSlot(GetInputSlot1()); |
|||
AddSlot(GetOutputSlot()); |
|||
RemoveSlotsNameNotMatching(validSlots); |
|||
} |
|||
|
|||
protected int[] validSlots |
|||
{ |
|||
get { return new[] { InputSlot1Id, OutputSlotId }; } |
|||
} |
|||
|
|||
protected virtual MaterialSlot GetInputSlot1() |
|||
{ |
|||
return new MaterialSlot(InputSlot1Id, GetInputSlot1Name(), kInputSlot1ShaderName, SlotType.Input, SlotValueType.Vector1, Vector4.zero); |
|||
} |
|||
|
|||
protected virtual MaterialSlot GetOutputSlot() |
|||
{ |
|||
return new MaterialSlot(OutputSlotId, GetOutputSlotName(), kOutputSlotShaderName, SlotType.Output, SlotValueType.Vector2, Vector4.zero); |
|||
} |
|||
protected virtual string GetInputSlot1Name() |
|||
{ |
|||
return kInputSlot1ShaderName; |
|||
} |
|||
protected virtual string GetOutputSlotName() |
|||
{ |
|||
return kOutputSlotShaderName; |
|||
} |
|||
protected virtual string GetFunctionPrototype(string arg1Name, string arg2Name, string arg3Name) |
|||
{ |
|||
return "inline " + precision + "2 " + GetFunctionName() + " (" + |
|||
precision + " " + arg1Name + ", " + |
|||
precision + "2 " + arg2Name + ", " + |
|||
precision + "3 " + arg3Name + ")"; |
|||
} |
|||
|
|||
public void GenerateNodeCode(ShaderGenerator visitor, GenerationMode generationMode) |
|||
{ |
|||
NodeUtils.SlotConfigurationExceptionIfBadConfiguration(this, new[] { InputSlot1Id }, new[] { OutputSlotId }); |
|||
string input1Value = GetSlotValue(InputSlot1Id, generationMode); |
|||
|
|||
visitor.AddShaderChunk(precision + "2 " + GetVariableNameForSlot(OutputSlotId) + " = " + GetFunctionCallBody(input1Value) + ";", true); |
|||
} |
|||
|
|||
public void GenerateNodeFunction(ShaderGenerator visitor, GenerationMode generationMode) |
|||
{ |
|||
var outputString = new ShaderGenerator(); |
|||
outputString.AddShaderChunk(GetFunctionPrototype("depth", "UVs", "viewTangentSpace"), false); |
|||
outputString.AddShaderChunk("{", false); |
|||
outputString.Indent(); |
|||
outputString.AddShaderChunk("return UVs + depth * viewTangentSpace.xy / viewTangentSpace.z;", false); |
|||
|
|||
outputString.Deindent(); |
|||
outputString.AddShaderChunk("}", false); |
|||
|
|||
visitor.AddShaderChunk(outputString.GetShaderString(0), true); |
|||
} |
|||
|
|||
protected virtual string GetFunctionCallBody(string inputValue1) |
|||
{ |
|||
var channel = UVChannel.uv0; |
|||
|
|||
return GetFunctionName() + " (" + |
|||
inputValue1 + ", " + |
|||
channel.GetUVName() + ", " + |
|||
ShaderGeneratorNames.TangentSpaceViewDirection + ")"; |
|||
} |
|||
|
|||
public bool RequiresMeshUV(UVChannel channel) |
|||
{ |
|||
return channel == UVChannel.uv0; |
|||
} |
|||
public bool RequiresViewDirectionTangentSpace() |
|||
{ |
|||
return true; |
|||
} |
|||
} |
|||
} |
|||
|
|
|||
fileFormatVersion: 2 |
|||
guid: 5f290ce984a59bb46a1c34491b3b8b98 |
|||
timeCreated: 1495488490 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 75cc6d701e07fe246ba5377a454f74c4 |
|||
folderAsset: yes |
|||
timeCreated: 1495532497 |
|||
licenseType: Pro |
|||
DefaultImporter: |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 9134a2b351ed9f140bfbb2d46f9075b5 |
|||
folderAsset: yes |
|||
timeCreated: 1495532965 |
|||
licenseType: Pro |
|||
DefaultImporter: |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 198ec765a01574320a8199338d27d9f1 |
|||
folderAsset: yes |
|||
timeCreated: 1495526831 |
|||
licenseType: Pro |
|||
DefaultImporter: |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
namespace UnityEngine.MaterialGraph |
|||
{ |
|||
[Title("Math/Advanced/Absolute")] |
|||
public class AbsoluteNode : Function1Input |
|||
{ |
|||
public AbsoluteNode() |
|||
{ |
|||
name = "Absolute"; |
|||
} |
|||
|
|||
protected override string GetFunctionName() {return "abs"; } |
|||
} |
|||
} |
|
|||
namespace UnityEngine.MaterialGraph |
|||
{ |
|||
[Title("Math/Advanced/Length")] |
|||
public class LengthNode : Function1Input |
|||
{ |
|||
public LengthNode() |
|||
{ |
|||
name = "Length"; |
|||
} |
|||
|
|||
protected override string GetFunctionName() { return "length"; } |
|||
} |
|||
} |
|
|||
namespace UnityEngine.MaterialGraph |
|||
{ |
|||
[Title("Math/Advanced/Normalize")] |
|||
class NormalizeNode : Function1Input |
|||
{ |
|||
public NormalizeNode() |
|||
{ |
|||
name = "Normalize"; |
|||
} |
|||
|
|||
protected override string GetFunctionName() { return "normalize"; } |
|||
} |
|||
} |
|
|||
namespace UnityEngine.MaterialGraph |
|||
{ |
|||
[Title("Math/Advanced/Posterize")] |
|||
class PosterizeNode : Function2Input, IGeneratesFunction |
|||
{ |
|||
public PosterizeNode() |
|||
{ |
|||
name = "Posterize"; |
|||
} |
|||
|
|||
protected override string GetFunctionName() {return "unity_posterize_" + precision; } |
|||
|
|||
public void GenerateNodeFunction(ShaderGenerator visitor, GenerationMode generationMode) |
|||
{ |
|||
var outputString = new ShaderGenerator(); |
|||
outputString.AddShaderChunk(GetFunctionPrototype("input", "stepsize"), false); |
|||
outputString.AddShaderChunk("{", false); |
|||
outputString.Indent(); |
|||
outputString.AddShaderChunk("return floor(input / stepsize) * stepsize;", false); |
|||
outputString.Deindent(); |
|||
outputString.AddShaderChunk("}", false); |
|||
|
|||
visitor.AddShaderChunk(outputString.GetShaderString(0), true); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 4120c70d7c1a34d92b74137bf0b1bc67 |
|||
folderAsset: yes |
|||
timeCreated: 1495526365 |
|||
licenseType: Pro |
|||
DefaultImporter: |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
namespace UnityEngine.MaterialGraph |
|||
{ |
|||
[Title("Math/Basic/Power")] |
|||
public class PowerNode : Function2Input |
|||
{ |
|||
public PowerNode() |
|||
{ |
|||
name = "Power"; |
|||
} |
|||
|
|||
protected override string GetFunctionName() { return "pow"; } |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 458e098c89ad64ed3a48cb5f63a5a498 |
|||
folderAsset: yes |
|||
timeCreated: 1495529238 |
|||
licenseType: Pro |
|||
DefaultImporter: |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
部分文件因为文件数量过多而无法显示
撰写
预览
正在加载...
取消
保存
Reference in new issue