浏览代码

UV Node Updates - pass 01. Main changes made to CartesianToPolar, Twist, Rotator, adding Transform. Reorganized old UV nodes based on node validation notes

/main
Natalie Burke 7 年前
当前提交
791e8bd7
共有 24 个文件被更改,包括 235 次插入57 次删除
  1. 2
      MaterialGraphProject/Assets/NewNodes/Editor/Keep/ParallaxNode.cs
  2. 2
      MaterialGraphProject/Assets/NewNodes/Editor/Keep/ScaleOffsetNode.cs
  3. 2
      MaterialGraphProject/Assets/NewNodes/Editor/Kill/MultiLayerParallaxNode.cs
  4. 2
      MaterialGraphProject/Assets/NewNodes/Editor/Kill/POMNode.cs
  5. 6
      MaterialGraphProject/Assets/NewNodes/Editor/Kill/SphereWarpNode.cs
  6. 17
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/UV/CartesianToPolarNode.cs
  7. 4
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/UV/SpherizeNode.cs
  8. 23
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/UV/TwistNode.cs
  9. 78
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/UV/UVRotatorNode.cs
  10. 46
      MaterialGraphProject/GeneratedShader.shader
  11. 6
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/UV/RadialShearNode.cs
  12. 8
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/UV/SphericalIndentationNode.cs
  13. 2
      MaterialGraphProject/Assets/NewNodes/Editor/Kill/UVPannerNode.cs
  14. 4
      MaterialGraphProject/Assets/NewNodes/Editor/Kill/UVTileNode.cs
  15. 79
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/UV/UVTransform.cs
  16. 11
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/UV/UVTransform.cs.meta
  17. 0
      /MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/UV/RadialShearNode.cs
  18. 0
      /MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/UV/RadialShearNode.cs.meta
  19. 0
      /MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/UV/SphericalIndentationNode.cs.meta
  20. 0
      /MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/UV/SphericalIndentationNode.cs
  21. 0
      /MaterialGraphProject/Assets/NewNodes/Editor/Kill/UVTileNode.cs.meta
  22. 0
      /MaterialGraphProject/Assets/NewNodes/Editor/Kill/UVPannerNode.cs.meta
  23. 0
      /MaterialGraphProject/Assets/NewNodes/Editor/Kill/UVPannerNode.cs
  24. 0
      /MaterialGraphProject/Assets/NewNodes/Editor/Kill/UVTileNode.cs

2
MaterialGraphProject/Assets/NewNodes/Editor/Keep/ParallaxNode.cs


