浏览代码

Merge branch 'hackweek2017' of https://github.com/stramit/MaterialGraph into hackweek2017

/main
Matt Dean 8 年前
当前提交
d6b72c9a
共有 18 个文件被更改,包括 1323 次插入121 次删除
  1. 181
      MaterialGraphProject/Assets/Matt&Andre/RemapNode.cs
  2. 8
      MaterialGraphProject/Assets/Rinaldo/BlendModeNode.cs
  3. 2
      MaterialGraphProject/Assets/Rinaldo/BlendModesEnum.cs
  4. 2
      MaterialGraphProject/Assets/TestAssets/Sky1.jpg.meta
  5. 3
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/NodePreviewPresenter.cs
  6. 12
      MaterialGraphProject/Assets/Andre/CubemapNode.cs
  7. 9
      MaterialGraphProject/Assets/Andre.meta
  8. 12
      MaterialGraphProject/Assets/Andre/CubemapNode.cs.meta
  9. 1
      MaterialGraphProject/Assets/Andre/New Shader Graph.ShaderGraph
  10. 9
      MaterialGraphProject/Assets/Andre/New Shader Graph.ShaderGraph.meta
  11. 25
      MaterialGraphProject/obj/Debug/Assembly-CSharp.csproj.FilesWrittenAbsolute.txt
  12. 1001
      MaterialGraphProject/obj/Debug/Assembly-CSharp.dll
  13. 171
      MaterialGraphProject/obj/Debug/Assembly-CSharp.dll.mdb
  14. 8
      MaterialGraphProject/Assets/Matt&Andre/CubemapNode.cs.meta
  15. 0
      /MaterialGraphProject/Assets/Andre/CubemapNode.cs

181
MaterialGraphProject/Assets/Matt&Andre/RemapNode.cs


