浏览代码

Merge pull request #127 from Unity-Technologies/procedural-shape

Procedural Shape
/main
GitHub 7 年前
当前提交
6f046031
共有 12 个文件被更改,包括 139 次插入23 次删除
  1. 26
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Procedural/Shape/EllipseNode.cs
  2. 22
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Procedural/Shape/RectangleNode.cs
  3. 8
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Procedural/Shape.meta
  4. 41
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Procedural/Shape/PolygonNode.cs
  5. 11
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Procedural/Shape/PolygonNode.cs.meta
  6. 42
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Procedural/Shape/RoundedRectangleNode.cs
  7. 12
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Procedural/Shape/RoundedRectangleNode.cs.meta
  8. 0
      /MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Procedural/Shape/EllipseNode.cs.meta
  9. 0
      /MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Procedural/Shape/RectangleNode.cs.meta
  10. 0
      /MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Procedural/Shape/EllipseNode.cs
  11. 0
      /MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Procedural/Shape/RectangleNode.cs

26
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Procedural/Shape/EllipseNode.cs


using System.Reflection;
using UnityEngine;
/*namespace UnityEditor.ShaderGraph
namespace UnityEditor.ShaderGraph
[Title("Procedural", "MakeSubgraph", "Repeating Dot")]
public class RepeatingDotNode : CodeFunctionNode
[Title("Procedural", "Shape", "Ellipse")]
public class EllipseNode : CodeFunctionNode
public RepeatingDotNode()
public EllipseNode()
name = "Repeating Dot";
name = "Ellipse";
return GetType().GetMethod("Unity_Repreatingdot", BindingFlags.Static | BindingFlags.NonPublic);
return GetType().GetMethod("Unity_Ellipse", BindingFlags.Static | BindingFlags.NonPublic);
static string Unity_Repreatingdot(
static string Unity_Ellipse(
[Slot(1, Binding.None, 4.0f, 4.0f, 4.0f, 4.0f)] Vector1 Count,
[Slot(2, Binding.None, 0.5f, 0.5f, 0.5f, 0.5f)] Vector1 Radius,
[Slot(2, Binding.None, 0.5f, 0, 0, 0)] Vector1 Width,
[Slot(3, Binding.None, 0.5f, 0, 0, 0)] Vector1 Height,
UV *= 2.0 - 1.0;
UV = fmod(UV * Count, 1.0) * 2.0 - 1.0;
Out = step(length(UV),Radius);
UV = (UV * 2.0 - 1.0);
UV = UV / {precision}2(Width, Height);
Out = step(length(UV), 1);
}*/
}

22
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Procedural/Shape/RectangleNode.cs


using System.Reflection;
using UnityEngine;
/*namespace UnityEditor.ShaderGraph
namespace UnityEditor.ShaderGraph
[Title("Procedural", "MakeSubgraph", "Square")]
public class BoxNode : CodeFunctionNode
[Title("Procedural", "Shape", "Rectangle")]
public class RectangleNode : CodeFunctionNode
public BoxNode()
public RectangleNode()
name = "Square";
name = "Rectangle";
return GetType().GetMethod("Unity_Boxnode", BindingFlags.Static | BindingFlags.NonPublic);
return GetType().GetMethod("Unity_Rectangle", BindingFlags.Static | BindingFlags.NonPublic);
static string Unity_Boxnode(
static string Unity_Rectangle(
[Slot(1, Binding.None, 0.2f, 0.8f, 0, 0)] Vector2 XMinAndMax,
[Slot(2, Binding.None, 0.2f, 0.8f, 0, 0)] Vector2 YMinAndMax,
[Slot(1, Binding.None, 0.5f, 0, 0, 0)] Vector1 Width,
[Slot(2, Binding.None, 0.5f, 0, 0, 0)] Vector1 Height,
{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 );
Out = x * y;

}*/
}

8
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Procedural/Shape.meta


fileFormatVersion: 2
guid: 74f319061d92c11439d4f7e87c991e89
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

41
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Procedural/Shape/PolygonNode.cs


using System.Reflection;
using UnityEngine;
namespace UnityEditor.ShaderGraph
{
[Title("Procedural", "Shape", "Polygon")]
public class PolygonNode : CodeFunctionNode
{
public PolygonNode()
{
name = "Polygon";
}
protected override MethodInfo GetFunctionToConvert()
{
return GetType().GetMethod("Unity_Polygon", BindingFlags.Static | BindingFlags.NonPublic);
}
static string Unity_Polygon(
[Slot(0, Binding.MeshUV0)] Vector2 UV,
[Slot(1, Binding.None, 6, 0, 0, 0)] Vector1 Sides,
[Slot(2, Binding.None, 0.5f, 0, 0, 0)] Vector1 Width,
[Slot(3, Binding.None, 0.5f, 0, 0, 0)] Vector1 Height,
[Slot(4, Binding.None)] out DynamicDimensionVector Out)
{
return
@"
{
{precision} tau = 6.28318530718;
{precision}2 uv = (UV * 2 - 1) / {precision}2(Width, Height);
uv.y *= -1;
{precision} pCoord = atan2(uv.x, uv.y);
{precision} r = tau / Sides;
{precision} distance = cos(floor(0.5 + pCoord / r) * r - pCoord) * length(uv);
{precision} value = 1 - step(1, smoothstep(0, 1, distance));
Out = value;
}
";
}
}
}

11
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Procedural/Shape/PolygonNode.cs.meta


fileFormatVersion: 2
guid: 97e0f55e76f7d88449d41fe897188d67
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

42
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
@"
{
Radius = min(abs(Radius), 0.5 * min(abs(Width), abs(Height)));
{precision}2 XMinAndMax = {precision}2(0.5 - abs(Width) / 2, 0.5 + abs(Width) / 2);
{precision}2 YMinAndMax = {precision}2(0.5 - abs(Height) / 2, 0.5 + abs(Height) / 2);
{precision} wide = (step( XMinAndMax.x, UV.x ) - step( XMinAndMax.y, UV.x )) * (step( YMinAndMax.x + Radius, UV.y ) - step( YMinAndMax.y - Radius, UV.y ));
{precision} tall = (step( XMinAndMax.x + Radius, UV.x ) - step( XMinAndMax.y - Radius, UV.x )) * (step( YMinAndMax.x, UV.y ) - step( YMinAndMax.y, UV.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);
Out = saturate(wide + tall + sw + se + nw + ne);
}";
}
}
}

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:

/MaterialGraphProject/Assets/NewNodes/Editor/Keep/MakeSubgraph/RepeatingDotNode.cs.meta → /MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Procedural/Shape/EllipseNode.cs.meta

/MaterialGraphProject/Assets/NewNodes/Editor/Keep/MakeSubgraph/BoxNode.cs.meta → /MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Procedural/Shape/RectangleNode.cs.meta

/MaterialGraphProject/Assets/NewNodes/Editor/Keep/MakeSubgraph/RepeatingDotNode.cs → /MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Procedural/Shape/EllipseNode.cs

/MaterialGraphProject/Assets/NewNodes/Editor/Keep/MakeSubgraph/BoxNode.cs → /MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Procedural/Shape/RectangleNode.cs

正在加载...
取消
保存