浏览代码

Started work on Rounded Rectangle node

/main
Matt Dean 7 年前
当前提交
4512dff0
共有 2 个文件被更改,包括 55 次插入0 次删除
  1. 43
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Procedural/Shape/RoundedRectangleNode.cs
  2. 12
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Procedural/Shape/RoundedRectangleNode.cs.meta

43
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Procedural/Shape/RoundedRectangleNode.cs


using System.Reflection;
using UnityEngine;
namespace UnityEditor.ShaderGraph
{
[Title("Procedural", "Shape", "Rounded Rectangle")]
public class RoundedRectangleNode : CodeFunctionNode
{
public RoundedRectangleNode()
{
name = "Rounded Rectangle";
}
protected override MethodInfo GetFunctionToConvert()
{
return GetType().GetMethod("Unity_RoundedRectangle", BindingFlags.Static | BindingFlags.NonPublic);
}
static string Unity_RoundedRectangle(
[Slot(0, Binding.MeshUV0)] Vector2 UV,
[Slot(1, Binding.None, 0.5f, 0, 0, 0)] Vector1 Width,
[Slot(2, Binding.None, 0.5f, 0, 0, 0)] Vector1 Height,
[Slot(3, Binding.None, 0.1f, 0, 0, 0)] Vector1 Radius,
[Slot(4, Binding.None)] out Vector1 Out)
{
return
@"
{
{precision}2 XMinAndMax = {precision}2(0.5 - Width / 2, 0.5 + Width / 2);
{precision}2 YMinAndMax = {precision}2(0.5 - Height / 2, 0.5 + Height / 2);
{precision} x = step( XMinAndMax.x, UV.x ) - step( XMinAndMax.y, UV.x );
{precision} y = step( YMinAndMax.x, UV.y ) - step( YMinAndMax.y, UV.y );
{precision} B = x * y;
{precision} sw = step(length(UV - {precision}2(XMinAndMax.x + Radius, YMinAndMax.x + Radius)), Radius);
{precision} se = step(length(UV - {precision}2(XMinAndMax.y - Radius, YMinAndMax.x + Radius)), Radius);
{precision} nw = step(length(UV - {precision}2(XMinAndMax.x + Radius, YMinAndMax.y - Radius)), Radius);
{precision} ne = step(length(UV - {precision}2(XMinAndMax.y - Radius, YMinAndMax.y - Radius)), Radius);
{precision} A = saturate(sw + se + nw + ne);
Out = A;
}";
}
}
}

12
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Procedural/Shape/RoundedRectangleNode.cs.meta


fileFormatVersion: 2
guid: faba19d28a5fc1d4187c0124658f1822
timeCreated: 1495565599
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存