namespace UnityEngine.MaterialGraph
{
[Title ("Math/Range/Remap")]
public class RemapNode : Function2Input, IGeneratesFunction
public class RemapNode : AbstractMaterialNode, IGeneratesBodyCode, IGeneratesFunction
/*protected const string kInputSlot1ShaderName = "Input1";
protected const string kInputSlot2ShaderName = "Input2";
protected const string kInputSlot1ShaderName = "Input1";
protected const string kInputSlot2ShaderName = "InMin";
protected const string kInputSlot3ShaderName = "InMax";
public const int OutputSlotId = 2;
public const int InputSlot3Id = 2;
public const int OutputSlotId = 3;
*/
public override bool hasPreview
{
get { return true; }
}
name = "RemapNode";
name = "Remap";
protected override string GetFunctionName ()
public string GetFunctionName ()
//need to override the type of slot two somehow///////////////////////////////////////////////////
/*override MaterialSlot GetInputSlot2 ()
public sealed override void UpdateNodeAfterDeserialization()
return new MaterialSlot (InputSlot2Id, GetInputSlot2Name (), kInputSlot2ShaderName, SlotType.Input, SlotValueType.Vector4, Vector4.zero);
}*/
AddSlot(GetInputSlot1());
AddSlot(GetInputSlot2());
AddSlot(GetInputSlot3());
AddSlot(GetOutputSlot());
RemoveSlotsNameNotMatching(validSlots);
}
public void GenerateNodeFunction (ShaderGenerator visitor, GenerationMode generationMode)
protected int[] validSlots
var outputString = new ShaderGenerator ();
outputString.AddShaderChunk (GetFunctionPrototype ("arg1", "arg2"), false);
outputString.AddShaderChunk ("{", false);
outputString.Indent ();
outputString.AddShaderChunk ("return ((arg1 * (arg2.y - arg2.x)) * (arg2.w - arg2.z))+arg2.z;", false);
outputString.Deindent ();
outputString.AddShaderChunk ("}", false);
visitor.AddShaderChunk (outputString.GetShaderString (0), true);
get { return new[] {InputSlot1Id, InputSlot2Id, InputSlot3Id, OutputSlotId}; }
/*
public sealed override void UpdateNodeAfterDeserialization ()
protected virtual MaterialSlot GetInputSlot1()
AddSlot (GetInputSlot1 ());
AddSlot (GetInputSlot2 ());
AddSlot (GetOutputSlot ());
RemoveSlotsNameNotMatching (validSlots);
return new MaterialSlot(InputSlot1Id, GetInputSlot1Name(), kInputSlot1ShaderName, SlotType.Input, SlotValueType.Dynamic, Vector4.zero);
protected int[] validSlots {
get { return new[] { InputSlot1Id, InputSlot2Id, OutputSlotId }; }
protected virtual MaterialSlot GetInputSlot2()
{
return new MaterialSlot(InputSlot2Id, GetInputSlot2Name(), kInputSlot2ShaderName, SlotType.Input, SlotValueType.Vector2, Vector2.zero);
protected virtual MaterialSlot GetInputSlot1 ()
protected virtual MaterialSlot GetInputSlot3()
return new MaterialSlot (InputSlot1Id, GetInputSlot1Name (), kInputSlot1ShaderName, SlotType.Input, SlotValueType.Dynamic, Vector4.zero);
return new MaterialSlot(InputSlot3Id, GetInputSlot3Name(), kInputSlot3ShaderName, SlotType.Input, SlotValueType.Vector2, Vector2.zero);
protected virtual MaterialSlot GetInputSlot2 ()
protected virtual MaterialSlot GetOutputSlot()
return new MaterialSlot (InputSlot2Id, GetInputSlot2Name (), kInputSlot2ShaderName, SlotType.Input, SlotValueType.Vector4, Vector4.zero);
return new MaterialSlot(OutputSlotId, GetOutputSlotName(), kOutputSlotShaderName, SlotType.Output, SlotValueType.Dynamic, Vector4.zero);
protected virtual MaterialSlot GetOutputSlot ()
protected virtual string GetInputSlot1Name()
return new MaterialSlot (OutputSlotId, GetOutputSlotName (), kOutputSlotShaderName, SlotType.Output, SlotValueType.Dynamic, Vector4.zero);
return "Input";
protected virtual string GetInputSlot1Name ()
protected virtual string GetInputSlot2Name()
return "Input1";
return "InMin/Max";
protected virtual string GetInputSlot2Name ()
protected virtual string GetInputSlot3Name()
return "RemapVector";
return "OutMin/Max";
protected virtual string GetOutputSlotName ()
protected virtual string GetOutputSlotName()
//protected abstract string GetFunctionName ();
/*protected virtual string GetFunctionPrototype (string arg1Name, string arg2Name)
protected virtual string GetFunctionPrototype(string arg1Name, string arg2Name, string arg3Name)
return "inline " + precision + outputDimension + " " + GetFunctionName () + " ("
+ precision + input1Dimension + " " + arg1Name + ", "
+ precision + input2Dimension + " " + arg2Name + ")";
return "inline " + precision + outputDimension + " " + GetFunctionName() + " ("
+ precision + input1Dimension + " " + arg1Name + ", "
+ precision + input2Dimension + " " + arg2Name + ", "
+ precision + input3Dimension + " " + arg3Name + ")";
public void GenerateNodeCode (ShaderGenerator visitor, GenerationMode generationMode)
public void GenerateNodeCode(ShaderGenerator visitor, GenerationMode generationMode)
NodeUtils.SlotConfigurationExceptionIfBadConfiguration (this, new[] { InputSlot1Id, InputSlot2Id }, new[] { OutputSlotId });
string input1Value = GetSlotValue (InputSlot1Id, generationMode);
string input2Value = GetSlotValue (InputSlot2Id, generationMode);
visitor.AddShaderChunk (precision + outputDimension + " " + GetVariableNameForSlot (OutputSlotId) + " = " + GetFunctionCallBody (input1Value, input2Value) + ";", true);
NodeUtils.SlotConfigurationExceptionIfBadConfiguration(this, new[] { InputSlot1Id, InputSlot2Id, InputSlot3Id }, new[] { OutputSlotId });
string input1Value = GetSlotValue(InputSlot1Id, generationMode);
string input2Value = GetSlotValue(InputSlot2Id, generationMode);
string input3Value = GetSlotValue(InputSlot3Id, generationMode);
visitor.AddShaderChunk(precision + outputDimension + " " + GetVariableNameForSlot(OutputSlotId) + " = " + GetFunctionCallBody(input1Value, input2Value, input3Value) + ";", true);
protected virtual string GetFunctionCallBody (string input1Value, string input2Value)
public void GenerateNodeFunction(ShaderGenerator visitor, GenerationMode generationMode)
return GetFunctionName () + " (" + input1Value + ", " + input2Value + ")";
}*/
var outputString = new ShaderGenerator ();
outputString.AddShaderChunk (GetFunctionPrototype ("arg1", "arg2", "arg3"), false);
outputString.AddShaderChunk ("{", false);
outputString.Indent ();
outputString.AddShaderChunk ("return arg1 * ((arg3.y - arg3.x) / (arg2.y - arg2.x)) + arg3.x;", false);
outputString.Deindent ();
outputString.AddShaderChunk ("}", false);
/*public string outputDimension {
get { return ConvertConcreteSlotValueTypeToString (FindOutputSlot<MaterialSlot> (OutputSlotId).concreteValueType); }
visitor.AddShaderChunk (outputString.GetShaderString (0), true);
private string input1Dimension {
get { return ConvertConcreteSlotValueTypeToString (FindInputSlot<MaterialSlot> (InputSlot1Id).concreteValueType); }
}
private string input2Dimension {
get { return ConvertConcreteSlotValueTypeToString (FindInputSlot<MaterialSlot> (InputSlot2Id).concreteValueType); }
}*/
/// <summary>
/// Gets the type of the property.*/
/// </summary>
/// <value>The type of the property.</value>
/*public override PropertyType propertyType {
get { return PropertyType.Vector4; }
}
public Vector4 value {
get { return m_Value; }
set {
if (m_Value == value)
return;
m_Value = value;
if (onModified != null)
onModified (this, ModificationScope.Node);
}
}*/
/*public override void GeneratePropertyBlock (PropertyGenerator visitor, GenerationMode generationMode)
protected virtual string GetFunctionCallBody(string inputValue1, string inputValue2, string inputValue3)
if (exposedState == ExposedState.Exposed)
visitor.AddShaderProperty (new VectorPropertyChunk (propertyName, description, m_Value, PropertyChunk.HideState.Visible));
return GetFunctionName() + " (" + inputValue1 + ", " + inputValue2 + ", " + inputValue3 + ")";
public override void GeneratePropertyUsages (ShaderGenerator visitor, GenerationMode generationMode)
public string outputDimension
if (exposedState == ExposedState.Exposed || generationMode.IsPreview ())
visitor.AddShaderChunk (precision + "3 " + propertyName + ";", false);
}*/
/*public void GenerateNodeCode (ShaderGenerator visitor, GenerationMode generationMode)
get { return ConvertConcreteSlotValueTypeToString(FindOutputSlot<MaterialSlot>(OutputSlotId).concreteValueType); }
}
private string input1Dimension
if (exposedState == ExposedState.Exposed || generationMode.IsPreview ())
return;
var input1Value = GetSlotValue (InputSlot1Id, generationMode);
var input2Value = GetSlotValue (InputSlot2Id, generationMode);
visitor.AddShaderChunk (precision + "4 " + propertyName + " = " + input1Value + " * ((" + input2Value + ".w - " + input2Value + ".z) + " + input2Value + ".z);", false);
get { return ConvertConcreteSlotValueTypeToString(FindInputSlot<MaterialSlot>(InputSlot1Id).concreteValueType); }
public override bool hasPreview {
get { return true; }
private string input2Dimension
{
get { return ConvertConcreteSlotValueTypeToString(FindInputSlot<MaterialSlot>(InputSlot2Id).concreteValueType); }
public override PreviewProperty GetPreviewProperty ()
public string input3Dimension
return new PreviewProperty {
m_Name = propertyName,
m_PropType = PropertyType.Vector4,
m_Vector4 = m_Value
};
}*/
get { return ConvertConcreteSlotValueTypeToString(FindInputSlot<MaterialSlot>(InputSlot3Id).concreteValueType); }
}
}
}

