浏览代码

Merge pull request #163 from Unity-Technologies/node-bugfixes

Node bugfixes
/main
GitHub 7 年前
当前提交
c763baf4
共有 49 个文件被更改,包括 491 次插入142 次删除
  1. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/SamplerStateShaderProperty.cs
  2. 7
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/TextureSamplerState.cs
  3. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/UVMaterialSlot.cs
  4. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/LightweightPipeline/LightWeightPBRSubShader.cs
  5. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Artistic/Blend/BlendNode.cs
  6. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Artistic/Mask/ChannelMaskNode.cs
  7. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Artistic/Normal/NormalCreateNode.cs
  8. 19
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/CodeFunctionNode.cs
  9. 8
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Basic/TimeNode.cs
  10. 12
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/ScreenPositionNode.cs
  11. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/UVNode.cs
  12. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Scene/ReflectionProbeNode.cs
  13. 4
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Texture/SampleTexture2DNode.cs
  14. 6
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Advanced/LogNode.cs
  15. 4
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Advanced/ModuloNode.cs
  16. 4
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Advanced/PosterizeNode.cs
  17. 4
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Advanced/ReciprocalNode.cs
  18. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Advanced/ReciprocalSquareRootNode.cs
  19. 4
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Basic/DivideNode.cs
  20. 4
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Basic/MultiplyNode.cs
  21. 4
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Basic/PowerNode.cs
  22. 4
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Basic/SubtractNode.cs
  23. 6
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Interpolation/InverseLerpNode.cs
  24. 6
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Interpolation/LerpNode.cs
  25. 6
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Interpolation/SmoothstepNode.cs
  26. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Range/MinimumNode.cs
  27. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Range/OneMinusNode.cs
  28. 4
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Range/RemapNode.cs
  29. 4
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Round/StepNode.cs
  30. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Trigonometry/ArccosineNode.cs
  31. 4
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Vector/CrossProductNode.cs
  32. 4
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Vector/DotProductNode.cs
  33. 9
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Vector/FresnelEffectNode.cs
  34. 4
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Vector/ProjectionNode.cs
  35. 4
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Vector/ReflectionNode.cs
  36. 4
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Vector/RejectionNode.cs
  37. 162
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/UV/FlipbookNode.cs
  38. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/UV/TwirlNode.cs
  39. 23
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Util/GraphUtil.cs
  40. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Util/ShaderGenerator.cs
  41. 8
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Util/UvChannel.cs
  42. 90
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Controls/ChannelMixerControl.cs
  43. 3
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Controls/ColorControl.cs
  44. 51
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Controls/ToggleControl.cs
  45. 3
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/Slots/ColorRGBSlotControlView.cs
  46. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/Slots/ColorSlotControlView.cs
  47. 108
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Resources/Styles/MaterialGraph.uss
  48. 8
      MaterialGraphProject/Assets/UnityShaderEditor/ShaderGraphLibrary/Functions.hlsl
  49. 8
      MaterialGraphProject/Assets/UnityShaderEditor/ShaderGraphLibrary/ShaderVariables.hlsl

2
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/SamplerStateShaderProperty.cs


public override string GetPropertyDeclarationString(string delimiter = ";")
{
return string.Format(@"SAMPLER2D({0}){1}", referenceName, delimiter);
return string.Format(@"SAMPLER({0}){1}", referenceName, delimiter);
}
public override PreviewProperty GetPreviewMaterialProperty()

7
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/TextureSamplerState.cs


public enum FilterMode
{
Linear,
Point
Point,
Trilinear
Clamp
Clamp,
Mirror,
MirrorOnce
}
[SerializeField] private FilterMode m_filter = FilterMode.Linear;

2
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/UVMaterialSlot.cs


