浏览代码

UV Nodes

- Minor fixes to Natalies commits
/main
Matt Dean 7 年前
当前提交
a63160cc
共有 20 个文件被更改,包括 213 次插入164 次删除
  1. 2
      MaterialGraphProject/Assets/NewNodes/Editor/Kill/SphericalIndentationNode.cs
  2. 2
      MaterialGraphProject/Assets/NewNodes/Editor/Kill/SpherizeNode.cs
  3. 4
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/UV/RadialShearNode.cs
  4. 15
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/UV/RotateNode.cs
  5. 40
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/UV/FlipbookNode.cs
  6. 12
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/UV/FlipbookNode.cs.meta
  7. 38
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/UV/PolarCoordinatesNode.cs
  8. 37
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/UV/SpherizeNode.cs
  9. 33
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/UV/TilingAndOffsetNode.cs
  10. 41
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/UV/TwirlNode.cs
  11. 34
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/UV/ScaleOffsetNode.cs
  12. 37
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/UV/SphereWarpNode.cs
  13. 39
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/UV/CartesianToPolarNode.cs
  14. 43
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/UV/TwistNode.cs
  15. 0
      /MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/UV/PolarCoordinatesNode.cs.meta
  16. 0
      /MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/UV/TilingAndOffsetNode.cs.meta
  17. 0
      /MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/UV/SpherizeNode.cs.meta
  18. 0
      /MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/UV/TwirlNode.cs.meta
  19. 0
      /MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/UV/RotateNode.cs.meta
  20. 0
      /MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/UV/RotateNode.cs

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


namespace UnityEditor.ShaderGraph
{
/*
[Title("UV/Spherize 3D")]
public class SphericalIndentationNode : CodeFunctionNode
{

}";
}
}
*/
}

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


namespace UnityEditor.ShaderGraph
{
/*
[Title("OLD/SpherizeOLD")]
public class SpherizeNode : CodeFunctionNode
{

}";
}
}
*/
}

4
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/UV/RadialShearNode.cs


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

{
float2 delta = UV - Center;
float delta2 = dot(delta.xy, delta.xy);
float2 delta_offset = delta2 * ShearAmount;
float2 delta_offset = delta2 * Strength;
Out = UV + float2(delta.y, -delta.x) * delta_offset + Offset;
}
";

15
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/UV/RotateNode.cs


Degrees
};
[Title("UV/Rotate")]
public class UVRotatorNode : CodeFunctionNode
public class RotateNode : CodeFunctionNode
{
[SerializeField]

}
}
public UVRotatorNode()
public RotateNode()
{
name = "Rotate";
}