8
MaterialGraphProject/Assets/Rinaldo/BlendModeNode.cs


outputString.Deindent();
outputString.AddShaderChunk("}", false);
break;
case BlendModesEnum.Substract:
outputString.AddShaderChunk(GetFunctionPrototype("arg1", "arg2"), false);
outputString.AddShaderChunk("{", false);
outputString.Indent();
outputString.AddShaderChunk("return arg1 - arg2;", false);
outputString.Deindent();
outputString.AddShaderChunk("}", false);
break;
}
visitor.AddShaderChunk(outputString.GetShaderString(0), true);

2
MaterialGraphProject/Assets/Rinaldo/BlendModesEnum.cs


// PinLight,
Screen,
SoftLight,
// Substract,
Substract,
// VividLight

2
MaterialGraphProject/Assets/TestAssets/Sky1.jpg.meta


isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
cubemapConvolution: 1
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048

3
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/NodePreviewPresenter.cs


case PropertyType.Texture2D:
mat.SetTexture(previewProperty.m_Name, previewProperty.m_Texture);
break;
case PropertyType.Cubemap:
mat.SetTexture(previewProperty.m_Name, previewProperty.m_Cubemap);
break;
case PropertyType.Color:
mat.SetColor(previewProperty.m_Name, previewProperty.m_Color);
break;