[Serializable]
public class UVMaterialSlot : Vector2MaterialSlot, IMayRequireMeshUV
{
private UVChannel m_Channel = UVChannel.uv0;
private UVChannel m_Channel = UVChannel.UV0;
public UVChannel channel
{

2
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/LightweightPipeline/LightWeightPBRSubShader.cs


modelRequiements.requiresBitangent |= NeededCoordinateSpace.World;
modelRequiements.requiresPosition |= NeededCoordinateSpace.World;
modelRequiements.requiresViewDir |= NeededCoordinateSpace.World;
modelRequiements.requiresMeshUVs.Add(UVChannel.uv1);
modelRequiements.requiresMeshUVs.Add(UVChannel.UV1);
GenerateApplicationVertexInputs(requirements.Union(modelRequiements), vertexInputs);
ShaderGenerator.GenerateSpaceTranslationSurfaceInputs(requirements.requiresNormal, InterpolatorType.Normal, surfaceInputs);

2
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Artistic/Blend/BlendNode.cs


[SerializeField]
BlendMode m_BlendMode = BlendMode.Overlay;
[EnumControl("")]
[EnumControl("Mode")]
public BlendMode blendMode
{
get { return m_BlendMode; }

2
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Artistic/Mask/ChannelMaskNode.cs


void ValidateChannelCount()
{
int channelCount = SlotValueHelper.GetChannelCount(FindSlot<MaterialSlot>(InputSlotId).concreteValueType);
if (channelMask > 1 << channelCount - 1)
if (channelMask >= 1 << channelCount)
channelMask = -1;
}

2
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Artistic/Normal/NormalCreateNode.cs


public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new Texture2DInputMaterialSlot(TextureInputId, k_TextureInputName, k_TextureInputName));
AddSlot(new UVMaterialSlot(UVInputId, k_UVInputName, k_UVInputName, UVChannel.uv0));
AddSlot(new UVMaterialSlot(UVInputId, k_UVInputName, k_UVInputName, UVChannel.UV0));
AddSlot(new SamplerStateMaterialSlot(SamplerInputId, k_SamplerInputName, k_SamplerInputName, SlotType.Input));
AddSlot(new Vector1MaterialSlot(OffsetInputId, k_OffsetInputName, k_OffsetInputName, SlotType.Input, 0.5f));
AddSlot(new Vector1MaterialSlot(StrengthInputId, k_StrengthInputName, k_StrengthInputName, SlotType.Input, 8f));

19
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/CodeFunctionNode.cs


foreach (var par in method.GetParameters())
{
var attribute = GetSlotAttribute(par);
var name = GraphUtil.ConvertCamelCase(par.Name, true);
s = new ColorRGBAMaterialSlot(attribute.slotId, par.Name, par.Name, SlotType.Input, attribute.defaultValue ?? Vector4.zero, hidden: attribute.hidden);
s = new ColorRGBAMaterialSlot(attribute.slotId, name, par.Name, SlotType.Input, attribute.defaultValue ?? Vector4.zero, hidden: attribute.hidden);
s = new ColorRGBAMaterialSlot(attribute.slotId, par.Name, par.Name, SlotType.Input, attribute.defaultValue ?? Vector4.zero, hidden: attribute.hidden);
s = new ColorRGBAMaterialSlot(attribute.slotId, name, par.Name, SlotType.Input, attribute.defaultValue ?? Vector4.zero, hidden: attribute.hidden);
s = new ColorRGBMaterialSlot(attribute.slotId, par.Name, par.Name, SlotType.Input, attribute.defaultValue ?? Vector4.zero, hidden: attribute.hidden);
s = new ColorRGBMaterialSlot(attribute.slotId, name, par.Name, SlotType.Input, attribute.defaultValue ?? Vector4.zero, hidden: attribute.hidden);
par.Name,
name,
s = CreateBoundSlot(attribute.binding, attribute.slotId, par.Name, par.Name, attribute.hidden);
s = CreateBoundSlot(attribute.binding, attribute.slotId, name, par.Name, attribute.hidden);
slots.Add(s);
m_Slots.Add(attribute);

case Binding.TangentSpacePosition:
return new PositionMaterialSlot(slotId, displayName, shaderOutputName, CoordinateSpace.Tangent);
case Binding.MeshUV0:
return new UVMaterialSlot(slotId, displayName, shaderOutputName, UVChannel.uv0);
return new UVMaterialSlot(slotId, displayName, shaderOutputName, UVChannel.UV0);
return new UVMaterialSlot(slotId, displayName, shaderOutputName, UVChannel.uv1);
return new UVMaterialSlot(slotId, displayName, shaderOutputName, UVChannel.UV1);
return new UVMaterialSlot(slotId, displayName, shaderOutputName, UVChannel.uv2);
return new UVMaterialSlot(slotId, displayName, shaderOutputName, UVChannel.UV2);
return new UVMaterialSlot(slotId, displayName, shaderOutputName, UVChannel.uv3);
return new UVMaterialSlot(slotId, displayName, shaderOutputName, UVChannel.UV3);
case Binding.ScreenPosition:
return new ScreenPositionMaterialSlot(slotId, displayName, shaderOutputName);
case Binding.ObjectSpaceViewDirection:

8
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Basic/TimeNode.cs


public class TimeNode : AbstractMaterialNode, IMayRequireTime
{
private const string kOutputSlotName = "Time";
private const string kOutputSlot1Name = "SinTime";
private const string kOutputSlot2Name = "CosTime";
private const string kOutputSlot3Name = "DeltaTime";
private const string kOutputSlot4Name = "SmoothDelta";
private const string kOutputSlot1Name = "Sine Time";
private const string kOutputSlot2Name = "Cosine Time";
private const string kOutputSlot3Name = "Delta Time";
private const string kOutputSlot4Name = "Smooth Delta";
public const int OutputSlotId = 0;
public const int OutputSlot1Id = 1;

12
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/ScreenPositionNode.cs


[SerializeField]
private ScreenSpaceType m_ScreenSpaceType = ScreenSpaceType.Default;
[EnumControl("")]
[EnumControl("Mode")]
public ScreenSpaceType screenSpaceType
{
get { return m_ScreenSpaceType; }

switch (m_ScreenSpaceType)
{
case ScreenSpaceType.Raw:
visitor.AddShaderChunk(string.Format("{0}4 {1} = In.{2};", precision, GetVariableNameForSlot(kOutputSlotId),
visitor.AddShaderChunk(string.Format("{0}4 {1} = IN.{2};", precision, GetVariableNameForSlot(kOutputSlotId),
string.Format("float4((In.{0}.xy / In.{0}.w) * 2 - 1, 0, 0)", ShaderGeneratorNames.ScreenPosition)), true);
string.Format("float4((IN.{0}.xy / IN.{0}.w) * 2 - 1, 0, 0)", ShaderGeneratorNames.ScreenPosition)), true);
string.Format("float4((In.{0}.xy / In.{0}.w) * 2 - 1, 0, 0)", ShaderGeneratorNames.ScreenPosition)), true);
string.Format("float4((IN.{0}.xy / IN.{0}.w) * 2 - 1, 0, 0)", ShaderGeneratorNames.ScreenPosition)), true);
string.Format("float4(In.{0}.x * _ScreenParams.x / _ScreenParams.y, In.{0}.y, 0, 0)", ShaderGeneratorNames.ScreenPosition)), true);
string.Format("float4({0}.x * _ScreenParams.x / _ScreenParams.y, {0}.y, 0, 0)", GetVariableNameForSlot(kOutputSlotId))), true);
string.Format("float4(In.{0}.xy / In.{0}.w, 0, 0)", ShaderGeneratorNames.ScreenPosition)), true);
string.Format("float4(IN.{0}.xy / IN.{0}.w, 0, 0)", ShaderGeneratorNames.ScreenPosition)), true);
break;
}
}

2
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/UVNode.cs


[SerializeField]
private UVChannel m_OutputChannel;
[EnumControl("")]
[EnumControl("Channel")]
public UVChannel uvChannel
{
get { return m_OutputChannel; }

2
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Scene/ReflectionProbeNode.cs


@"
{
{precision}3 reflectVec = reflect(-ViewDir, Normal);
Out = DecodeHDR(UNITY_SAMPLE_TEXCUBE_LOD(unity_SpecCube0, reflectVec, LOD), unity_SpecCube0_HDR);
Out = DecodeHDREnvironment(SAMPLE_TEXTURECUBE_LOD(unity_SpecCube0, samplerunity_SpecCube0, reflectVec, LOD), unity_SpecCube0_HDR);
}
";
}

