浏览代码
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 年前
当前提交
f13a8ff6
共有 20 个文件被更改,包括 455 次插入 和 30 次删除
-
2MaterialGraphProject/Assets/Eduardo/EduardoTestGraph.ShaderGraph
-
2MaterialGraphProject/Assets/Eduardo/FunctionNInNOut.cs
-
2MaterialGraphProject/Assets/Eduardo/HeightToNormalNode.cs
-
2MaterialGraphProject/Assets/Matt/SubsurfaceMaster.ShaderGraph
-
14MaterialGraphProject/Assets/Rinaldo/BlendModeNode.cs
-
2MaterialGraphProject/Assets/Rinaldo/BlendModesEnum.cs
-
2MaterialGraphProject/Assets/Rinaldo/Editor/BlendModeNodePresenter.cs
-
10MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/AbstractMaterialNode.cs
-
12MaterialGraphProject/Assets/Vlad/TextureAssetNode.cs
-
15MaterialGraphProject/Assets/Vlad/UVTriPlanar.cs
-
46MaterialGraphProject/Assets/Eduardo/ChannelBlendNode.cs
-
12MaterialGraphProject/Assets/Eduardo/ChannelBlendNode.cs.meta
-
20MaterialGraphProject/Assets/Eduardo/ReciprocalSqrtNode.cs
-
12MaterialGraphProject/Assets/Eduardo/ReciprocalSqrtNode.cs.meta
-
1MaterialGraphProject/Assets/Matt/ClothMaster.ShaderGraph
-
9MaterialGraphProject/Assets/Matt/ClothMaster.ShaderGraph.meta
-
96MaterialGraphProject/Assets/Matt/ClothMasterNode.cs
-
12MaterialGraphProject/Assets/Matt/ClothMasterNode.cs.meta
-
202MaterialGraphProject/Assets/NewNodes/WIP/MultiLayerParallaxNode.cs
-
12MaterialGraphProject/Assets/NewNodes/WIP/MultiLayerParallaxNode.cs.meta
2
MaterialGraphProject/Assets/Eduardo/EduardoTestGraph.ShaderGraph
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
2
MaterialGraphProject/Assets/Matt/SubsurfaceMaster.ShaderGraph
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
|
|||
using UnityEngine.Graphing; |
|||
using System.Linq; |
|||
using System.Collections; |
|||
|
|||
namespace UnityEngine.MaterialGraph |
|||
{ |
|||
[Title("Art/ChannelBlend")] |
|||
public class ChannelBlend : FunctionNInNOut, IGeneratesFunction |
|||
{ |
|||
|
|||
public ChannelBlend() |
|||
{ |
|||
name = "ChannelBlend"; |
|||
AddSlot("Mask", "mask", Graphing.SlotType.Input, SlotValueType.Vector4, Vector4.zero); |
|||
AddSlot("RColor", "rCol", Graphing.SlotType.Input, SlotValueType.Vector4, Vector4.zero); |
|||
AddSlot("GColor", "gCol", Graphing.SlotType.Input, SlotValueType.Vector4, Vector4.zero); |
|||
AddSlot("BColor", "bCol", Graphing.SlotType.Input, SlotValueType.Vector4, Vector4.zero); |
|||
AddSlot("AColor", "aCol", Graphing.SlotType.Input, SlotValueType.Vector4, Vector4.zero); |
|||
AddSlot("BGColor", "bgCol", Graphing.SlotType.Input, SlotValueType.Vector4, Vector4.zero); |
|||
|
|||
AddSlot("BlendedColor", "blendCol", Graphing.SlotType.Output, SlotValueType.Vector4, Vector4.zero); |
|||
} |
|||
|
|||
protected override string GetFunctionName() |
|||
{ |
|||
return "unity_ChannelBlend"; |
|||
} |
|||
|
|||
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("float4 background = step(max(mask.r,max(mask.g,mask.b)), 0.001) * bgCol;", false); |
|||
outputString.AddShaderChunk("blendCol = mask.r * rCol + mask.g * gCol + mask.b * bCol + mask.a * aCol + background;", false); |
|||
outputString.AddShaderChunk("}", false); |
|||
|
|||
visitor.AddShaderChunk(outputString.GetShaderString(0), true); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: a3ee559026fa1ca4aab68fafbdcfbc56 |
|||
timeCreated: 1495618140 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
namespace UnityEngine.MaterialGraph |
|||
{ |
|||
[Title("Math/Advanced/Reciprocal Square Root")] |
|||
public class ReciprocalSqrtNode : Function1Input |
|||
{ |
|||
public ReciprocalSqrtNode() |
|||
{ |
|||
name = "ReciprocalSquareRoot"; |
|||
} |
|||
|
|||
public override bool hasPreview |
|||
{ |
|||
get { return false; } |
|||
} |
|||
|
|||
protected override string GetFunctionName() { return "rsqrt"; } |
|||
} |
|||
} |
|||
|
|||
|
|
|||
fileFormatVersion: 2 |
|||
guid: d67c532974f20f74ca83c79573c45a61 |
|||
timeCreated: 1495627989 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
1
MaterialGraphProject/Assets/Matt/ClothMaster.ShaderGraph
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
|
|||
fileFormatVersion: 2 |
|||
guid: c6f272d98c8edc642b85922a6d8ffe9c |
|||
timeCreated: 1495626442 |
|||
licenseType: Pro |
|||
ScriptedImporter: |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|||
script: {fileID: 11500000, guid: 625f186215c104763be7675aa2d941aa, type: 3} |
|
|||
using System; |
|||
using UnityEngine.Graphing; |
|||
|
|||
namespace UnityEngine.MaterialGraph |
|||
{ |
|||
[Serializable] |
|||
[Title("Master/Cloth")] |
|||
public class ClothMasterNode : AbstractAdvancedMasterNode |
|||
{ |
|||
//public const string MetallicSlotName = "Metallic";
|
|||
//public const int MetallicSlotId = 2;
|
|||
|
|||
public const string FuzzSlotName = "Fuzz"; |
|||
public const int FuzzSlotId = 9; |
|||
|
|||
public const string ClothFactorSlotName = "ClothFactor"; |
|||
public const int ClothFactorSlotId = 10; |
|||
|
|||
public const string LightFunctionName = "Advanced"; |
|||
public const string SurfaceOutputStructureName = "SurfaceOutputAdvanced"; |
|||
|
|||
public ClothMasterNode() |
|||
{ |
|||
name = "Cloth"; |
|||
UpdateNodeAfterDeserialization(); |
|||
} |
|||
|
|||
public override string GetMaterialID() |
|||
{ |
|||
return "SHADINGMODELID_CLOTH"; |
|||
} |
|||
|
|||
public override int[] GetCustomDataSlots() |
|||
{ |
|||
return new int[] { 9, 10 }; |
|||
} |
|||
|
|||
public override string[] GetCustomData() |
|||
{ |
|||
string fuzzInput = GetVariableNameForSlotAtId(9); |
|||
if (fuzzInput == "") |
|||
fuzzInput = "float3(0,0,0)"; |
|||
else |
|||
fuzzInput = fuzzInput + ".rgb"; |
|||
string clothFactorInput = GetVariableNameForSlotAtId(10); |
|||
if (clothFactorInput == "") |
|||
clothFactorInput = "0"; |
|||
else |
|||
clothFactorInput = clothFactorInput + ".r"; |
|||
return new string[] { "o.CustomData = float4(" + fuzzInput + ", "+ clothFactorInput + ");" }; |
|||
} |
|||
|
|||
public sealed override void UpdateNodeAfterDeserialization() |
|||
{ |
|||
AddSlot(new MaterialSlot(AlbedoSlotId, AlbedoSlotName, AlbedoSlotName, SlotType.Input, SlotValueType.Vector3, Vector4.zero)); |
|||
AddSlot(new MaterialSlot(NormalSlotId, NormalSlotName, NormalSlotName, SlotType.Input, SlotValueType.Vector3, Vector4.zero)); |
|||
AddSlot(new MaterialSlot(EmissionSlotId, EmissionSlotName, EmissionSlotName, SlotType.Input, SlotValueType.Vector3, Vector4.zero)); |
|||
//AddSlot(new MaterialSlot(MetallicSlotId, MetallicSlotName, MetallicSlotName, SlotType.Input, SlotValueType.Vector1, Vector4.zero));
|
|||
AddSlot(new MaterialSlot(SmoothnessSlotId, SmoothnessSlotName, SmoothnessSlotName, SlotType.Input, SlotValueType.Vector1, Vector4.zero)); |
|||
AddSlot(new MaterialSlot(OcclusionSlotId, OcclusionSlotName, OcclusionSlotName, SlotType.Input, SlotValueType.Vector1, Vector4.zero)); |
|||
AddSlot(new MaterialSlot(AnisotropySlotId, AnisotropySlotName, AnisotropySlotName, SlotType.Input, SlotValueType.Vector1, Vector4.zero)); |
|||
AddSlot(new MaterialSlot(TangentSlotId, TangentSlotName, TangentSlotName, SlotType.Input, SlotValueType.Vector3, Vector4.zero)); |
|||
AddSlot(new MaterialSlot(AnisotropySlotId, AnisotropySlotName, AnisotropySlotName, SlotType.Input, SlotValueType.Vector1, Vector4.zero)); |
|||
AddSlot(new MaterialSlot(FuzzSlotId, FuzzSlotName, FuzzSlotName, SlotType.Input, SlotValueType.Vector3, Vector4.zero)); |
|||
AddSlot(new MaterialSlot(ClothFactorSlotId, ClothFactorSlotName, ClothFactorSlotName, SlotType.Input, SlotValueType.Vector1, Vector4.zero)); |
|||
|
|||
// clear out slot names that do not match the slots
|
|||
// we support
|
|||
RemoveSlotsNameNotMatching( |
|||
new[] |
|||
{ |
|||
AlbedoSlotId, |
|||
NormalSlotId, |
|||
EmissionSlotId, |
|||
//MetallicSlotId,
|
|||
SmoothnessSlotId, |
|||
OcclusionSlotId, |
|||
AlphaSlotId, |
|||
AnisotropySlotId, |
|||
TangentSlotId, |
|||
FuzzSlotId, |
|||
ClothFactorSlotId |
|||
}); |
|||
} |
|||
|
|||
public override string GetSurfaceOutputName() |
|||
{ |
|||
return SurfaceOutputStructureName; |
|||
} |
|||
|
|||
public override string GetLightFunction() |
|||
{ |
|||
return LightFunctionName; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 4a9c7c58817be884f8b788d9e11dbef0 |
|||
timeCreated: 1478188276 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using UnityEngine.Graphing; |
|||
|
|||
namespace UnityEngine.MaterialGraph |
|||
{ |
|||
[Title("UV/MultiLayerParallax")] |
|||
public class MultiLayerParallaxNode : AbstractMaterialNode, IGeneratesBodyCode, IGeneratesFunction, IMayRequireMeshUV, IMayRequireViewDirectionTangentSpace |
|||
{ |
|||
protected const string kInputDepthShaderName = "Depth"; |
|||
protected const string kInputFadeRateShaderName = "FadeRate"; |
|||
protected const string kInputLayerCountShaderName = "LayerCount"; |
|||
protected const string kTextureSlotShaderName = "Texture"; |
|||
protected const string kOutputSlotShaderName = "Result"; |
|||
|
|||
public const int InputDepthSlotId = 0; // 'depth'
|
|||
public const int InputFadeRateSlotId = 1; // 'fade_rate'
|
|||
public const int InputLayerCountSlotId = 2; // 'layer_count'
|
|||
public const int TextureSlotId = 3; // 'tex'
|
|||
public const int OutputSlotId = 4; // 'result'
|
|||
|
|||
public override bool hasPreview |
|||
{ |
|||
get { return true; } |
|||
} |
|||
|
|||
public override PreviewMode previewMode |
|||
{ |
|||
get |
|||
{ |
|||
return PreviewMode.Preview3D; |
|||
} |
|||
} |
|||
|
|||
public MultiLayerParallaxNode() |
|||
{ |
|||
name = "MultiLayerParallax"; |
|||
UpdateNodeAfterDeserialization(); |
|||
} |
|||
|
|||
public string GetFunctionName() |
|||
{ |
|||
return "unity_multilayer_parallax_" + precision; |
|||
} |
|||
|
|||
public sealed override void UpdateNodeAfterDeserialization() |
|||
{ |
|||
AddSlot(GetInputDepthSlot()); |
|||
AddSlot(GetInputFadeRateSlot()); |
|||
AddSlot(GetInputLayerCountSlot()); |
|||
AddSlot(GetTextureSlot()); |
|||
AddSlot(GetOutputSlot()); |
|||
RemoveSlotsNameNotMatching(validSlots); |
|||
} |
|||
|
|||
protected int[] validSlots |
|||
{ |
|||
get { return new[] { InputDepthSlotId, InputFadeRateSlotId, InputLayerCountSlotId, TextureSlotId, OutputSlotId }; } |
|||
} |
|||
|
|||
protected virtual MaterialSlot GetInputDepthSlot() |
|||
{ |
|||
return new MaterialSlot(InputDepthSlotId, GetInputSlot1Name(), kInputDepthShaderName, SlotType.Input, SlotValueType.Vector1, Vector4.zero); |
|||
} |
|||
|
|||
protected virtual MaterialSlot GetInputFadeRateSlot() |
|||
{ |
|||
return new MaterialSlot(InputFadeRateSlotId, GetInputSlot2Name(), kInputFadeRateShaderName, SlotType.Input, SlotValueType.Dynamic, Vector4.zero); |
|||
} |
|||
|
|||
protected virtual MaterialSlot GetInputLayerCountSlot() |
|||
{ |
|||
return new MaterialSlot(InputLayerCountSlotId, GetInputSlot3Name(), kInputLayerCountShaderName, SlotType.Input, SlotValueType.Dynamic, Vector4.zero); |
|||
} |
|||
|
|||
protected virtual MaterialSlot GetTextureSlot() |
|||
{ |
|||
return new MaterialSlot(TextureSlotId, GetTextureSlotName(), kTextureSlotShaderName, SlotType.Input, SlotValueType.sampler2D, Vector4.zero); |
|||
} |
|||
|
|||
protected virtual MaterialSlot GetOutputSlot() |
|||
{ |
|||
return new MaterialSlot(OutputSlotId, GetOutputSlotName(), kOutputSlotShaderName, SlotType.Output, SlotValueType.Dynamic, Vector4.zero); |
|||
} |
|||
protected virtual string GetInputSlot1Name() |
|||
{ |
|||
return kInputDepthShaderName; |
|||
} |
|||
protected virtual string GetInputSlot2Name() |
|||
{ |
|||
return kInputFadeRateShaderName; |
|||
} |
|||
|
|||
protected virtual string GetInputSlot3Name() |
|||
{ |
|||
return kInputLayerCountShaderName; |
|||
} |
|||
|
|||
protected virtual string GetTextureSlotName() |
|||
{ |
|||
return kTextureSlotShaderName; |
|||
} |
|||
protected virtual string GetOutputSlotName() |
|||
{ |
|||
return kOutputSlotShaderName; |
|||
} |
|||
|
|||
private string input1Dimension |
|||
{ |
|||
get { return ConvertConcreteSlotValueTypeToString(FindInputSlot<MaterialSlot>(InputDepthSlotId).concreteValueType); } |
|||
} |
|||
|
|||
private string input2Dimension |
|||
{ |
|||
get { return ConvertConcreteSlotValueTypeToString(FindInputSlot<MaterialSlot>(InputFadeRateSlotId).concreteValueType); } |
|||
} |
|||
private string input3Dimension |
|||
{ |
|||
get { return ConvertConcreteSlotValueTypeToString(FindInputSlot<MaterialSlot>(InputLayerCountSlotId).concreteValueType); } |
|||
} |
|||
|
|||
public string outputDimension |
|||
{ |
|||
get { return ConvertConcreteSlotValueTypeToString(FindOutputSlot<MaterialSlot>(OutputSlotId).concreteValueType); } |
|||
} |
|||
|
|||
protected virtual string GetFunctionPrototype(string depth, string fadeRate, string layerCount, string tex, string UVs, string viewTangentSpace) |
|||
{ |
|||
return "inline " + precision + outputDimension + " " + GetFunctionName() + " (" + |
|||
precision + input1Dimension + " " + depth + ", " + |
|||
precision + input2Dimension + " " + fadeRate + ", " + |
|||
precision + input3Dimension + " " + layerCount + ", " + |
|||
"sampler2D " + tex + ", " + |
|||
precision + "2 " + UVs + ", " + |
|||
precision + "3 " + viewTangentSpace + ")"; |
|||
} |
|||
|
|||
public void GenerateNodeCode(ShaderGenerator visitor, GenerationMode generationMode) |
|||
{ |
|||
NodeUtils.SlotConfigurationExceptionIfBadConfiguration(this, new[] { InputDepthSlotId, InputFadeRateSlotId, InputLayerCountSlotId, TextureSlotId }, new[] { OutputSlotId }); |
|||
string depthValue = GetSlotValue(InputDepthSlotId, generationMode); |
|||
string fadeRateValue = GetSlotValue(InputFadeRateSlotId, generationMode); |
|||
string layerCountValue = GetSlotValue(InputLayerCountSlotId, generationMode); |
|||
string textureValue = GetSlotValue(TextureSlotId, generationMode); |
|||
|
|||
visitor.AddShaderChunk( |
|||
precision + outputDimension + " " + GetVariableNameForSlot(OutputSlotId) + |
|||
" = " + GetFunctionCallBody(depthValue, fadeRateValue, layerCountValue, textureValue) + ";", true); |
|||
} |
|||
|
|||
public void GenerateNodeFunction(ShaderGenerator visitor, GenerationMode generationMode) |
|||
{ |
|||
var outputString = new ShaderGenerator(); |
|||
outputString.AddShaderChunk(GetFunctionPrototype("depth", "fadeRate", "layerCount", "tex", "UVs", "viewTangentSpace"), false); |
|||
outputString.AddShaderChunk("{", false); |
|||
outputString.Indent(); |
|||
|
|||
outputString.AddShaderChunk(precision + "2 texcoord = UVs;", false); |
|||
outputString.AddShaderChunk(precision + "2 offset = -viewTangentSpace.xy * depth / layerCount;", false); |
|||
|
|||
outputString.AddShaderChunk(precision + outputDimension + " result = 0.0f;", false); |
|||
outputString.AddShaderChunk(precision + outputDimension + " fade = 1.0f;", false); |
|||
outputString.AddShaderChunk(precision + " alpha = 0.0f;", false); |
|||
|
|||
outputString.AddShaderChunk("for (int i = 0; i < 10; i++) {", false); |
|||
outputString.Indent(); |
|||
|
|||
outputString.AddShaderChunk("result += fade * tex2D(tex, texcoord);", false); |
|||
outputString.AddShaderChunk("texcoord += offset;", false); |
|||
outputString.AddShaderChunk("fade *= fadeRate;", false); |
|||
|
|||
outputString.Deindent(); |
|||
outputString.AddShaderChunk("}", false); |
|||
|
|||
outputString.AddShaderChunk("return result / layerCount;", false); |
|||
|
|||
outputString.Deindent(); |
|||
outputString.AddShaderChunk("}", false); |
|||
|
|||
visitor.AddShaderChunk(outputString.GetShaderString(0), true); |
|||
} |
|||
|
|||
protected virtual string GetFunctionCallBody(string depthValue, string fadeRateValue, string layerCountValue, string texValue) |
|||
{ |
|||
return GetFunctionName() + " (" + |
|||
depthValue + ", " + |
|||
fadeRateValue + ", " + |
|||
layerCountValue + ", " + |
|||
texValue + ", " + |
|||
UVChannel.uv0.GetUVName() + ", " + |
|||
ShaderGeneratorNames.TangentSpaceViewDirection + ")"; |
|||
} |
|||
|
|||
public bool RequiresMeshUV(UVChannel channel) |
|||
{ |
|||
return channel == UVChannel.uv0; |
|||
} |
|||
public bool RequiresViewDirectionTangentSpace() |
|||
{ |
|||
return true; |
|||
} |
|||
} |
|||
} |
|||
|
|
|||
fileFormatVersion: 2 |
|||
guid: 1970e51ab882ec24cb06ec8cbbefd184 |
|||
timeCreated: 1495557243 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue