浏览代码

Add time checkbox

Make shorter GUIDs
/main
Tim Cooper 8 年前
当前提交
2e183994
共有 10 个文件被更改,包括 49 次插入30 次删除
  1. 9
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/AbstractGraphEditWindow.cs
  2. 8
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/Presenters/TitleBarPresenter.cs
  3. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Graphs/AbstractMaterialGraphAsset.cs
  4. 11
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/AbstractMaterialNode.cs
  5. 12
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Art/Adjustments/LevelsNode.cs
  6. 24
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Art/Filters/ConvolutionFilterNode.cs
  7. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Matrix/Matrix2Node.cs
  8. 5
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Matrix/Matrix3Node.cs
  9. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Matrix/Matrix4Node.cs
  10. 4
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/PropertyNode.cs

9
MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/AbstractGraphEditWindow.cs


[SerializeField]
private ScriptableObject m_ToLoad;
public static bool allowAlwaysRepaint = true;
return m_InMemoryAsset != null && m_InMemoryAsset.shouldRepaint;
return allowAlwaysRepaint && m_InMemoryAsset != null && m_InMemoryAsset.shouldRepaint;
}
}

}
}
}
}
public virtual void ToggleRequiresTime()
{
allowAlwaysRepaint = !allowAlwaysRepaint;
}
public void ChangeSelction(IGraphAsset newSelection, bool refocus = true)

8
MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/Presenters/TitleBarPresenter.cs


m_leftItems.Add(selectGraph);
var optionsItem = CreateInstance<TitleBarButtonPresenter>();
optionsItem.text = "Options";
optionsItem.text = "Time";
optionsItem.onClick += ToggleTime;
m_rightItems.Add(optionsItem);
}

m_Owner.UpdateAsset ();
m_Owner.UpdateAsset ();
}
void ToggleTime()
{
m_Owner.ToggleRequiresTime();
}
}
}

2
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Graphs/AbstractMaterialGraphAsset.cs


public bool shouldRepaint
{
get { return graph.GetNodes<AbstractMaterialNode>().OfType<IRequiresTime>().Any(); }
get { return graph.GetNodes<AbstractMaterialNode>().OfType<IRequiresTime>().Any(); }
}
public ScriptableObject GetScriptableObject()

11
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/AbstractMaterialNode.cs


namespace UnityEngine.MaterialGraph
{
public static class GuidEncoder
{
public static string Encode(Guid guid)
{
string enc = Convert.ToBase64String(guid.ToByteArray());
return String.Format("{0:X}", enc.GetHashCode());
}
}
[Serializable]
public abstract class AbstractMaterialNode : SerializableNode, IGenerateProperties
{

public virtual string GetVariableNameForNode()
{
return name + "_" + guid.ToString().Replace("-", "_");
return name + "_" + GuidEncoder.Encode(guid);
}
public sealed override void AddSlot(ISlot slot)

12
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Art/Adjustments/LevelsNode.cs


{
if (generationMode.IsPreview())
{
string propGuid = guid.ToString().Replace("-", "_");
var propGuid = GetVariableNameForNode();
visitor.AddShaderChunk(precision + " inputMin" + propGuid +";", true);
visitor.AddShaderChunk(precision + " inputMax" + propGuid + ";", true);
visitor.AddShaderChunk(precision + " inputInvGamma" + propGuid + ";", true);

return;
float inputInvGamma = 1.0f / m_InputGamma;
string propGuid = guid.ToString().Replace("-", "_");
var propGuid = GetVariableNameForNode();
visitor.AddShaderChunk(precision + " inputMin" + propGuid + " = " + m_InputMin + ";", true);
visitor.AddShaderChunk(precision + " inputMax" + propGuid + " = " + m_InputMax + ";", true);

protected override string GetFunctionCallBody(string inputValue)
{
string propGuid = guid.ToString().Replace("-", "_");
return GetFunctionName() + "(" + inputValue +
", inputMin" + propGuid +
string propGuid = GetVariableNameForNode();
return GetFunctionName() + "(" + inputValue +
", inputMin" + propGuid +
", inputMax" + propGuid +
", inputInvGamma" + propGuid +
", outputMin" + propGuid +

public override void CollectPreviewMaterialProperties(List<PreviewProperty> properties)
{
string propGuid = guid.ToString().Replace("-", "_");
var propGuid = GetVariableNameForNode();
base.CollectPreviewMaterialProperties(properties);
float inputInvGamma = 1.0f / m_InputGamma;

24
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Art/Filters/ConvolutionFilterNode.cs


public float GetConvolutionDivisor()
{
return m_ConvolutionFilter[6].w;
return m_ConvolutionFilter[6].w;
}
public void SetConvolutionDivisor(float value)

}
public float GetConvolutionWeight(int row, int col)
{
{
int vectorIndex;
int vectorOffset;
GetPositionInData(row, col, out vectorIndex, out vectorOffset);

case 0: return m_ConvolutionFilter[vectorIndex].x;
case 1: return m_ConvolutionFilter[vectorIndex].y;
case 2: return m_ConvolutionFilter[vectorIndex].z;
default: return m_ConvolutionFilter[vectorIndex].w;
case 0: return m_ConvolutionFilter[vectorIndex].x;
case 1: return m_ConvolutionFilter[vectorIndex].y;
case 2: return m_ConvolutionFilter[vectorIndex].z;
default: return m_ConvolutionFilter[vectorIndex].w;
}
}

{
if (generationMode.IsPreview())
{
string propGuid = guid.ToString().Replace("-", "_");
string propGuid = GetVariableNameForNode();
for (int i = 0; i < kNumConvolutionVector4; ++i)
{
visitor.AddShaderChunk(precision + "4 " + GetPropertyName(i, propGuid) + ";", true);

if (!generationMode.IsPreview())
{
string propGuid = guid.ToString().Replace("-", "_");
var propGuid = GetVariableNameForNode();
for (int i = 0; i < kNumConvolutionVector4; ++i)
{
visitor.AddShaderChunk(precision + "4 " + GetPropertyName(i, propGuid) + "=" + precision + "4 (" + m_ConvolutionFilter[i].x + ", " + m_ConvolutionFilter[i].y + ", " + m_ConvolutionFilter[i].z + ", " + m_ConvolutionFilter[i].w + ");", true);

string samplerName = GetSlotValue(InputSlot1Id, generationMode);
//uv
var uvSlot = FindInputSlot<MaterialSlot>(InputSlot2Id);
if (uvSlot == null)

protected string GetFunctionCallBody(string samplerName, string baseUv, string texelSize)
{
string propGuid = guid.ToString().Replace("-", "_");
var propGuid = GetVariableNameForNode();
return GetFunctionName() + " (" + samplerName + ", " + baseUv + ", "
+ GetPropertyName(0, propGuid) + ", "

protected override string GetFunctionPrototype(string arg1Name, string arg2Name)
{
string propGuid = guid.ToString().Replace("-", "_");
var propGuid = GetVariableNameForNode();
return "inline " + precision + "4 " + GetFunctionName() + " ("
+ "sampler2D " + arg1Name + ", "

public override void CollectPreviewMaterialProperties(List<PreviewProperty> properties)
{
base.CollectPreviewMaterialProperties(properties);
string propGuid = guid.ToString().Replace("-", "_");
var propGuid = GetVariableNameForNode();
for (int i = 0; i < kNumConvolutionVector4; ++i)
{
properties.Add(new PreviewProperty { m_Name = GetPropertyName(i, propGuid), m_PropType = PropertyType.Vector4, m_Vector4 = m_ConvolutionFilter[i] });

2
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Matrix/Matrix2Node.cs


{
get
{
return string.Format("{0}_{1}_Uniform", name, guid.ToString().Replace("-", "_"));
return string.Format("{0}_{1}_Uniform", name, GetVariableNameForNode());
}
}

5
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Matrix/Matrix3Node.cs


public string propertyName
{
get
{
return string.Format("{0}_{1}_Uniform", name, guid.ToString().Replace("-", "_"));
}
get { return string.Format("{0}_{1}_Uniform", name, GetVariableNameForNode()); }
}
public override string GetVariableNameForSlot(int slotId)

2
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Matrix/Matrix4Node.cs


{
get
{
return string.Format("{0}_{1}_Uniform", name, guid.ToString().Replace("-", "_"));
return string.Format("{0}_{1}_Uniform", name, GetVariableNameForNode());
}
}

4
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/PropertyNode.cs


[SerializeField]
private ExposedState m_Exposed = ExposedState.NotExposed;
public ExposedState exposedState
{
get

{
get
{
return string.Format("{0}_{1}_Uniform", name, guid.ToString().Replace("-", "_"));
return string.Format("{0}_{1}_Uniform", name, GetVariableNameForNode());
}
}

正在加载...
取消
保存