4
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Texture/SampleTexture2DNode.cs


const string kOutputSlotGName = "G";
const string kOutputSlotBName = "B";
const string kOutputSlotAName = "A";
const string kTextureInputName = "Tex";
const string kTextureInputName = "Texture";
const string kUVInputName = "UV";
const string kSamplerInputName = "Sampler";

AddSlot(new Vector1MaterialSlot(OutputSlotBId, kOutputSlotBName, kOutputSlotBName, SlotType.Output, 0));
AddSlot(new Vector1MaterialSlot(OutputSlotAId, kOutputSlotAName, kOutputSlotAName, SlotType.Output, 0));
AddSlot(new Texture2DInputMaterialSlot(TextureInputId, kTextureInputName, kTextureInputName));
AddSlot(new UVMaterialSlot(UVInput, kUVInputName, kUVInputName, UVChannel.uv0));
AddSlot(new UVMaterialSlot(UVInput, kUVInputName, kUVInputName, UVChannel.UV0));
AddSlot(new SamplerStateMaterialSlot(SamplerInput, kSamplerInputName, kSamplerInputName, SlotType.Input));
RemoveSlotsNameNotMatching(new[] { OutputSlotRGBAId, OutputSlotRId, OutputSlotGId, OutputSlotBId, OutputSlotAId, TextureInputId, UVInput, SamplerInput });
}