12
MaterialGraphProject/Assets/Andre/CubemapNode.cs


protected const string kOutputSlotGName = "G";
protected const string kOutputSlotBName = "B";
protected const string kOutputSlotAName = "A";
protected const string kInputSlotLodName = "MipLevel";
public const int InputSlotLod = 6;
public const int OutputSlotRgbaId = 1;
public const int OutputSlotRId = 2;
public const int OutputSlotGId = 3;

AddSlot(new MaterialSlot(OutputSlotBId, kOutputSlotBName, kOutputSlotBName, SlotType.Output, SlotValueType.Vector1, Vector4.zero));
AddSlot(new MaterialSlot(OutputSlotAId, kOutputSlotAName, kOutputSlotAName, SlotType.Output, SlotValueType.Vector1, Vector4.zero));
AddSlot(new MaterialSlot(UvSlotId, kUVSlotName, kUVSlotName, SlotType.Input, SlotValueType.Vector3, Vector3.zero, false));
AddSlot (new MaterialSlot(InputSlotLod, kInputSlotLodName, kInputSlotLodName, SlotType.Input, SlotValueType.Vector1, Vector2.zero));
RemoveSlotsNameNotMatching(validSlots);
}

protected int[] validSlots
{
get { return new[] {OutputSlotRgbaId, OutputSlotRId, OutputSlotGId, OutputSlotBId, OutputSlotAId, UvSlotId}; }
get { return new[] {OutputSlotRgbaId, OutputSlotRId, OutputSlotGId, OutputSlotBId, OutputSlotAId, UvSlotId, InputSlotLod}; }
}
// Node generations

if (uvSlot == null)
return;
var lodID = FindInputSlot<MaterialSlot>(InputSlotLod);
if (lodID == null)
return;
//var lodValue = string.Format ("{0}", )
var edges = owner.GetEdges(uvSlot.slotReference).ToList();
if (edges.Count > 0)

uvName = ShaderGenerator.AdaptNodeOutput(fromNode, edge.outputSlot.slotId, ConcreteSlotValueType.Vector3, true);
}
string body = "texCUBE (" + propertyName + ", " + uvName + ")";
string body = "texCUBElod (" + propertyName + ", " + precision + "4(" + uvName + "," + lodID.currentValue.x + "))";
visitor.AddShaderChunk(precision + "4 " + GetVariableNameForNode() + " = " + body + ";", true);
}

9
MaterialGraphProject/Assets/Andre.meta


fileFormatVersion: 2
guid: cd5688ca09d4248698f2b43253441000
folderAsset: yes
timeCreated: 1495479128
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

12
MaterialGraphProject/Assets/Andre/CubemapNode.cs.meta


fileFormatVersion: 2
guid: c184bca342bb146daa708a7ecda424fc
timeCreated: 1495482070
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

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

9
MaterialGraphProject/Assets/Andre/New Shader Graph.ShaderGraph.meta


fileFormatVersion: 2
guid: 8c255d11f15384beb834142327f24126
timeCreated: 1495482510
licenseType: Pro
ScriptedImporter:
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 625f186215c104763be7675aa2d941aa, type: 3}

25
MaterialGraphProject/obj/Debug/Assembly-CSharp.csproj.FilesWrittenAbsolute.txt