if(m_constant == Unit.Radians)
return GetType().GetMethod("Unity_UVRotator_Radians", BindingFlags.Static | BindingFlags.NonPublic);
return GetType().GetMethod("Unity_Rotate_Radians", BindingFlags.Static | BindingFlags.NonPublic);
return GetType().GetMethod("Unity_UVRotator_Degrees", BindingFlags.Static | BindingFlags.NonPublic);
return GetType().GetMethod("Unity_Rotate_Degrees", BindingFlags.Static | BindingFlags.NonPublic);
static string Unity_UVRotator_Radians(
static string Unity_Rotate_Radians(
[Slot(0, Binding.MeshUV0)] Vector2 UV,
[Slot(1, Binding.None, 0.5f, 0.5f, 0.5f, 0.5f)] Vector2 Center,
[Slot(2, Binding.None)] Vector1 Rotation,

{precision} s = sin(Rotation);
{precision} c = cos(Rotation);
//center rotation matrix
{precision}2x2 rMatrix = float2x2(c, -s, s, c);
rMatrix *= 0.5;

}";
}
static string Unity_UVRotator_Degrees(
static string Unity_Rotate_Degrees(
[Slot(0, Binding.MeshUV0)] Vector2 UV,
[Slot(1, Binding.None, 0.5f, 0.5f, 0.5f, 0.5f)] Vector2 Center,
[Slot(2, Binding.None)] Vector1 Rotation,

return @"
{
//rotation matrix
//center rotation matrix
{precision}2x2 rMatrix = float2x2(c, -s, s, c);

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


using System.Reflection;
using UnityEngine;
using UnityEditor.Graphing;
namespace UnityEditor.ShaderGraph
{
[Title("UV/Flipbook")]
public class FlipbookNode : CodeFunctionNode
{
public FlipbookNode()
{
name = "Flipbook";
}
protected override MethodInfo GetFunctionToConvert()
{
return GetType().GetMethod("Unity_Flipbook", BindingFlags.Static | BindingFlags.NonPublic);
}
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)
{
Out = Vector2.zero;
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;
}
";
}
}
}

12
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/UV/FlipbookNode.cs.meta


fileFormatVersion: 2
guid: c31e2a2017d86b14192cc8a9fec5fffb
timeCreated: 1495718285
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

38
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/UV/PolarCoordinatesNode.cs


using System.Reflection;
using UnityEngine;
namespace UnityEditor.ShaderGraph
{
[Title("UV/Polar Coordinates")]
public class PolarCoordinatesNode : CodeFunctionNode
{
public PolarCoordinatesNode()
{
name = "Polar Coordinates";
}
protected override MethodInfo GetFunctionToConvert()
{
return GetType().GetMethod("Unity_PolarCoordinates", BindingFlags.Static | BindingFlags.NonPublic);
}
static string Unity_PolarCoordinates(
[Slot(0, Binding.MeshUV0)] Vector2 UV,
[Slot(1, Binding.None, 0.5f, 0.5f, 0.5f, 0.5f)] Vector2 Center,
[Slot(2, Binding.None, 1.0f, 1.0f, 1.0f, 1.0f)] Vector1 RadialScale,
[Slot(3, Binding.None, 1.0f, 1.0f, 1.0f, 1.0f)] Vector1 LengthScale,
[Slot(4, Binding.None)] out Vector2 Out)
{
Out = Vector2.zero;
return
@"
{
float2 delta = UV - Center;
{precision} radius = length(delta) * 2 * RadialScale;
{precision} angle = atan2(delta.x, delta.y) * 1.0/6.28 * LengthScale;
Out = float2(radius, angle);
}
";
}
}
}

37
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/UV/SpherizeNode.cs


using System.Reflection;
using UnityEngine;
namespace UnityEditor.ShaderGraph
{
[Title("UV/Spherize")]
public class SpherizeNode : CodeFunctionNode
{
public SpherizeNode()
{
name = "Spherize";
}
protected override MethodInfo GetFunctionToConvert()
{
return GetType().GetMethod("Unity_Spherize", BindingFlags.Static | BindingFlags.NonPublic);
}
static string Unity_Spherize(
[Slot(0, Binding.MeshUV0)] Vector2 UV,
[Slot(1, Binding.None, 0.5f, 0.5f, 0.5f, 0.5f)] Vector2 Center,
[Slot(2, Binding.None, 10f, 10f, 10f, 10f)] Vector2 Strength,
[Slot(3, Binding.None)] Vector2 Offset,
[Slot(4, Binding.None)] out Vector2 Out)
{
Out = Vector2.zero;
return
@"
{
float2 delta = UV - Center;
float delta2 = dot(delta.xy, delta.xy);
float delta4 = delta2 * delta2;
float2 delta_offset = delta4 * Strength;
Out = UV + delta * delta_offset + Offset;
}";
}
}
}

33
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/UV/TilingAndOffsetNode.cs


using System.Reflection;
using UnityEngine;
namespace UnityEditor.ShaderGraph
{
[Title("UV/Tiling And Offset")]
public class TilingAndOffsetNode : CodeFunctionNode
{
public TilingAndOffsetNode()
{
name = "Tiling And Offset";
}
protected override MethodInfo GetFunctionToConvert()
{
return GetType().GetMethod("Unity_TilingAndOffset", BindingFlags.Static | BindingFlags.NonPublic);
}
static string Unity_TilingAndOffset(
[Slot(0, Binding.MeshUV0)] Vector2 UV,
[Slot(1, Binding.None, 1f, 1f, 1f, 1f)] Vector2 Tiling,
[Slot(2, Binding.None, 0f, 0f, 0f, 0f)] Vector2 Offset,
[Slot(3, Binding.None)] out Vector2 Out)
{
Out = Vector2.zero;
return
@"
{
Out = UV * Tiling + Offset;
}
";
}
}
}

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


using System.Reflection;
using UnityEngine;
using UnityEditor.Graphing;
namespace UnityEditor.ShaderGraph
{
[Title("UV/Twirl")]
public class TwirlNode : CodeFunctionNode
{
public TwirlNode()
{
name = "Twirl";
}
protected override MethodInfo GetFunctionToConvert()
{
return GetType().GetMethod("Unity_Twirl", BindingFlags.Static | BindingFlags.NonPublic);
}
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(3, Binding.None)] Vector2 Offset,
[Slot(4, Binding.None)] out Vector2 Out)
{
Out = Vector2.zero;
return
@"
{
float2 delta = UV - Center;
{precision} angle = Strength * length(delta);
{precision} x = cos(angle) * delta.x - sin(angle) * delta.y;
{precision} y = sin(angle) * delta.x + cos(angle) * delta.y;
Out = float2(x + Center.x + Offset.x, y + Center.y + Offset.y);
}
";
}
}
}

34
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/UV/ScaleOffsetNode.cs


using System.Reflection;
using UnityEngine;
namespace UnityEditor.ShaderGraph
{
[Title("UV/Tiling Offset")]
public class ScaleOffsetNode : CodeFunctionNode
{
public ScaleOffsetNode()
{
name = "Tiling Offset";
}
protected override MethodInfo GetFunctionToConvert()
{
return GetType().GetMethod("Unity_ScaleAndOffset", BindingFlags.Static | BindingFlags.NonPublic);
}
static string Unity_ScaleAndOffset(
[Slot(0, Binding.MeshUV0)] Vector2 UV,
[Slot(1, Binding.None, 1f, 1f, 1f, 1f)] Vector2 Tiling,
[Slot(2, Binding.None, 0f, 0f, 0f, 0f)] Vector2 Offset,
[Slot(3, Binding.None)] out Vector2 Out)
{
Out = Vector2.zero;
return
@"
{
float4 xform = float4(Tiling, Offset);
Out = UV * xform.xy + xform.zw;
}
";
}
}
}