6
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Advanced/LogNode.cs


}
static string Unity_Log(
[Slot(0, Binding.None)] DynamicDimensionVector In,
[Slot(0, Binding.None, 1, 1, 1, 1)] DynamicDimensionVector In,
[Slot(1, Binding.None)] out DynamicDimensionVector Out)
{
return

}
static string Unity_Log2(
[Slot(0, Binding.None)] DynamicDimensionVector In,
[Slot(0, Binding.None, 1, 1, 1, 1)] DynamicDimensionVector In,
[Slot(1, Binding.None)] out DynamicDimensionVector Out)
{
return

}
static string Unity_Log10(
[Slot(0, Binding.None)] DynamicDimensionVector In,
[Slot(0, Binding.None, 1, 1, 1, 1)] DynamicDimensionVector In,
[Slot(1, Binding.None)] out DynamicDimensionVector Out)
{
return

4
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Advanced/ModuloNode.cs


}
static string Unity_Modulo(
[Slot(0, Binding.None)] DynamicDimensionVector A,
[Slot(1, Binding.None)] DynamicDimensionVector B,
[Slot(0, Binding.None, 0, 0, 0, 0)] DynamicDimensionVector A,
[Slot(1, Binding.None, 1, 1, 1, 1)] DynamicDimensionVector B,
[Slot(2, Binding.None)] out DynamicDimensionVector Out)
{
return

4
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Advanced/PosterizeNode.cs


}
static string Unity_Posterize(
[Slot(0, Binding.None)] DynamicDimensionVector In,
[Slot(1, Binding.None)] DynamicDimensionVector Steps,
[Slot(0, Binding.None, 0, 0, 0, 0)] DynamicDimensionVector In,
[Slot(1, Binding.None, 4, 4, 4, 4)] DynamicDimensionVector Steps,
[Slot(2, Binding.None)] out DynamicDimensionVector Out)
{
return

4
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Advanced/ReciprocalNode.cs


}
static string Unity_Reciprocal(
[Slot(0, Binding.None)] DynamicDimensionVector In,
[Slot(0, Binding.None, 1, 1, 1, 1)] DynamicDimensionVector In,
[Slot(1, Binding.None)] out DynamicDimensionVector Out)
{
return

}
static string Unity_Reciprocal_Fast(
[Slot(0, Binding.None)] DynamicDimensionVector In,
[Slot(0, Binding.None, 1, 1, 1, 1)] DynamicDimensionVector In,
[Slot(1, Binding.None)] out DynamicDimensionVector Out)
{
return

2
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Advanced/ReciprocalSquareRootNode.cs


}
static string Unity_Rsqrt(
[Slot(0, Binding.None)] DynamicDimensionVector In,
[Slot(0, Binding.None, 1, 1, 1, 1)] DynamicDimensionVector In,
[Slot(1, Binding.None)] out DynamicDimensionVector Out)
{
return

4
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Basic/DivideNode.cs


}
static string Unity_Divide(
[Slot(0, Binding.None)] DynamicDimensionVector A,
[Slot(1, Binding.None)] DynamicDimensionVector B,
[Slot(0, Binding.None, 0, 0, 0, 0)] DynamicDimensionVector A,
[Slot(1, Binding.None, 2, 2, 2, 2)] DynamicDimensionVector B,
[Slot(2, Binding.None)] out DynamicDimensionVector Out)
{
return @"

4
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Basic/MultiplyNode.cs


}
static string Unity_Multiply(
[Slot(0, Binding.None)] DynamicDimensionVector A,
[Slot(1, Binding.None)] DynamicDimensionVector B,
[Slot(0, Binding.None, 0, 0, 0, 0)] DynamicDimensionVector A,
[Slot(1, Binding.None, 2, 2, 2, 2)] DynamicDimensionVector B,
[Slot(2, Binding.None)] out DynamicDimensionVector Out)
{
return

4
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Basic/PowerNode.cs


}
static string Unity_Power(
[Slot(0, Binding.None)] DynamicDimensionVector A,
[Slot(1, Binding.None)] DynamicDimensionVector B,
[Slot(0, Binding.None, 0, 0, 0, 0)] DynamicDimensionVector A,
[Slot(1, Binding.None, 2, 2, 2, 2)] DynamicDimensionVector B,
[Slot(2, Binding.None)] out DynamicDimensionVector Out)
{
return

4
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Basic/SubtractNode.cs


}
static string Unity_Subtract(
[Slot(0, Binding.None)] DynamicDimensionVector A,
[Slot(1, Binding.None)] DynamicDimensionVector B,
[Slot(0, Binding.None, 1, 1, 1, 1)] DynamicDimensionVector A,
[Slot(1, Binding.None, 1, 1, 1, 1)] DynamicDimensionVector B,
[Slot(2, Binding.None)] out DynamicDimensionVector Out)
{
return

6
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Interpolation/InverseLerpNode.cs


}
static string Unity_InverseLerp(
[Slot(0, Binding.None)] DynamicDimensionVector A,
[Slot(1, Binding.None)] DynamicDimensionVector B,
[Slot(2, Binding.None)] DynamicDimensionVector T,
[Slot(0, Binding.None, 0, 0, 0, 0)] DynamicDimensionVector A,
[Slot(1, Binding.None, 1, 1, 1, 1)] DynamicDimensionVector B,
[Slot(2, Binding.None, 0, 0, 0, 0)] DynamicDimensionVector T,
[Slot(3, Binding.None)] out DynamicDimensionVector Out)
{
return

6
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Interpolation/LerpNode.cs


}
static string Unity_Lerp(
[Slot(0, Binding.None)] DynamicDimensionVector A,
[Slot(1, Binding.None)] DynamicDimensionVector B,
[Slot(2, Binding.None)] DynamicDimensionVector T,
[Slot(0, Binding.None, 0, 0, 0, 0)] DynamicDimensionVector A,
[Slot(1, Binding.None, 1, 1, 1, 1)] DynamicDimensionVector B,
[Slot(2, Binding.None, 0, 0, 0, 0)] DynamicDimensionVector T,
[Slot(3, Binding.None)] out DynamicDimensionVector Out)
{
return

6
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Interpolation/SmoothstepNode.cs


}
static string Unity_Smoothstep(
[Slot(0, Binding.None)] DynamicDimensionVector A,
[Slot(1, Binding.None)] DynamicDimensionVector B,
[Slot(2, Binding.None)] DynamicDimensionVector T,
[Slot(0, Binding.None, 0, 0, 0, 0)] DynamicDimensionVector A,
[Slot(1, Binding.None, 1, 1, 1, 1)] DynamicDimensionVector B,
[Slot(2, Binding.None, 0, 0, 0, 0)] DynamicDimensionVector T,
[Slot(3, Binding.None)] out DynamicDimensionVector Out)
{
return

2
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Range/MinimumNode.cs


}
static string Unity_Minimum(
[Slot(0, Binding.None, 1, 1, 1, 1)] DynamicDimensionVector A,
[Slot(0, Binding.None, 0, 0, 0, 0)] DynamicDimensionVector A,
[Slot(1, Binding.None, 1, 1, 1, 1)] DynamicDimensionVector B,
[Slot(2, Binding.None)] out DynamicDimensionVector Out)
{

2
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Range/OneMinusNode.cs


}
static string Unity_OneMinus(
[Slot(0, Binding.None)] DynamicDimensionVector In,
[Slot(0, Binding.None, 1, 1, 1, 1)] DynamicDimensionVector In,
[Slot(1, Binding.None)] out DynamicDimensionVector Out)
{
return

4
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Range/RemapNode.cs


}
static string Unity_Remap(
[Slot(0, Binding.None)] DynamicDimensionVector In,
[Slot(1, Binding.None, 0, 1, 0, 0)] Vector2 InMinMax,
[Slot(0, Binding.None, -1, -1, -1, -1)] DynamicDimensionVector In,
[Slot(1, Binding.None, -1, 1, 0, 0)] Vector2 InMinMax,
[Slot(2, Binding.None, 0, 1, 0, 0)] Vector2 OutMinMax,
[Slot(3, Binding.None)] out DynamicDimensionVector Out)
{

4
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Round/StepNode.cs


}
static string Unity_Step(
[Slot(0, Binding.None)] DynamicDimensionVector A,
[Slot(1, Binding.None)] DynamicDimensionVector B,
[Slot(0, Binding.None, 1, 1, 1, 1)] DynamicDimensionVector A,
[Slot(1, Binding.None, 0, 0, 0, 0)] DynamicDimensionVector B,
[Slot(2, Binding.None)] out DynamicDimensionVector Out)
{
return

2
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Trigonometry/ArccosineNode.cs


}
static string Unity_Arccosine(
[Slot(0, Binding.None)] DynamicDimensionVector In,
[Slot(0, Binding.None, 1, 1, 1, 1)] DynamicDimensionVector In,
[Slot(1, Binding.None)] out DynamicDimensionVector Out)
{
return

4
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Vector/CrossProductNode.cs


}
static string Unity_CrossProduct(
[Slot(0, Binding.None)] Vector3 A,
[Slot(1, Binding.None)] Vector3 B,
[Slot(0, Binding.None, 0, 0, 0, 0)] Vector3 A,
[Slot(1, Binding.None, 0, 1, 0, 0)] Vector3 B,
[Slot(2, Binding.None)] out Vector3 Out)
{
Out = Vector3.zero;

4
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Vector/DotProductNode.cs


}
static string Unity_DotProduct(
[Slot(0, Binding.None)] Vector3 A,
[Slot(1, Binding.None)] Vector3 B,
[Slot(0, Binding.None, 0, 0, 0, 0)] Vector3 A,
[Slot(1, Binding.None, 0, 1, 0, 0)] Vector3 B,
[Slot(2, Binding.None)] out Vector1 Out)
{
return

9
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Vector/FresnelEffectNode.cs


name = "Fresnel Effect";
}
public override PreviewMode previewMode
{
get { return PreviewMode.Preview3D; }
}
protected override MethodInfo GetFunctionToConvert()
{
return GetType().GetMethod("Unity_FresnelEffect", BindingFlags.Static | BindingFlags.NonPublic);

[Slot(0, Binding.None)] Vector3 Normal,
[Slot(1, Binding.None)] Vector3 ViewDir,
[Slot(0, Binding.WorldSpaceNormal)] Vector3 Normal,
[Slot(1, Binding.WorldSpaceViewDirection)] Vector3 ViewDir,
[Slot(2, Binding.None, 1, 1, 1, 1)] Vector1 Power,
[Slot(3, Binding.None)] out Vector1 Out)
{

4
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Vector/ProjectionNode.cs


}
static string Unity_Projection(
[Slot(0, Binding.None)] DynamicDimensionVector A,
[Slot(1, Binding.None)] DynamicDimensionVector B,
[Slot(0, Binding.None, 0, 0, 0, 0)] DynamicDimensionVector A,
[Slot(1, Binding.None, 0, 1, 0, 0)] DynamicDimensionVector B,
[Slot(2, Binding.None)] out DynamicDimensionVector Out)
{
return

4
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Vector/ReflectionNode.cs


}
static string Unity_Reflection(
[Slot(0, Binding.None)] DynamicDimensionVector In,
[Slot(1, Binding.None)] DynamicDimensionVector Normal,
[Slot(0, Binding.None, 0, 0, 0, 0)] DynamicDimensionVector In,
[Slot(1, Binding.None, 0, 1, 0, 0)] DynamicDimensionVector Normal,
[Slot(2, Binding.None)] out DynamicDimensionVector Out)
{

4
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Vector/RejectionNode.cs


}
static string Unity_Rejection(
[Slot(0, Binding.None)] DynamicDimensionVector A,
[Slot(1, Binding.None)] DynamicDimensionVector B,
[Slot(0, Binding.None, 0, 0, 0, 0)] DynamicDimensionVector A,
[Slot(1, Binding.None, 0, 1, 0, 0)] DynamicDimensionVector B,
[Slot(2, Binding.None)] out DynamicDimensionVector Out)
{
return

162
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/UV/FlipbookNode.cs


using System.Reflection;
using UnityEngine;
using System;
using System.Collections.Generic;
using UnityEditor.ShaderGraph.Drawing.Controls;
using UnityEngine;
public class FlipbookNode : CodeFunctionNode
public class FlipbookNode : AbstractMaterialNode, IGeneratesBodyCode, IGeneratesFunction, IMayRequireMeshUV
UpdateNodeAfterDeserialization();
protected override MethodInfo GetFunctionToConvert()
const int UVSlotId = 0;
const int WidthSlotId = 1;
const int HeightSlotId = 2;
const int TileSlotId = 3;
const int OutputSlotId = 4;
const string kUVSlotName = "UV";
const string kWidthSlotName = "Width";
const string kHeightSlotName = "Height";
const string kTileSlotName = "Tile";
const string kOutputSlotName = "Out";
public override bool hasPreview
return GetType().GetMethod("Unity_Flipbook", BindingFlags.Static | BindingFlags.NonPublic);
get { return true; }
static string Unity_Flipbook(
[Slot(0, Binding.MeshUV0)] Vector2 UV,
[Slot(1, Binding.None, 1, 1, 1, 1)] Vector1 Width,
[Slot(2, Binding.None, 1, 1, 1, 1)] Vector1 Height,
[Slot(3, Binding.None)] Vector1 Tile,
[Slot(4, Binding.None)] out Vector2 Out)
string GetFunctionName()
{
return "Unity_Flipbook_" + precision;
}
public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new UVMaterialSlot(UVSlotId, kUVSlotName, kUVSlotName, UVChannel.UV0));
AddSlot(new Vector1MaterialSlot(WidthSlotId, kWidthSlotName, kWidthSlotName, SlotType.Input, 1));
AddSlot(new Vector1MaterialSlot(HeightSlotId, kHeightSlotName, kHeightSlotName, SlotType.Input, 1));
AddSlot(new Vector1MaterialSlot(TileSlotId, kTileSlotName, kTileSlotName, SlotType.Input, 0));
AddSlot(new Vector2MaterialSlot(OutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, Vector2.zero));
RemoveSlotsNameNotMatching(new[] { UVSlotId, WidthSlotId, HeightSlotId, TileSlotId, OutputSlotId });
}
[SerializeField]
private bool m_InvertX = false;
[ToggleControl("Invert X")]
public Toggle invertX
Out = Vector2.zero;
get { return new Toggle(m_InvertX); }
set
{
if (m_InvertX == value.isOn)
return;
m_InvertX = value.isOn;
Dirty(ModificationScope.Node);
}
}
return
@"
{
{precision}2 tileCount = {precision}2(1.0, 1.0) / {precision}2(Width, Height);
{precision} tileY = floor(Tile * tileCount.x);
{precision} tileX = Tile - Width * tileY;
Out = (UV + {precision}2(tileX, tileY)) * tileCount;
}
";
[SerializeField]
private bool m_InvertY = true;
[ToggleControl("Invert Y")]
public Toggle invertY
{
get { return new Toggle(m_InvertY); }
set
{
if (m_InvertY == value.isOn)
return;
m_InvertY = value.isOn;
Dirty(ModificationScope.Node);
}
}
public void GenerateNodeCode(ShaderGenerator visitor, GenerationMode generationMode)
{
var sb = new ShaderStringBuilder();
var uvValue = GetSlotValue(UVSlotId, generationMode);
var widthValue = GetSlotValue(WidthSlotId, generationMode);
var heightValue = GetSlotValue(HeightSlotId, generationMode);
var tileValue = GetSlotValue(TileSlotId, generationMode);
var outputValue = GetSlotValue(OutputSlotId, generationMode);
sb.AppendLine("{0} {1};", NodeUtils.ConvertConcreteSlotValueTypeToString(precision, FindOutputSlot<MaterialSlot>(OutputSlotId).concreteValueType), GetVariableNameForSlot(OutputSlotId));
if (!generationMode.IsPreview())
{
sb.AppendLine("{0}2 _{1}_Invert = {0}2 ({2}, {3});", precision, GetVariableNameForNode(), invertX.isOn ? 1 : 0, invertY.isOn ? 1 : 0);
}
sb.AppendLine("{0}({1}, {2}, {3}, {4}, _{5}_Invert, {6});", GetFunctionName(), uvValue, widthValue, heightValue, tileValue, GetVariableNameForNode(), outputValue);
visitor.AddShaderChunk(sb.ToString(), false);
}
public override void CollectPreviewMaterialProperties(List<PreviewProperty> properties)
{
base.CollectPreviewMaterialProperties(properties);
properties.Add(new PreviewProperty(PropertyType.Vector2)
{
name = string.Format("_{0}_Invert", GetVariableNameForNode()),
vector4Value = new Vector2(invertX.isOn ? 1 : 0, invertY.isOn ? 1 : 0)
});
}
public override void CollectShaderProperties(PropertyCollector properties, GenerationMode generationMode)
{
if (!generationMode.IsPreview())
return;
base.CollectShaderProperties(properties, generationMode);
properties.AddShaderProperty(new Vector2ShaderProperty()
{
overrideReferenceName = string.Format("_{0}_Invert", GetVariableNameForNode()),
generatePropertyBlock = false
});
}
public void GenerateNodeFunction(FunctionRegistry registry, GenerationMode generationMode)
{
registry.ProvideFunction(GetFunctionName(), s =>
{
s.AppendLine("void {0} ({1} UV, {2} Width, {3} Height, {4} Tile, {5}2 Invert, out {6} Out)",
GetFunctionName(),
FindInputSlot<MaterialSlot>(UVSlotId).concreteValueType.ToString(precision),
FindInputSlot<MaterialSlot>(WidthSlotId).concreteValueType.ToString(precision),
FindInputSlot<MaterialSlot>(HeightSlotId).concreteValueType.ToString(precision),
FindInputSlot<MaterialSlot>(TileSlotId).concreteValueType.ToString(precision),
precision,
FindOutputSlot<MaterialSlot>(OutputSlotId).concreteValueType.ToString(precision));
using (s.BlockScope())
{
s.AppendLine("Tile = fmod(Tile, Width*Height);");
s.AppendLine("{0}2 tileCount = {0}2(1.0, 1.0) / {0}2(Width, Height);", precision);
s.AppendLine("{0} tileY = abs(Invert.y * Height - (floor(Tile * tileCount.x) + Invert.y * 1));", precision);
s.AppendLine("{0} tileX = abs(Invert.x * Width - ((Tile - Width * floor(Tile * tileCount.x)) + Invert.x * 1));", precision);
s.AppendLine("Out = (UV + {0}2(tileX, tileY)) * tileCount;", precision);
}
});
}
public bool RequiresMeshUV(UVChannel channel)
{
s_TempSlots.Clear();
GetInputSlots(s_TempSlots);
foreach (var slot in s_TempSlots)
{
if (slot.RequiresMeshUV(channel))
return true;
}
return false;
}
}
}

