浏览代码

Added new Rotation about axis node (#1695)

* Added new Rotation about axis node
* changes for pr
* changed description
/main
Matt Dean 6 年前
当前提交
0a5ac9f7
共有 4 个文件被更改,包括 434 次插入2 次删除
  1. 9
      com.unity.shadergraph/CHANGELOG.md
  2. 316
      com.unity.shadergraph/.data/rotate_about_axis_node.png
  3. 100
      com.unity.shadergraph/Editor/Data/Nodes/Math/Vector/RotateAboutAxisNode.cs
  4. 11
      com.unity.shadergraph/Editor/Data/Nodes/Math/Vector/RotateAboutAxisNode.cs.meta

9
com.unity.shadergraph/CHANGELOG.md


![](.data/editable_property_references.gif)
You can now edit the Reference name for a property. To do so, select the property and type a new name next to Reference. If you want to reset to the default name, right-click Reference, and select Reset reference.
You can now edit the Reference name for a property. To do so, select the property and type a new name next to Reference. If you want to reset to the default name, right-click Reference, and select Reset reference.
In the expanded property window, you can now also toggle if the property is exposed.

![](.data/texture_2d_lod_node.png)
This adds a new node for LOD functionality on a Texture 2D Sample. Sample Texture 2D LOD uses the exact same input and output slots as Sample Texture 2D, but also includes an input for level of detail adjustments via a Vector1 slot.
This adds a new node for LOD functionality on a Texture 2D Sample. Sample Texture 2D LOD uses the exact same input and output slots as Sample Texture 2D, but also includes an input for level of detail adjustments via a Vector1 slot.
### Texel Size Node

You can now see the generated code for any specific node. To do so, right-click the node, and select Show Generated Code. The code snippet will now open in the code editor that you have linked to Unity.
### Rotate About Axis node
![](.data/rotate_about_axis_node.png)
With the Rotate About Axis node, you can rotate a 3D vector space around an axis. For the rotation, you can specify an amount of degrees or a radian value.
### Bug fixes and minor changes

316
com.unity.shadergraph/.data/rotate_about_axis_node.png

之前 之后
宽度: 492  |  高度: 532  |  大小: 85 KiB

100
com.unity.shadergraph/Editor/Data/Nodes/Math/Vector/RotateAboutAxisNode.cs


using System.Reflection;
using UnityEngine;
using UnityEditor.ShaderGraph.Drawing.Controls;
using UnityEditor.Graphing;
namespace UnityEditor.ShaderGraph
{
[Title("Math", "Vector", "Rotate About Axis")]
public class RotateAboutAxisNode : CodeFunctionNode
{
[SerializeField]
private RotationUnit m_Unit = RotationUnit.Radians;
[EnumControl("Unit")]
public RotationUnit unit
{
get { return m_Unit; }
set
{
if (m_Unit == value)
return;
m_Unit = value;
Dirty(ModificationScope.Graph);
}
}
public RotateAboutAxisNode()
{
name = "Rotate About Axis";
}
public override string documentationURL
{
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/Rotate-About-Axis-Node"; }
}
protected override MethodInfo GetFunctionToConvert()
{
if (m_Unit == RotationUnit.Radians)
return GetType().GetMethod("Unity_Rotate_About_Axis_Radians", BindingFlags.Static | BindingFlags.NonPublic);
else
return GetType().GetMethod("Unity_Rotate_About_Axis_Degrees", BindingFlags.Static | BindingFlags.NonPublic);
}
static string Unity_Rotate_About_Axis_Degrees(
[Slot(0, Binding.None)] Vector3 In,
[Slot(1, Binding.None)] Vector3 Axis,
[Slot(2, Binding.None)] Vector1 Rotation,
[Slot(3, Binding.None)] out Vector3 Out)
{
Out = In;
return
@"
{
{precision} s = sin(Rotation);
{precision} c = cos(Rotation);
{precision} one_minus_c = 1.0 - c;
Axis = normalize(Axis);
{precision}3x3 rot_mat = { one_minus_c * Axis.x * Axis.x + c, one_minus_c * Axis.x * Axis.y - Axis.z * s, one_minus_c * Axis.z * Axis.x + Axis.y * s,
one_minus_c * Axis.x * Axis.y + Axis.z * s, one_minus_c * Axis.y * Axis.y + c, one_minus_c * Axis.y * Axis.z - Axis.x * s,
one_minus_c * Axis.z * Axis.x - Axis.y * s, one_minus_c * Axis.y * Axis.z + Axis.x * s, one_minus_c * Axis.z * Axis.z + c
};
Out = mul(rot_mat, In);
}
";
}
static string Unity_Rotate_About_Axis_Radians(
[Slot(0, Binding.None)] Vector3 In,
[Slot(1, Binding.None)] Vector3 Axis,
[Slot(2, Binding.None)] Vector1 Rotation,
[Slot(3, Binding.None)] out Vector3 Out)
{
Out = In;
return
@"
{
Rotation = radians(Rotation);
{precision} s = sin(Rotation);
{precision} c = cos(Rotation);
{precision} one_minus_c = 1.0 - c;
Axis = normalize(Axis);
{precision}3x3 rot_mat = { one_minus_c * Axis.x * Axis.x + c, one_minus_c * Axis.x * Axis.y - Axis.z * s, one_minus_c * Axis.z * Axis.x + Axis.y * s,
one_minus_c * Axis.x * Axis.y + Axis.z * s, one_minus_c * Axis.y * Axis.y + c, one_minus_c * Axis.y * Axis.z - Axis.x * s,
one_minus_c * Axis.z * Axis.x - Axis.y * s, one_minus_c * Axis.y * Axis.z + Axis.x * s, one_minus_c * Axis.z * Axis.z + c
};
Out = mul(rot_mat, In);
}
";
}
}
}

11
com.unity.shadergraph/Editor/Data/Nodes/Math/Vector/RotateAboutAxisNode.cs.meta


fileFormatVersion: 2
guid: f4eb8feccb0350d46a88b15271a33cb2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存