37
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/UV/SphereWarpNode.cs


using System.Reflection;
using UnityEngine;
namespace UnityEditor.ShaderGraph
{
[Title("UV/Spherize")]
public class SphereWarpNode : CodeFunctionNode
{
public SphereWarpNode()
{
name = "Spherize";
}
protected override MethodInfo GetFunctionToConvert()
{
return GetType().GetMethod("Unity_SphereWarp", BindingFlags.Static | BindingFlags.NonPublic);
}
static string Unity_SphereWarp(
[Slot(0, Binding.MeshUV0)] Vector2 UV,
[Slot(1, Binding.None, 0.5f, 0.5f, 0.5f, 0.5f)] Vector2 Center,
[Slot(2, Binding.None, 1f, 1f, 1f, 1f)] Vector2 WarpAmount,
[Slot(3, Binding.None)] Vector2 Offset,
[Slot(4, Binding.None)] out Vector2 Out)
{
Out = Vector2.zero;
return
@"
{
float2 delta = UV - Center;
float delta2 = dot(delta.xy, delta.xy);
float delta4 = delta2 * delta2;
float2 delta_offset = delta4 * WarpAmount;
Out = UV + delta * delta_offset + Offset;
}";
}
}
}

39
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/UV/CartesianToPolarNode.cs


using System.Reflection;
using UnityEngine;
namespace UnityEditor.ShaderGraph
{
[Title("UV/Polar Coordinates")]
public class CartesianToPolarNode : CodeFunctionNode
{
public CartesianToPolarNode()
{
name = "Polar Coordinates";
}
protected override MethodInfo GetFunctionToConvert()
{
return GetType().GetMethod("Unity_CartesianToPolar", BindingFlags.Static | BindingFlags.NonPublic);
}
static string Unity_CartesianToPolar(
[Slot(0, Binding.MeshUV0)] Vector2 UV,
[Slot(1, Binding.None, 0.5f, 0.5f, 0.5f, 0.5f)] Vector2 Center,
[Slot(2, Binding.None, 1.0f, 1.0f, 1.0f, 1.0f)] Vector1 RadialScale,
[Slot(3, Binding.None, 1.0f, 1.0f, 1.0f, 1.0f)] Vector1 LengthScale,
[Slot(4, Binding.None)] out Vector2 Out)
{
Out = Vector2.zero;
return
@"
{
float2 delta = UV - Center;
{precision} radius = length(delta) * 2 * RadialScale;
{precision} angle = atan2(delta.x, delta.y) * 1.0/6.28 * LengthScale;
Out = float2(radius, angle);
}
";
}
}
}

43
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/UV/TwistNode.cs


using System.Reflection;
using UnityEngine;
using UnityEditor.Graphing;
namespace UnityEditor.ShaderGraph
{
[Title("UV/Twirl")]
public class TwistNode : CodeFunctionNode
{
public TwistNode()
{
name = "Twirl";
}
protected override MethodInfo GetFunctionToConvert()
{
return GetType().GetMethod("Unity_Twist", BindingFlags.Static | BindingFlags.NonPublic);
}
static string Unity_Twist(
[Slot(0, Binding.MeshUV0)] Vector2 UV,
[Slot(1, Binding.None, 0.5f, 0.5f, 0.5f, 0.5f)] Vector2 Center,
[Slot(2, Binding.None, 1f, 1f, 1f, 1f)] Vector1 Strength,
[Slot(3, Binding.None)] Vector2 Offset,
[Slot(4, Binding.None)] out Vector2 Out)
{
Out = Vector2.zero;
return
@"
{
float2 delta = UV - Center;
{precision} angle = Strength * length(delta);
{precision} x = cos(angle) * delta.x - sin(angle) * delta.y;
{precision} y = sin(angle) * delta.x + cos(angle) * delta.y;
Out = float2(x + Center.x + Offset.x, y + Center.y + Offset.y);
}
";
}
}
}

/MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/UV/CartesianToPolarNode.cs.meta → /MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/UV/PolarCoordinatesNode.cs.meta

/MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/UV/ScaleOffsetNode.cs.meta → /MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/UV/TilingAndOffsetNode.cs.meta

/MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/UV/SphereWarpNode.cs.meta → /MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/UV/SpherizeNode.cs.meta

/MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/UV/TwistNode.cs.meta → /MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/UV/TwirlNode.cs.meta

/MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/UV/UVRotatorNode.cs.meta → /MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/UV/RotateNode.cs.meta

/MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/UV/UVRotatorNode.cs → /MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/UV/RotateNode.cs

正在加载...
取消
保存