浏览代码

changing result to out - cutting transfrom - adding Tiling Offset. Some functionality may change based on Tiling Offset UV input/texture node changes

/main
Natalie Burke 7 年前
当前提交
9650733e
共有 18 个文件被更改,包括 125 次插入123 次删除
  1. 20
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/UV/CartesianToPolarNode.cs
  2. 18
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/UV/RadialShearNode.cs
  3. 18
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/UV/TwistNode.cs
  4. 45
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/UV/UVRotatorNode.cs
  5. 6
      MaterialGraphProject/Assets/NewNodes/Editor/Kill/SpherizeNode.cs
  6. 2
      MaterialGraphProject/Assets/NewNodes/Editor/Kill/UVTransform.cs
  7. 34
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/UV/ScaleOffsetNode.cs
  8. 37
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/UV/SphereWarpNode.cs
  9. 31
      MaterialGraphProject/Assets/NewNodes/Editor/Keep/ScaleOffsetNode.cs
  10. 37
      MaterialGraphProject/Assets/NewNodes/Editor/Kill/SphereWarpNode.cs
  11. 0
      /MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/UV/ScaleOffsetNode.cs.meta
  12. 0
      /MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/UV/SphereWarpNode.cs.meta
  13. 0
      /MaterialGraphProject/Assets/NewNodes/Editor/Kill/SpherizeNode.cs.meta
  14. 0
      /MaterialGraphProject/Assets/NewNodes/Editor/Kill/SpherizeNode.cs
  15. 0
      /MaterialGraphProject/Assets/NewNodes/Editor/Kill/UVTransform.cs
  16. 0
      /MaterialGraphProject/Assets/NewNodes/Editor/Kill/UVTransform.cs.meta
  17. 0
      /MaterialGraphProject/Assets/NewNodes/Editor/Kill/SphericalIndentationNode.cs.meta
  18. 0
      /MaterialGraphProject/Assets/NewNodes/Editor/Kill/SphericalIndentationNode.cs

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


}
static string Unity_CartesianToPolar(
[Slot(0, Binding.MeshUV0)] Vector2 uv,
[Slot(1, Binding.None, 1.0f, 1.0f, 1.0f, 1.0f)] Vector1 radialScale,
[Slot(2, Binding.None, 1.0f, 1.0f, 1.0f, 1.0f)] Vector1 lengthScale,
[Slot(3, Binding.None, 0.5f, 0.5f, 0.5f, 0.5f)] Vector2 center,
[Slot(4, Binding.None)] out Vector2 result)
[Slot(0, Binding.MeshUV0)] Vector2 UV,
[Slot(1, Binding.None, 1.0f, 1.0f, 1.0f, 1.0f)] Vector1 RadialScale,
[Slot(2, Binding.None, 1.0f, 1.0f, 1.0f, 1.0f)] Vector1 LengthScale,
[Slot(3, Binding.None, 0.5f, 0.5f, 0.5f, 0.5f)] Vector2 Center,
[Slot(4, Binding.None)] out Vector2 Out)
result = Vector2.zero;
Out = Vector2.zero;
float2 delta = uv - center;
{precision} radius = length(delta) * 2 * radialScale;
{precision} angle = atan2(delta.x, delta.y) * 1.0/6.28 * lengthScale;
result = float2(radius, angle);
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);
}
";
}

18
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(3, Binding.None)] Vector2 offset,
[Slot(4, Binding.None)] out Vector2 result)
[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(3, Binding.None)] Vector2 Offset,
[Slot(4, Binding.None)] out Vector2 Out)
result = Vector2.zero;
Out = Vector2.zero;
float2 delta = uv - center;
float2 delta = UV - Center;
float2 delta_offset = delta2 * shearAmount;
result = uv + float2(delta.y, -delta.x) * delta_offset + offset;
float2 delta_offset = delta2 * ShearAmount;
Out = UV + float2(delta.y, -delta.x) * delta_offset + Offset;
}
";
}

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


}
static string Unity_Twist(
[Slot(0, Binding.MeshUV0)] Vector2 uv,
[Slot(1, Binding.None, 1f, 1f, 1f, 1f)] Vector1 strength,
[Slot(2, Binding.None, 0.5f, 0.5f, 0.5f, 0.5f)] Vector2 center,
[Slot(3, Binding.None)] Vector2 offset,
[Slot(4, Binding.None)] out Vector2 result)
[Slot(0, Binding.MeshUV0)] Vector2 UV,
[Slot(1, Binding.None, 1f, 1f, 1f, 1f)] Vector1 Strength,
[Slot(2, Binding.None, 0.5f, 0.5f, 0.5f, 0.5f)] Vector2 Center,
[Slot(3, Binding.None)] Vector2 Offset,
[Slot(4, Binding.None)] out Vector2 Out)
result = Vector2.zero;
Out = Vector2.zero;
return
@"

float2 delta = uv - center;
{precision} angle = strength * length(delta);
float2 delta = UV - Center;
{precision} angle = Strength * length(delta);
result = float2(x + center.x + offset.x, y + center.y + offset.y);
Out = float2(x + Center.x + Offset.x, y + Center.y + Offset.y);
}
";
}