namespace UnityEditor.ShaderGraph
{
[Title("UV/Parallax")]
[Title("OLD/Parallax")]
public class ParallaxNode : AbstractMaterialNode, IGeneratesBodyCode, IGeneratesFunction, IMayRequireMeshUV, IMayRequireViewDirection
{
protected const string kInputSlot1ShaderName = "Depth";

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


namespace UnityEditor.ShaderGraph
{
[Title("UV/ScaleOffset")]
[Title("OLD/ScaleOffset")]
public class ScaleOffsetNode : CodeFunctionNode
{
protected override MethodInfo GetFunctionToConvert()

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


namespace UnityEditor.ShaderGraph
{
[Title("UV/MultiLayerParallax")]
[Title("OLD/MultiLayerParallax")]
public class MultiLayerParallaxNode : AbstractMaterialNode, IGeneratesBodyCode, IGeneratesFunction, IMayRequireMeshUV, IMayRequireViewDirection
{
protected const string kInputDepthShaderName = "Depth";

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


namespace UnityEditor.ShaderGraph
{
[Title("UV/ParallaxOcclusionMapping")]
[Title("OLD/ParallaxOcclusionMapping")]
public class ParallaxOcclusionMappingNode : CodeFunctionNode
{
protected override MethodInfo GetFunctionToConvert()

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


namespace UnityEditor.ShaderGraph
{
[Title("UV/SphereWarpNode")]
[Title("UV/Spherize")]
public SphereWarpNode()
{
name = "Spherize";
}
protected override MethodInfo GetFunctionToConvert()
{
return GetType().GetMethod("Unity_SphereWarp", BindingFlags.Static | BindingFlags.NonPublic);

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


namespace UnityEditor.ShaderGraph
{
[Title("UV/Cartesian To Polar")]
[Title("UV/Polar Coordinates")]
name = "CartesianToPolar";
name = "Polar Coordinates";
}
protected override MethodInfo GetFunctionToConvert()

static string Unity_CartesianToPolar(
[Slot(0, Binding.MeshUV0)] Vector2 uv,
[Slot(1, Binding.None)] out Vector3 result)
[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)
result = Vector3.zero;
result = Vector2.zero;
{precision} radius = length(uv);
{precision} angle = atan2(uv.x, uv.y);
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);
}
";

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


namespace UnityEditor.ShaderGraph
{
[Title("UV/Spherize")]
[Title("OLD/SpherizeOLD")]
name = "Spherize";
name = "Spherizeold";
}
protected override MethodInfo GetFunctionToConvert()

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


namespace UnityEditor.ShaderGraph
{
[Title("UV/Twist")]
[Title("UV/Twirl")]
name = "Twist";
name = "Twirl";
}
protected override MethodInfo GetFunctionToConvert()

static string Unity_Twist(
[Slot(0, Binding.None)] Vector2 uv,
[Slot(1, Binding.None)] Vector1 twist,
[Slot(2, 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 result)
{
result = Vector2.zero;

{precision} angle = twist * length(uv);
{precision} x = cos(angle) * uv.x - sin(angle) * uv.y;
{precision} y = sin(angle) * uv.x + cos(angle) * uv.y;
result = float2(x, y);
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;
result = float2(x + center.x + offset.x, y + center.y + offset.y);
}
";
}

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


using System.Reflection;
using UnityEngine;
using UnityEditor.ShaderGraph.Drawing.Controls;
using UnityEditor.Graphing;
[Title("UV/UV Rotator")]
public enum Unit
{
Radians,
Degrees
};
[Title("UV/Rotate")]
[SerializeField]
private Unit m_constant = Unit.Radians;
[EnumControl("")]
public Unit constant
{
get { return m_constant; }
set
{
if (m_constant == value)
return;
m_constant = value;
if (onModified != null)
{
onModified(this, ModificationScope.Graph);
}
}
}
name = "UVRotator";
name = "Rotate";
return GetType().GetMethod("Unity_UVRotator", BindingFlags.Static | BindingFlags.NonPublic);
if(m_constant == Unit.Radians)
return GetType().GetMethod("Unity_UVRotator_Radians", BindingFlags.Static | BindingFlags.NonPublic);
else
return GetType().GetMethod("Unity_UVRotator_Degrees", BindingFlags.Static | BindingFlags.NonPublic);
static string Unity_UVRotator(
[Slot(0, Binding.MeshUV0)] Vector4 uv,
static string Unity_UVRotator_Radians(
[Slot(0, Binding.MeshUV0)] Vector2 uv,
[Slot(2, Binding.None)] out Vector4 result)
[Slot(2, Binding.None)] out Vector2 result)
return
@"
{

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

46
MaterialGraphProject/GeneratedShader.shader


Shader "hidden/preview/Smoothstep_F2C698A4"
Shader "hidden/preview/_D6313FDD"
Float_BAE7EB71("Strength", Float) = 1
Float_21781ECA("Ref", Float) = 0
[HideInInspector] [NonModifiableTextureData] [NoScaleOffset] Texture_930E6693("9a61064b-169a-41ef-b682-771a60220772", 2D) = "white" {}
[HideInInspector] [NonModifiableTextureData] [NoScaleOffset] Texture_38F8F2CD("texture", 2D) = "white" {}
void Unity_Smoothstep_float(float A, float B, float T, out float Out)
void Unity_ScaleAndOffset_float(float2 uv, float2 scale, float2 scaleCenter, float2 offset, out float2 result)
Out = smoothstep(A, B, T);
float4 xform = float4(scale, offset + scaleCenter - scaleCenter * scale);
result = uv * xform.xy + xform.zw;
}
struct GraphVertexInput
{

UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct SurfaceInputs{
half4 uv0;
float _Smoothstep_F2C698A4_Out;
float2 __D6313FDD_result;
surface._Smoothstep_F2C698A4_Out = scale * surface._Smoothstep_F2C698A4_Out;
surface.__D6313FDD_result = scale * surface.__D6313FDD_result;
base._Smoothstep_F2C698A4_Out = base._Smoothstep_F2C698A4_Out + add._Smoothstep_F2C698A4_Out;
base.__D6313FDD_result = base.__D6313FDD_result + add.__D6313FDD_result;
float Float_BAE7EB71;
float Float_21781ECA;
UNITY_DECLARE_TEX2D(Texture_930E6693);
float _Smoothstep_F2C698A4_A;
float _Smoothstep_F2C698A4_B;
float _Smoothstep_F2C698A4_T;
UNITY_DECLARE_TEX2D(Texture_38F8F2CD);
float4 __D6313FDD_uv;
float4 __D6313FDD_scale;
float4 __D6313FDD_scaleCenter;
float4 __D6313FDD_offset;
float _Smoothstep_F2C698A4_Out;
Unity_Smoothstep_float(_Smoothstep_F2C698A4_A, _Smoothstep_F2C698A4_B, _Smoothstep_F2C698A4_T, _Smoothstep_F2C698A4_Out);
half4 uv0 = IN.uv0;
float2 __D6313FDD_result;
Unity_ScaleAndOffset_float(uv0, __D6313FDD_scale, __D6313FDD_scaleCenter, __D6313FDD_offset, __D6313FDD_result);
surface._Smoothstep_F2C698A4_Out = _Smoothstep_F2C698A4_Out;
surface.__D6313FDD_result = __D6313FDD_result;
return surface;
}
ENDCG

struct GraphVertexOutput
{
float4 position : POSITION;
half4 uv0 : TEXCOORD;
};
GraphVertexOutput vert (GraphVertexInput v)
{

o.uv0 = v.texcoord0;
float4 uv0 = IN.uv0;
surfaceInput.uv0 =uv0;
return half4(surf._Smoothstep_F2C698A4_Out, surf._Smoothstep_F2C698A4_Out, surf._Smoothstep_F2C698A4_Out, 1.0);
return half4(surf.__D6313FDD_result.x, surf.__D6313FDD_result.y, 0.0, 1.0);
}
ENDCG
}

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


namespace UnityEditor.ShaderGraph
{
[Title("UV/RadialShearNode")]
[Title("UV/Radial Shear")]
public RadialShearNode()
{
name = "Radial Shear";
}
protected override MethodInfo GetFunctionToConvert()
{
return GetType().GetMethod("Unity_RadialShear", BindingFlags.Static | BindingFlags.NonPublic);

8
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/UV/SphericalIndentationNode.cs


namespace UnityEditor.ShaderGraph
{
[Title("UV/SphericalIndentation")]
public class SphericalIndentationNode : CodeFunctionNode
[Title("UV/Spherize 3D")]
public class SphericalIndentationNode : CodeFunctionNode
public SphericalIndentationNode()
{
name = "Spherize 3D";
}
protected override MethodInfo GetFunctionToConvert()
{
return GetType().GetMethod("Unity_SphericalIndentation", BindingFlags.Static | BindingFlags.NonPublic);

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


namespace UnityEditor.ShaderGraph
{
[Title("UV/UV Panner")]
[Title("OLD/UV Panner")]
public class PannerNode : CodeFunctionNode
{
public PannerNode()

4
MaterialGraphProject/Assets/NewNodes/Editor/Kill/UVTileNode.cs


namespace UnityEditor.ShaderGraph
{
[Title("UV/UV Tile")]
[Title("OLD/UV Tile")]
public class UVTileNode : CodeFunctionNode
{
public UVTileNode()

return
@"
{
result uv * tileFactor;
result = uv * tileFactor;
}";
}
}

79
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/UV/UVTransform.cs


using System.Reflection;
using UnityEngine;
using UnityEditor.ShaderGraph.Drawing.Controls;
using UnityEditor.Graphing;
namespace UnityEditor.ShaderGraph
{
public enum RotationUnit
{
Radians,
Degrees
};
[Title("UV/Transform")]
public class UVTransform : CodeFunctionNode
{
[SerializeField]
private RotationUnit m_constant = RotationUnit.Radians;
[EnumControl("")]
public RotationUnit constant
{
get { return m_constant; }
set
{
if (m_constant == value)
return;
m_constant = value;
if (onModified != null)
{
onModified(this, ModificationScope.Graph);
}
}
}
public UVTransform()
{
name = "Transform";
}
protected override MethodInfo GetFunctionToConvert()
{
return GetType().GetMethod("Unity_ScaleOffsetRotate", BindingFlags.Static | BindingFlags.NonPublic);
}
static string Unity_ScaleOffsetRotate(
[Slot(0, Binding.MeshUV0)] Vector2 uv,
[Slot(1, Binding.None, 1f, 1f, 1f, 1f)] Vector2 scale,
[Slot(2, Binding.None)] Vector2 offset,
[Slot(3, Binding.None)] Vector1 rotation,
[Slot(4, Binding.None)] out Vector2 result)
{
result = Vector2.zero;
return
@"
{
uv -= offset;
{precision} s = sin(rotation);
{precision} c = cos(rotation);
//center rotation matrix
{precision}2x2 rMatrix = float2x2(c, -s, s, c);
rMatrix *= 0.5;
rMatrix += 0.5;
rMatrix = rMatrix*2 - 1;
//multiply the UVs by the rotation matrix
uv.xy = mul(uv.xy, rMatrix);
uv += offset;
float4 xform = float4(scale, offset + offset - offset * scale);
result = uv * xform.xy + xform.zw;
}
";
}
}
}

11
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/UV/UVTransform.cs.meta


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

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

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

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

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

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

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

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

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

正在加载...
取消
保存