Matt Dean
7 年前
当前提交
dadccc50
共有 26 个文件被更改,包括 604 次插入 和 477 次删除
-
1.gitignore
-
23MaterialGraphProject/Assets/NewNodes/Editor/Keep/HeightToNormalNode.cs
-
268MaterialGraphProject/Assets/PartyPreview.ShaderGraph
-
27MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/AbstractMaterialGraph.cs
-
2MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/LightweightPipeline/LightweightMetallicMasterNode.cs
-
2MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/LightweightPipeline/LightweightSpecularMasterNode.cs
-
18MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Controls/EnumControl.cs
-
7MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Controls/VectorControl.cs
-
46MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/GraphInspectorView.cs
-
4MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/MaterialGraphEditWindow.cs
-
185MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/PreviewManager.cs
-
4MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/GraphEditorView.cs
-
60MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/MaterialNodeView.cs
-
8MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/PortInputView.cs
-
5MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/Slots/MultiFloatSlotControlView.cs
-
126MaterialGraphProject/Assets/UnityShaderEditor/Editor/Resources/Styles/MaterialGraph.uss
-
2MaterialGraphProject/ProjectSettings/ProjectVersion.txt
-
8MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Artistic/Mask.meta
-
79MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Controls/ChannelEnumControl.cs
-
3MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Controls/ChannelEnumControl.cs.meta
-
37MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Artistic/Mask/ColorMaskNode.cs
-
11MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Artistic/Mask/ColorMaskNode.cs.meta
-
11MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Artistic/Mask/ChannelMaskNode.cs.meta
-
124MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Artistic/Mask/ChannelMaskNode.cs
-
20MaterialGraphProject/ProjectSettings/EditorSettings.asset
268
MaterialGraphProject/Assets/PartyPreview.ShaderGraph
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
|
|||
m_EditorVersion: 2018.1.0a6 |
|||
m_EditorVersion: 2018.1.0a7 |
|
|||
fileFormatVersion: 2 |
|||
guid: cdb8c403de0823942a95a464c32ad0f0 |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.Reflection; |
|||
using UnityEngine; |
|||
using UnityEditor.Graphing; |
|||
using UnityEngine.Experimental.UIElements; |
|||
|
|||
namespace UnityEditor.ShaderGraph.Drawing.Controls |
|||
{ |
|||
[AttributeUsage(AttributeTargets.Property)] |
|||
public class ChannelEnumControlAttribute : Attribute, IControlAttribute |
|||
{ |
|||
string m_Label; |
|||
int m_SlotId; |
|||
|
|||
public ChannelEnumControlAttribute(string label = null, int slotId = 0) |
|||
{ |
|||
m_Label = label; |
|||
m_SlotId = slotId; |
|||
} |
|||
|
|||
public VisualElement InstantiateControl(AbstractMaterialNode node, PropertyInfo propertyInfo) |
|||
{ |
|||
return new ChannelEnumControlView(m_Label, m_SlotId, node, propertyInfo); |
|||
} |
|||
} |
|||
|
|||
public class ChannelEnumControlView : VisualElement, INodeModificationListener |
|||
{ |
|||
GUIContent m_Label; |
|||
AbstractMaterialNode m_Node; |
|||
PropertyInfo m_PropertyInfo; |
|||
IMGUIContainer m_Container; |
|||
int m_SlotId; |
|||
|
|||
public ChannelEnumControlView(string label, int slotId, AbstractMaterialNode node, PropertyInfo propertyInfo) |
|||
{ |
|||
m_Node = node; |
|||
m_PropertyInfo = propertyInfo; |
|||
m_SlotId = slotId; |
|||
if (!propertyInfo.PropertyType.IsEnum) |
|||
throw new ArgumentException("Property must be an enum.", "propertyInfo"); |
|||
m_Label = new GUIContent(label ?? ObjectNames.NicifyVariableName(propertyInfo.Name)); |
|||
m_Container = new IMGUIContainer(OnGUIHandler); |
|||
Add(m_Container); |
|||
} |
|||
|
|||
void OnGUIHandler() |
|||
{ |
|||
UpdatePopup(); |
|||
} |
|||
|
|||
public void OnNodeModified(ModificationScope scope) |
|||
{ |
|||
if (scope == ModificationScope.Graph) |
|||
m_Container.Dirty(ChangeType.Repaint); |
|||
} |
|||
|
|||
private void UpdatePopup() |
|||
{ |
|||
var value = (int)m_PropertyInfo.GetValue(m_Node, null); |
|||
using (var changeCheckScope = new EditorGUI.ChangeCheckScope()) |
|||
{ |
|||
int channelCount = (int)SlotValueHelper.GetChannelCount(m_Node.FindSlot<MaterialSlot>(m_SlotId).concreteValueType); |
|||
var enumEntryCount = (Enum)m_PropertyInfo.GetValue(m_Node, null); |
|||
string[] enumEntryNames = Enum.GetNames(enumEntryCount.GetType()); |
|||
string[] popupEntries = new string[channelCount]; |
|||
for (int i = 0; i < popupEntries.Length; i++) |
|||
popupEntries[i] = enumEntryNames[i]; |
|||
value = EditorGUILayout.Popup(m_Label, value, popupEntries); |
|||
|
|||
if (changeCheckScope.changed) |
|||
{ |
|||
m_Node.owner.owner.RegisterCompleteObjectUndo("Change " + m_Node.name); |
|||
m_PropertyInfo.SetValue(m_Node, value, null); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 74fdde12d8253bd4c874acc555be0585 |
|||
timeCreated: 1507817885 |
|
|||
using System.Reflection; |
|||
using UnityEngine; |
|||
|
|||
namespace UnityEditor.ShaderGraph |
|||
{ |
|||
[Title("Artistic/Mask/Color Mask")] |
|||
public class ColorMaskNode : CodeFunctionNode |
|||
{ |
|||
public ColorMaskNode() |
|||
{ |
|||
name = "Color Mask"; |
|||
} |
|||
|
|||
protected override MethodInfo GetFunctionToConvert() |
|||
{ |
|||
return GetType().GetMethod("Unity_ColorMask", BindingFlags.Static | BindingFlags.NonPublic); |
|||
} |
|||
|
|||
static string Unity_ColorMask( |
|||
[Slot(0, Binding.None)] Vector3 In, |
|||
[Slot(1, Binding.None)] Color MaskColor, |
|||
[Slot(2, Binding.None)] Vector1 Range, |
|||
[Slot(3, Binding.None)] out Vector3 Out) |
|||
{ |
|||
Out = Vector3.zero; |
|||
return |
|||
@"
|
|||
{ |
|||
{precision}3 col = {precision}3(0, 0, 0); |
|||
{precision} Distance = distance(MaskColor, In); |
|||
if(Distance <= Range) |
|||
col = {precision}3(1, 1, 1); |
|||
Out = col; |
|||
}";
|
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 19255c24842f72c4c94c21b682a3e170 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: e3fd76d77a796b641ba3e9149086efc2 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Reflection; |
|||
using UnityEngine; |
|||
using UnityEditor.Graphing; |
|||
using UnityEditor.ShaderGraph.Drawing.Controls; |
|||
|
|||
namespace UnityEditor.ShaderGraph |
|||
{ |
|||
public enum TextureChannel |
|||
{ |
|||
Red, |
|||
Green, |
|||
Blue, |
|||
Alpha |
|||
} |
|||
|
|||
[Title("Artistic/Mask/Channel Mask")] |
|||
public class ChannelMaskNode : AbstractMaterialNode, IGeneratesBodyCode, IGeneratesFunction |
|||
{ |
|||
public ChannelMaskNode() |
|||
{ |
|||
name = "Channel Mask"; |
|||
UpdateNodeAfterDeserialization(); |
|||
} |
|||
|
|||
const int InputSlotId = 0; |
|||
const int OutputSlotId = 1; |
|||
const string kInputSlotName = "In"; |
|||
const string kOutputSlotName = "Out"; |
|||
|
|||
public override bool hasPreview |
|||
{ |
|||
get { return true; } |
|||
} |
|||
|
|||
string GetFunctionName() |
|||
{ |
|||
return string.Format("Unity_ChannelMask_{0}_{1}", channel, precision); |
|||
} |
|||
|
|||
public sealed override void UpdateNodeAfterDeserialization() |
|||
{ |
|||
AddSlot(new DynamicVectorMaterialSlot(InputSlotId, kInputSlotName, kInputSlotName, SlotType.Input, Vector3.zero)); |
|||
AddSlot(new DynamicVectorMaterialSlot(OutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, Vector3.zero)); |
|||
RemoveSlotsNameNotMatching(new[] { InputSlotId, OutputSlotId }); |
|||
} |
|||
|
|||
[SerializeField] |
|||
private TextureChannel m_Channel = TextureChannel.Red; |
|||
|
|||
[ChannelEnumControl("Channel")] |
|||
public TextureChannel channel |
|||
{ |
|||
get { return m_Channel; } |
|||
set |
|||
{ |
|||
if (m_Channel == value) |
|||
return; |
|||
|
|||
m_Channel = value; |
|||
if (onModified != null) |
|||
{ |
|||
onModified(this, ModificationScope.Graph); |
|||
} |
|||
} |
|||
} |
|||
|
|||
void ValidateChannelCount() |
|||
{ |
|||
int channelCount = (int)SlotValueHelper.GetChannelCount(FindSlot<MaterialSlot>(InputSlotId).concreteValueType); |
|||
if ((int)channel >= channelCount) |
|||
channel = TextureChannel.Red; |
|||
} |
|||
|
|||
string GetFunctionPrototype(string argIn, string argOut) |
|||
{ |
|||
return string.Format("void {0} ({1} {2}, out {3} {4})", GetFunctionName(), |
|||
ConvertConcreteSlotValueTypeToString(precision, FindInputSlot<DynamicVectorMaterialSlot>(InputSlotId).concreteValueType), argIn, |
|||
ConvertConcreteSlotValueTypeToString(precision, FindOutputSlot<DynamicVectorMaterialSlot>(OutputSlotId).concreteValueType), argOut); |
|||
} |
|||
|
|||
public void GenerateNodeCode(ShaderGenerator visitor, GenerationMode generationMode) |
|||
{ |
|||
ValidateChannelCount(); |
|||
string inputValue = GetSlotValue(InputSlotId, generationMode); |
|||
string outputValue = GetSlotValue(OutputSlotId, generationMode); |
|||
visitor.AddShaderChunk(string.Format("{0} {1};", ConvertConcreteSlotValueTypeToString(precision, FindInputSlot<MaterialSlot>(InputSlotId).concreteValueType), GetVariableNameForSlot(OutputSlotId)), true); |
|||
visitor.AddShaderChunk(GetFunctionCallBody(inputValue, outputValue), true); |
|||
} |
|||
|
|||
string GetFunctionCallBody(string inputValue, string outputValue) |
|||
{ |
|||
return GetFunctionName() + " (" + inputValue + ", " + outputValue + ");"; |
|||
} |
|||
|
|||
public void GenerateNodeFunction(ShaderGenerator visitor, GenerationMode generationMode) |
|||
{ |
|||
ValidateChannelCount(); |
|||
var outputString = new ShaderGenerator(); |
|||
outputString.AddShaderChunk(GetFunctionPrototype("In", "Out"), false); |
|||
outputString.AddShaderChunk("{", false); |
|||
outputString.Indent(); |
|||
|
|||
switch(channel) |
|||
{ |
|||
case TextureChannel.Green: |
|||
outputString.AddShaderChunk("Out = In.yyyy;", false); |
|||
break; |
|||
case TextureChannel.Blue: |
|||
outputString.AddShaderChunk("Out = In.zzzz;", false); |
|||
break; |
|||
case TextureChannel.Alpha: |
|||
outputString.AddShaderChunk("Out = In.wwww;", false); |
|||
break; |
|||
default: |
|||
outputString.AddShaderChunk("Out = In.xxxx;", false); |
|||
break; |
|||
} |
|||
|
|||
outputString.Deindent(); |
|||
outputString.AddShaderChunk("}", false); |
|||
visitor.AddShaderChunk(outputString.GetShaderString(0), true); |
|||
} |
|||
} |
|||
} |
|
|||
%YAML 1.1 |
|||
%TAG !u! tag:unity3d.com,2011: |
|||
--- !u!159 &1 |
|||
EditorSettings: |
|||
m_ObjectHideFlags: 0 |
|||
serializedVersion: 5 |
|||
m_ExternalVersionControlSupport: Visible Meta Files |
|||
m_SerializationMode: 2 |
|||
m_DefaultBehaviorMode: 0 |
|||
m_SpritePackerMode: 2 |
|||
m_SpritePackerPaddingPower: 1 |
|||
m_EtcTextureCompressorBehavior: 0 |
|||
m_EtcTextureFastCompressor: 0 |
|||
m_EtcTextureNormalCompressor: 2 |
|||
m_EtcTextureBestCompressor: 5 |
|||
m_ProjectGenerationIncludedExtensions: txt;xml;fnt;cd;uss |
|||
m_ProjectGenerationRootNamespace: |
|||
m_UserGeneratedProjectSuffix: |
|||
m_CollabEditorSettings: |
|||
inProgressEnabled: 1 |
撰写
预览
正在加载...
取消
保存
Reference in new issue