浏览代码

Fix Checkerboard node

- Rename class
- Rename method
- Change color slots to Color type
- Adjust UVs to align checker to boundaries
- Use precision value
- Comment out old node (using the Checkerboard name)
/main
Matt Dean 7 年前
当前提交
73639f15
共有 2 个文件被更改,包括 18 次插入15 次删除
  1. 2
      MaterialGraphProject/Assets/NewNodes/Editor/Kill/CheckerboardNode.cs
  2. 31
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Procedural/CheckerboardNode.cs

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


/*
using System.Reflection;
using UnityEngine;

}
}
}
*/

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);
}";
}
}
正在加载...
取消
保存