/Users/andremcgrail/Documents/UnityProjects/External Projects/MaterialGraph/MaterialGraphProject/Temp/bin/Debug/Assembly-CSharp.dll.mdb
/Users/andremcgrail/Documents/UnityProjects/External Projects/MaterialGraph/MaterialGraphProject/Temp/bin/Debug/Assembly-CSharp.dll
/Users/andremcgrail/Documents/UnityProjects/External Projects/MaterialGraph/MaterialGraphProject/obj/Debug/Assembly-CSharp.dll
/Users/andremcgrail/Documents/UnityProjects/External Projects/MaterialGraph/MaterialGraphProject/obj/Debug/Assembly-CSharp.dll.mdb
/Users/andremcgrail/Documents/UnityProjects/External Projects/MaterialGraph/MaterialGraphProject/Temp/bin/Debug/UnityEngine.dll
/Users/andremcgrail/Documents/UnityProjects/External Projects/MaterialGraph/MaterialGraphProject/Temp/bin/Debug/UnityEditor.dll
/Users/andremcgrail/Documents/UnityProjects/External Projects/MaterialGraph/MaterialGraphProject/Temp/bin/Debug/UnityEngine.UI.dll
/Users/andremcgrail/Documents/UnityProjects/External Projects/MaterialGraph/MaterialGraphProject/Temp/bin/Debug/UnityEngine.Networking.dll
/Users/andremcgrail/Documents/UnityProjects/External Projects/MaterialGraph/MaterialGraphProject/Temp/bin/Debug/UnityEngine.PerformanceTesting.dll
/Users/andremcgrail/Documents/UnityProjects/External Projects/MaterialGraph/MaterialGraphProject/Temp/bin/Debug/UnityEngine.TestRunner.dll
/Users/andremcgrail/Documents/UnityProjects/External Projects/MaterialGraph/MaterialGraphProject/Temp/bin/Debug/nunit.framework.dll
/Users/andremcgrail/Documents/UnityProjects/External Projects/MaterialGraph/MaterialGraphProject/Temp/bin/Debug/UnityEngine.Timeline.dll
/Users/andremcgrail/Documents/UnityProjects/External Projects/MaterialGraph/MaterialGraphProject/Temp/bin/Debug/UnityEngine.UIAutomation.dll
/Users/andremcgrail/Documents/UnityProjects/External Projects/MaterialGraph/MaterialGraphProject/Temp/bin/Debug/UnityEngine.Analytics.dll
/Users/andremcgrail/Documents/UnityProjects/External Projects/MaterialGraph/MaterialGraphProject/Temp/bin/Debug/UnityEngine.HoloLens.dll
/Users/andremcgrail/Documents/UnityProjects/External Projects/MaterialGraph/MaterialGraphProject/Temp/bin/Debug/Mono.Cecil.dll
/Users/andremcgrail/Documents/UnityProjects/External Projects/MaterialGraph/MaterialGraphProject/Temp/bin/Debug/Unity.SerializationLogic.dll
/Users/andremcgrail/Documents/UnityProjects/External Projects/MaterialGraph/MaterialGraphProject/Temp/bin/Debug/Unity.DataContract.dll
/Users/andremcgrail/Documents/UnityProjects/External Projects/MaterialGraph/MaterialGraphProject/Temp/bin/Debug/ExCSS.Unity.dll
/Users/andremcgrail/Documents/UnityProjects/External Projects/MaterialGraph/MaterialGraphProject/Temp/bin/Debug/Unity.Legacy.NRefactory.dll
/Users/andremcgrail/Documents/UnityProjects/External Projects/MaterialGraph/MaterialGraphProject/Temp/bin/Debug/Unity.UNetWeaver.dll
/Users/andremcgrail/Documents/UnityProjects/External Projects/MaterialGraph/MaterialGraphProject/Temp/bin/Debug/Unity.UNetWeaver.dll.mdb
/Users/andremcgrail/Documents/UnityProjects/External Projects/MaterialGraph/MaterialGraphProject/Temp/bin/Debug/Unity.CecilTools.dll
/Users/andremcgrail/Documents/UnityProjects/External Projects/MaterialGraph/MaterialGraphProject/Temp/bin/Debug/Mono.Cecil.Pdb.dll
/Users/andremcgrail/Documents/UnityProjects/External Projects/MaterialGraph/MaterialGraphProject/Temp/bin/Debug/Mono.Cecil.Mdb.dll

1001
MaterialGraphProject/obj/Debug/Assembly-CSharp.dll
文件差异内容过多而无法显示
查看文件

171
MaterialGraphProject/obj/Debug/Assembly-CSharp.dll.mdb
文件差异内容过多而无法显示
查看文件

8
MaterialGraphProject/Assets/Matt&Andre/CubemapNode.cs.meta


fileFormatVersion: 2
guid: c184bca342bb146daa708a7ecda424fc
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

/MaterialGraphProject/Assets/Matt&Andre/CubemapNode.cs → /MaterialGraphProject/Assets/Andre/CubemapNode.cs

正在加载...
取消
保存