浏览代码

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

Node Bugfixes
/main
GitHub 7 年前
当前提交
35129ab8
共有 6 个文件被更改,包括 36 次插入34 次删除
  1. 2
      MaterialGraphProject/Assets/NewNodes/Editor/Kill/CheckerboardNode.cs
  2. 35
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/ScreenPositionNode.cs
  3. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Advanced/LengthNode.cs
  4. 31
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Procedural/CheckerboardNode.cs
  5. 0
      /MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Procedural/CheckerboardNode.cs.meta
  6. 0
      /MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Procedural/CheckerboardNode.cs

2
MaterialGraphProject/Assets/NewNodes/Editor/Kill/CheckerboardNode.cs


/*
using System.Reflection;
using UnityEngine;

}
}
}
*/

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


public enum ScreenSpaceType
{
Default,
Raw,
Center,
Tiled
};

}
}
string GetCurrentType()
{
return System.Enum.GetName(typeof(ScreenSpaceType), m_ScreenSpaceType);
}
private const int kOutputSlot1Id = 0;
private const string kOutputSlot1Name = "Out";
private const int kOutputSlotId = 0;
private const string kOutputSlotName = "Out";
public override bool hasPreview { get { return true; } }
public override PreviewMode previewMode

public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new Vector2MaterialSlot(kOutputSlot1Id, kOutputSlot1Name, kOutputSlot1Name, SlotType.Output, Vector2.zero));
RemoveSlotsNameNotMatching(new[] { kOutputSlot1Id });
}
public override string GetVariableNameForSlot(int slotId)
{
return ShaderGeneratorNames.ScreenPosition;
AddSlot(new Vector4MaterialSlot(kOutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, Vector4.zero));
RemoveSlotsNameNotMatching(new[] { kOutputSlotId });
}
public void GenerateNodeCode(ShaderGenerator visitor, GenerationMode generationMode)

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

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


static string Unity_Length(
[Slot(0, Binding.None)] DynamicDimensionVector In,
[Slot(1, Binding.None)] out DynamicDimensionVector Out)
[Slot(1, Binding.None)] out Vector1 Out)
{
return
@"

31
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Procedural/CheckerboardNode.cs


namespace UnityEditor.ShaderGraph
{
[Title("Procedural/Checkerboard")]
public class AACheckerboardNode : CodeFunctionNode
public class CheckerboardNode : CodeFunctionNode
public AACheckerboardNode()
public CheckerboardNode()
return GetType().GetMethod("Unity_AACheckerboard", BindingFlags.Static | BindingFlags.NonPublic);
return GetType().GetMethod("Unity_Checkerboard", BindingFlags.Static | BindingFlags.NonPublic);
static string Unity_AACheckerboard(
static string Unity_Checkerboard(
[Slot(1, Binding.None, 0.2f, 0.2f, 0.2f, 0.2f)] Vector4 ColorA,
[Slot(2, Binding.None, 0.7f, 0.7f, 0.7f, 0.7f)] Vector4 ColorB,
[Slot(1, Binding.None, 0.2f, 0.2f, 0.2f, 1f)] Color ColorA,
[Slot(2, Binding.None, 0.7f, 0.7f, 0.7f, 1f)] Color ColorB,
[Slot(3, Binding.None, 1f, 1f, 1f, 1f)] Vector2 Frequency,
[Slot(4, Binding.None)] out Vector4 Out)
{

{
float4 derivatives = float4(ddx(UV), ddy(UV));
float2 duv_length = sqrt(float2(dot(derivatives.xz, derivatives.xz), dot(derivatives.yw, derivatives.yw)));
float width = 0.5f;
float2 distance3 = 2.0f * abs(frac(UV.xy * Frequency) - 0.5f) - width;
float2 scale = 0.5 / duv_length.xy;
float2 blend_out = saturate(scale / 3);
float2 vector_alpha = clamp(distance3 * scale.xy * blend_out.xy, -1.0f, 1.0f);
float alpha = saturate(0.5f + 0.5f * vector_alpha.x * vector_alpha.y);
Out= lerp(ColorA, ColorB, alpha.xxxx);
UV = UV + 0.25 / Frequency;
{precision}4 derivatives = {precision}4(ddx(UV), ddy(UV));
{precision}2 duv_length = sqrt({precision}2(dot(derivatives.xz, derivatives.xz), dot(derivatives.yw, derivatives.yw)));
{precision} width = 0.5;
{precision}2 distance3 = 2.0 * abs(frac((UV.xy + 0.5) * Frequency) - 0.5) - width;
{precision}2 scale = 0.5 / duv_length.xy;
{precision}2 blend_out = saturate(scale / 3);
{precision}2 vector_alpha = clamp(distance3 * scale.xy * blend_out.xy, -1.0, 1.0);
{precision} alpha = saturate(vector_alpha.x * vector_alpha.y);
Out = lerp(ColorA, ColorB, alpha.xxxx);
}";
}
}

/MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Procedural/AACheckerBoardNode.cs.meta → /MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Procedural/CheckerboardNode.cs.meta

/MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Procedural/AACheckerBoardNode.cs → /MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Procedural/CheckerboardNode.cs

正在加载...
取消
保存