2
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/UV/TwirlNode.cs


static string Unity_Twirl(
[Slot(0, Binding.MeshUV0)] Vector2 UV,
[Slot(1, Binding.None, 0.5f, 0.5f, 0.5f, 0.5f)] Vector2 Center,
[Slot(2, Binding.None, 0f, 0f, 0f, 0f)] Vector1 Strength,
[Slot(2, Binding.None, 10f, 0f, 0f, 0f)] Vector1 Strength,
[Slot(3, Binding.None)] Vector2 Offset,
[Slot(4, Binding.None)] out Vector2 Out)
{

23
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Util/GraphUtil.cs


using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using UnityEditor.Graphing;

{
static class GraphUtil
{
internal static string ConvertCamelCase(string text, bool preserveAcronyms)
{
if (string.IsNullOrEmpty(text))
return string.Empty;
StringBuilder newText = new StringBuilder(text.Length * 2);
newText.Append(text[0]);
for (int i = 1; i < text.Length; i++)
{
if (char.IsUpper(text[i]))
if ((text[i - 1] != ' ' && !char.IsUpper(text[i - 1])) ||
(preserveAcronyms && char.IsUpper(text[i - 1]) &&
i < text.Length - 1 && !char.IsUpper(text[i + 1])))
newText.Append(' ');
newText.Append(text[i]);
}
return newText.ToString();
}
internal static void GenerateApplicationVertexInputs(ShaderGraphRequirements graphRequiements, ShaderGenerator vertexInputs)
{
vertexInputs.AddShaderChunk("struct GraphVertexInput", false);

finalBuilder.AppendLine(@"#include ""CoreRP/ShaderLibrary/Common.hlsl""");
finalBuilder.AppendLine(@"#include ""CoreRP/ShaderLibrary/Packing.hlsl""");
finalBuilder.AppendLine(@"#include ""CoreRP/ShaderLibrary/Color.hlsl""");
finalBuilder.AppendLine(@"#include ""ShaderGraphLibrary/Functions.hlsl""");
finalBuilder.AppendLine(@"#include ""CoreRP/ShaderLibrary/EntityLighting.hlsl""");
finalBuilder.AppendLine(@"#include ""ShaderGraphLibrary/Functions.hlsl""");
finalBuilder.AppendLines(shaderProperties.GetPropertiesDeclaration(0));
finalBuilder.AppendLines(surfaceInputs.GetShaderString(0));

2
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Util/ShaderGenerator.cs


if (combinedRequierments.requiresScreenPosition)
{
interpolators.AddShaderChunk(string.Format("float4 {0} : TEXCOORD{1};", ShaderGeneratorNames.ScreenPosition, interpolatorIndex), false);
vertexShader.AddShaderChunk(string.Format("o.{0} = ComputeScreenPos(UnityObjectToClipPos(v.vertex));", ShaderGeneratorNames.ScreenPosition), false);
vertexShader.AddShaderChunk(string.Format("o.{0} = ComputeScreenPos(mul(GetWorldToHClipMatrix(), mul(GetObjectToWorldMatrix(), v.vertex)), _ProjectionParams.x);", ShaderGeneratorNames.ScreenPosition), false);
pixelShader.AddShaderChunk(string.Format("float4 {0} = IN.{0};", ShaderGeneratorNames.ScreenPosition), false);
interpolatorIndex++;
}

8
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Util/UvChannel.cs


namespace UnityEditor.ShaderGraph {
public enum UVChannel
{
uv0 = 0,
uv1 = 1,
uv2 = 2,
uv3 = 3,
UV0 = 0,
UV1 = 1,
UV2 = 2,
UV3 = 3,
}
}

90
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Controls/ChannelMixerControl.cs


Slider m_GreenSlider;
Slider m_BlueSlider;
FloatField m_RedInputField;
FloatField m_GreenInputField;
FloatField m_BlueInputField;
float m_Minimum;
float m_Maximum;
bool m_Initialized;

if (!string.IsNullOrEmpty(label))
Add(new Label(label));
var buttonPanel = new VisualElement { name = "buttonPanel" };
Add(outputButtonRed);
outputButtonRed.Add(new Label("R"));
buttonPanel.Add(outputButtonRed);
Add(outputButtonGreen);
outputButtonGreen.Add(new Label("G"));
buttonPanel.Add(outputButtonGreen);
Add(outputButtonBlue);
outputButtonBlue.Add(new Label("B"));
buttonPanel.Add(outputButtonBlue);
Add(new Label("Red"));
Add(buttonPanel);
var redSliderPanel = new VisualElement { name = "sliderPanel" };
redSliderPanel.Add(new Label("R"));
Add(m_RedSlider);
redSliderPanel.Add(m_RedSlider);
m_RedInputField = new FloatField { value = m_ChannelMixer.outRed.x };
m_RedInputField.RegisterCallback<ChangeEvent<double>, int>(OnChangeInputField, 0);
redSliderPanel.Add(m_RedInputField);
Add(redSliderPanel);
Add(new Label("Green"));
var greenSliderPanel = new VisualElement { name = "sliderPanel" };
greenSliderPanel.Add(new Label("G"));
Add(m_GreenSlider);
greenSliderPanel.Add(m_GreenSlider);
m_GreenInputField = new FloatField { value = m_ChannelMixer.outRed.y };
m_GreenInputField.RegisterCallback<ChangeEvent<double>, int>(OnChangeInputField, 1);
greenSliderPanel.Add(m_GreenInputField);
Add(greenSliderPanel);
Add(new Label("Blue"));
var blueSliderPanel = new VisualElement { name = "sliderPanel" };
blueSliderPanel.Add(new Label("B"));
Add(m_BlueSlider);
blueSliderPanel.Add(m_BlueSlider);
m_BlueInputField = new FloatField { value = m_ChannelMixer.outRed.z };
m_BlueInputField.RegisterCallback<ChangeEvent<double>, int>(OnChangeInputField, 2);
blueSliderPanel.Add(m_BlueInputField);
Add(blueSliderPanel);
m_Initialized = true;
ResetSliders();

m_ChannelMixer.outRed[inChannel] = value;
break;
}
switch(inChannel)
{
case 1:
m_GreenInputField.value = value;
break;
case 2:
m_BlueInputField.value = value;
break;
default:
m_RedInputField.value = value;
break;
}
}
void OnChangeInputField(ChangeEvent<double> evt, int inChannel)
{
if (!m_Initialized)
return;
var value = Mathf.Max(Mathf.Min((float)evt.newValue, m_Maximum), m_Minimum);
m_Node.owner.owner.RegisterCompleteObjectUndo("Input Field Change");
switch (m_OutChannel)
{
case 1:
m_ChannelMixer.outGreen[inChannel] = value;
break;
case 2:
m_ChannelMixer.outBlue[inChannel] = value;
break;
default:
m_ChannelMixer.outRed[inChannel] = value;
break;
}
switch(inChannel)
{
case 1:
m_GreenSlider.value = value;
break;
case 2:
m_BlueSlider.value = value;
break;
default:
m_RedSlider.value = value;
break;
}
m_PropertyInfo.SetValue(m_Node, m_ChannelMixer, null);
Dirty(ChangeType.Repaint);
}
void OnClickButton(int outChannel)

3
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Controls/ColorControl.cs


if (!string.IsNullOrEmpty(label))
Add(new Label(label));
var colorField = new ColorField { value = (Color)m_PropertyInfo.GetValue(m_Node, null) };
var colorField = new ColorField { value = (Color)m_PropertyInfo.GetValue(m_Node, null),
showEyeDropper = false };
colorField.OnValueChanged(OnChange);
Add(colorField);
}

51
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Controls/ToggleControl.cs


using System;
using System.Reflection;
using UnityEditor.Graphing;
using UnityEditor.Experimental.UIElements;
using UnityEditor.Graphing;
using UnityEngine.Experimental.UIElements.StyleSheets;
using UnityEditor.ShaderGraph;
namespace UnityEditor.ShaderGraph.Drawing.Controls
{

public class ToggleControlView : VisualElement, INodeModificationListener
{
GUIContent m_Label;
IMGUIContainer m_Container;
UnityEngine.Experimental.UIElements.Toggle m_Toggle;
public ToggleControlView(string label, AbstractMaterialNode node, PropertyInfo propertyInfo)
{

throw new ArgumentException("Property must be a Toggle.", "propertyInfo");
m_Label = new GUIContent(label ?? ObjectNames.NicifyVariableName(propertyInfo.Name));
m_Container = new IMGUIContainer(OnGUIHandler);
Add(m_Container);
label = label ?? ObjectNames.NicifyVariableName(propertyInfo.Name);
var value = (Toggle)m_PropertyInfo.GetValue(m_Node, null);
var panel = new VisualElement { name = "togglePanel" };
if (!string.IsNullOrEmpty(label))
panel.Add(new Label(label));
Action changedToggle = () => { OnChangeToggle(); };
m_Toggle = new UnityEngine.Experimental.UIElements.Toggle(changedToggle);
m_Toggle.SetEnabled(value.isEnabled);
m_Toggle.on = value.isOn;
panel.Add(m_Toggle);
Add(panel);
var value = (Toggle)m_PropertyInfo.GetValue(m_Node, null);
m_Toggle.SetEnabled(value.isEnabled);
m_Container.Dirty(ChangeType.Repaint);
{
Dirty(ChangeType.Repaint);
}
void OnGUIHandler()
void OnChangeToggle()
m_Node.owner.owner.RegisterCompleteObjectUndo("Toggle Change");
using (var changeCheckScope = new EditorGUI.ChangeCheckScope())
{
m_Container.SetEnabled(value.isEnabled);
bool isOn = EditorGUILayout.Toggle(m_Label, value.isOn);
value = new Toggle(isOn, value.isEnabled);
if (changeCheckScope.changed)
{
m_Node.owner.owner.RegisterCompleteObjectUndo("Change " + m_Node.name);
m_PropertyInfo.SetValue(m_Node, value, null);
}
}
value.isOn = !value.isOn;
m_PropertyInfo.SetValue(m_Node, value, null);
Dirty(ChangeType.Repaint);
}
}
}

3
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/Slots/ColorRGBSlotControlView.cs


public ColorRGBSlotControlView(ColorRGBMaterialSlot slot)
{
m_Slot = slot;
var colorField = new ColorField { value = new Color(slot.value.x, slot.value.y, slot.value.z, 0), showAlpha = false };
var colorField = new ColorField { value = new Color(slot.value.x, slot.value.y, slot.value.z, 0),
showEyeDropper = false, showAlpha = false };
colorField.OnValueChanged(OnValueChanged);
Add(colorField);
}

2
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/Slots/ColorSlotControlView.cs


public ColorRGBASlotControlView(ColorRGBAMaterialSlot slot)
{
m_Slot = slot;
var colorField = new ColorField { value = slot.value };
var colorField = new ColorField { value = slot.value, showEyeDropper = false };
colorField.OnValueChanged(OnValueChanged);
Add(colorField);
}

108
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Resources/Styles/MaterialGraph.uss


width: 100;
}
CubemapSlotControlView {
flex-direction: row;
align-items: center;
}
CubemapSlotControlView > ObjectField {
margin-top: 0;
margin-bottom: 0;
margin-left: 0;
margin-right: 0;
width: 100;
}
MultiFloatSlotControlView {
flex-direction: row;
align-items: center;

}
ColorRGBASlotControlView > ColorField {
width: 50;
width: 41;
margin-left: 0;
margin-right: 0;
}
ColorRGBSlotControlView {

ColorRGBSlotControlView > ColorField {
width: 50;
width: 41;
margin-left: 0;
margin-right: 0;
}
.edge.fromMatrix4, .edge.fromMatrix3, .edge.fromMatrix2 {

margin-right: 0;
min-width: 30;
flex-grow: 1;
}
ChannelMixerControlView {
padding-left: 8;
padding-right: 8;
padding-top: 4;
padding-bottom: 4;
}
ChannelMixerControlView > Label {
margin-left: 0;
margin-right: 0;
cursor: slide-arrow;
}
ChannelMixerControlView > #buttonPanel {
flex-direction: row;
flex-grow: 1;
margin-bottom: 6;
}
ChannelMixerControlView > #buttonPanel > Button {
flex-grow: 1;
margin-left: 0;
margin-right: 0;
align-items: center;
}
ChannelMixerControlView > #buttonPanel > Button > Label {
flex-grow: 1;
margin-left: 0;
margin-right: 0;
margin-top: 0;
margin-bottom: 0;
padding-left: 0;
padding-right: 0;
padding-top: 0;
padding-bottom: 0;
}
ChannelMixerControlView > #sliderPanel {
flex-direction: row;
flex-grow: 1;
}
ChannelMixerControlView > #sliderPanel > Label {
margin-left: 0;
margin-right: 0;
min-width: 20;
}
ChannelMixerControlView > #sliderPanel > Slider {
flex-grow: 1;
margin-left: 0;
margin-right: 0;
}
ChannelMixerControlView > #sliderPanel > FloatField {
margin-left: 4;
margin-right: 2;
min-width: 30;
max-width: 30;
}
ToggleControlView > #togglePanel {
flex-direction: row;
flex-grow: 1;
}
ToggleControlView > #togglePanel > Label {
flex-grow: 1;
padding-left: 0;
padding-right: 0;
padding-top: 0;
padding-bottom: 0;
margin-left: 8;
margin-right: 8;
margin-top: 4;
margin-bottom: 4;
}
ToggleControlView > #togglePanel > Toggle {
margin-left: 8;
margin-right: 8;
margin-top: 4;
margin-bottom: 4;
align-self: center;
}
ObjectControlView {

8
MaterialGraphProject/Assets/UnityShaderEditor/ShaderGraphLibrary/Functions.hlsl


#endif
}
float4 ComputeScreenPos (float4 pos, float projectionSign)
{
float4 o = pos * 0.5f;
o.xy = float2(o.x, o.y * projectionSign) + o.w;
o.zw = pos.zw;
return o;
}
#endif // UNITY_SHADER_GRAPH_INCLUDED

8
MaterialGraphProject/Assets/UnityShaderEditor/ShaderGraphLibrary/ShaderVariables.hlsl


// This contain occlusion factor from 0 to 1 for dynamic objects (no SH here)
float4 unity_ProbesOcclusion;
// HDR environment map decode instructions
half4 unity_SpecCube0_HDR;
CBUFFER_END
#if defined(USING_STEREO_MATRICES)

SAMPLER(samplerunity_DynamicLightmap);
TEXTURE2D(unity_DynamicDirectionality);
// Default reflection probe
TEXTURECUBE(unity_SpecCube0);
SAMPLER(samplerunity_SpecCube0);
// We can have shadowMask only if we have lightmap, so no sampler
TEXTURE2D(unity_ShadowMask);

正在加载...
取消
保存