45
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/UV/UVRotatorNode.cs


}
static string Unity_UVRotator_Radians(
[Slot(0, Binding.MeshUV0)] Vector2 uv,
[Slot(1, Binding.None)] Vector1 rotation,
[Slot(2, Binding.None)] out Vector2 result)
[Slot(0, Binding.MeshUV0)] Vector2 UV,
[Slot(1, Binding.None)] Vector1 Rotation,
[Slot(2, Binding.None)] out Vector2 Out)
result = Vector2.zero;
Out = Vector2.zero;
return

uv.xy -= 0.5;
{precision} s = sin(rotation);
{precision} c = cos(rotation);
UV.xy -= 0.5;
{precision} s = sin(Rotation);
{precision} c = cos(Rotation);
//center rotation matrix

rMatrix = rMatrix*2 - 1;
//multiply the UVs by the rotation matrix
uv.xy = mul(uv.xy, rMatrix);
uv.xy += 0.5;
UV.xy = mul(UV.xy, rMatrix);
UV.xy += 0.5;
result = uv;
Out = UV;
[Slot(0, Binding.MeshUV0)] Vector2 uv,
[Slot(1, Binding.None)] Vector1 rotation,
[Slot(2, Binding.None)] out Vector2 result)
[Slot(0, Binding.MeshUV0)] Vector2 UV,
[Slot(1, Binding.None)] Vector1 Rotation,
[Slot(2, Binding.None)] out Vector2 Out)
result = Vector2.zero;
//Unity_UVRotator_Radians(uv, rotation, out result)
//rotation = rotation * (3.1415926f/180.0f)
Out = Vector2.zero;
rotation = rotation * (3.1415926f/180.0f);
uv.xy -= 0.5;
{precision} s = sin(rotation);
{precision} c = cos(rotation);
Rotation = Rotation * (3.1415926f/180.0f);
UV.xy -= 0.5;
{precision} s = sin(Rotation);
{precision} c = cos(Rotation);
//center rotation matrix

rMatrix = rMatrix*2 - 1;
//multiply the UVs by the rotation matrix
uv.xy = mul(uv.xy, rMatrix);
uv.xy += 0.5;
UV.xy = mul(UV.xy, rMatrix);
UV.xy += 0.5;
result = uv;
Out = UV;
}";
}

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


[Slot(0, Binding.MeshUV0)] Vector2 uv,
[Slot(1, Binding.None)] Vector2 position,
[Slot(2, Binding.None)] Vector2 radiusAndStrength,
[Slot(3, Binding.None)] out Vector2 result)
[Slot(3, Binding.None)] out Vector2 Out)
result = Vector2.zero;
Out = Vector2.zero;
return
@"
{

result = uv + (mag * fromUVToPoint);
Out = uv + (mag * fromUVToPoint);
}";
}
}

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


Radians,
Degrees
};
[Title("UV/Transform")]
[Title("OLD/Transform")]
public class UVTransform : CodeFunctionNode
{

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;
}";
}
}
}

31
MaterialGraphProject/Assets/NewNodes/Editor/Keep/ScaleOffsetNode.cs


using System.Reflection;
using UnityEngine;
namespace UnityEditor.ShaderGraph
{
[Title("OLD/ScaleOffset")]
public class ScaleOffsetNode : CodeFunctionNode
{
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 scale,
[Slot(2, Binding.None, 0.5f, 0.5f, 0.5f, 0.5f)] Vector2 scaleCenter,
[Slot(3, Binding.None)] Vector2 offset,
[Slot(4, Binding.None)] out Vector2 result)
{
result = Vector2.zero;
return
@"
{
float4 xform = float4(scale, offset + scaleCenter - scaleCenter * scale);
result = uv * xform.xy + xform.zw;
}
";
}
}
}

37
MaterialGraphProject/Assets/NewNodes/Editor/Kill/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 result)
{
result = Vector2.zero;
return
@"
{
float2 delta = uv - center;
float delta2 = dot(delta.xy, delta.xy);
float delta4 = delta2 * delta2;
float2 delta_offset = delta4 * warpAmount;
result = uv + delta * delta_offset + offset;
}";
}
}
}

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

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

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

/MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/UV/SpherizeNode.cs → /MaterialGraphProject/Assets/NewNodes/Editor/Kill/SpherizeNode.cs

/MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/UV/UVTransform.cs → /MaterialGraphProject/Assets/NewNodes/Editor/Kill/UVTransform.cs

/MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/UV/UVTransform.cs.meta → /MaterialGraphProject/Assets/NewNodes/Editor/Kill/UVTransform.cs.meta

/MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/UV/SphericalIndentationNode.cs.meta → /MaterialGraphProject/Assets/NewNodes/Editor/Kill/SphericalIndentationNode.cs.meta

/MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/UV/SphericalIndentationNode.cs → /MaterialGraphProject/Assets/NewNodes/Editor/Kill/SphericalIndentationNode.cs

正在加载...
取消
保存