浏览代码

Added Wave Form Nodes (#1547)

* small sampling of wave form nodes
* updates to waveform calcs
* fixed noise wave function
* updates noise wave and changelog
* update name of node directory folder
* updated maths and noise sine wave node name + changelog
* updated filename for noise sine wave node
* updated float to precision in noise sine wave
* updated changelog
/main
Matt Dean 6 年前
当前提交
c6494b51
共有 12 个文件被更改,包括 642 次插入0 次删除
  1. 8
      com.unity.shadergraph/CHANGELOG.md
  2. 436
      com.unity.shadergraph/.data/wave_form_nodes.PNG
  3. 8
      com.unity.shadergraph/Editor/Data/Nodes/Math/Wave.meta
  4. 41
      com.unity.shadergraph/Editor/Data/Nodes/Math/Wave/NoiseSineWaveNode.cs
  5. 11
      com.unity.shadergraph/Editor/Data/Nodes/Math/Wave/NoiseSineWaveNode.cs.meta
  6. 35
      com.unity.shadergraph/Editor/Data/Nodes/Math/Wave/SawtoothWaveNode.cs
  7. 11
      com.unity.shadergraph/Editor/Data/Nodes/Math/Wave/SawtoothWaveNode.cs.meta
  8. 35
      com.unity.shadergraph/Editor/Data/Nodes/Math/Wave/SquareWaveNode.cs
  9. 11
      com.unity.shadergraph/Editor/Data/Nodes/Math/Wave/SquareWaveNode.cs.meta
  10. 35
      com.unity.shadergraph/Editor/Data/Nodes/Math/Wave/TriangleWaveNode.cs
  11. 11
      com.unity.shadergraph/Editor/Data/Nodes/Math/Wave/TriangleWaveNode.cs.meta

8
com.unity.shadergraph/CHANGELOG.md


This adds gradient functionality via two new nodes. The Sample Gradient node samples a gradient given a Time parameter. You can define this gradient on the Gradient slot control view. The Gradient Asset node defines a gradient that can be sampled by multiple Sample Gradient nodes using different Time parameters.
### Waveform nodes
![](.data/wave_form_nodes.png)
Math nodes now have a Waves category. The category has four different nodes: Triangle wave, Sawtooth wave, Square wave, and Noise Sine wave.
The Triangle, Sawtooth, and Square wave nodes output a waveform with a range of -1 to 1 over a period of 1.
The Noise Sine wave outputs a standard Sine wave with a range of -1 to 1 over a period of 2 * pi. For variance, random noise is added to the amplitude of the Sine wave, within a determined range.
## Normal Derive Nodes
![](.data/normal_derive_nodes.png)

436
com.unity.shadergraph/.data/wave_form_nodes.PNG

之前 之后
宽度: 1187  |  高度: 747  |  大小: 85 KiB

8
com.unity.shadergraph/Editor/Data/Nodes/Math/Wave.meta


fileFormatVersion: 2
guid: 24b10579e42f5f845a9f2ab79f921476
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

41
com.unity.shadergraph/Editor/Data/Nodes/Math/Wave/NoiseSineWaveNode.cs


using UnityEngine;
using System.Reflection;
namespace UnityEditor.ShaderGraph
{
[Title("Math", "Wave", "Noise Sine Wave")]
class NoiseSineWaveNode : CodeFunctionNode
{
public NoiseSineWaveNode()
{
name = "Noise Sine Wave";
}
public override string documentationURL
{
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/Noise-Sine-Wave-Node"; }
}
protected override MethodInfo GetFunctionToConvert()
{
return GetType().GetMethod("NoiseSineWave", BindingFlags.Static | BindingFlags.NonPublic);
}
static string NoiseSineWave(
[Slot(0, Binding.None)] DynamicDimensionVector In,
[Slot(1, Binding.None, -0.5f, 0.5f, 1, 1)] Vector2 MinMax,
[Slot(2, Binding.None)] out DynamicDimensionVector Out)
{
return
@"
{
{precision} sinIn = sin(In);
{precision} sinInOffset = sin(In + 1.0);
{precision} randomno = frac(sin((sinIn - sinInOffset) * (12.9898 + 78.233))*43758.5453);
{precision} noise = lerp(MinMax.x, MinMax.y, randomno);
Out = sinIn + noise;
}
";
}
}
}

11
com.unity.shadergraph/Editor/Data/Nodes/Math/Wave/NoiseSineWaveNode.cs.meta


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

35
com.unity.shadergraph/Editor/Data/Nodes/Math/Wave/SawtoothWaveNode.cs


using System.Reflection;
namespace UnityEditor.ShaderGraph
{
[Title("Math", "Wave", "Sawtooth Wave")]
class SawtoothWaveNode : CodeFunctionNode
{
public SawtoothWaveNode()
{
name = "Sawtooth Wave";
}
public override string documentationURL
{
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/Sawtooth-Wave-Node"; }
}
protected override MethodInfo GetFunctionToConvert()
{
return GetType().GetMethod("SawtoothWave", BindingFlags.Static | BindingFlags.NonPublic);
}
static string SawtoothWave(
[Slot(0, Binding.None)] DynamicDimensionVector In,
[Slot(1, Binding.None)] out DynamicDimensionVector Out)
{
return
@"
{
Out = 2 * (In - floor(0.5 + In));
}
";
}
}
}

11
com.unity.shadergraph/Editor/Data/Nodes/Math/Wave/SawtoothWaveNode.cs.meta


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

35
com.unity.shadergraph/Editor/Data/Nodes/Math/Wave/SquareWaveNode.cs


using System.Reflection;
namespace UnityEditor.ShaderGraph
{
[Title("Math", "Wave", "Square Wave")]
class SquareWaveNode : CodeFunctionNode
{
public SquareWaveNode()
{
name = "Square Wave";
}
public override string documentationURL
{
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/Square-Wave-Node"; }
}
protected override MethodInfo GetFunctionToConvert()
{
return GetType().GetMethod("SquareWave", BindingFlags.Static | BindingFlags.NonPublic);
}
static string SquareWave(
[Slot(0, Binding.None)] DynamicDimensionVector In,
[Slot(1, Binding.None)] out DynamicDimensionVector Out)
{
return
@"
{
Out = 1.0 - 2.0 * round(frac(In));
}
";
}
}
}

11
com.unity.shadergraph/Editor/Data/Nodes/Math/Wave/SquareWaveNode.cs.meta


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

35
com.unity.shadergraph/Editor/Data/Nodes/Math/Wave/TriangleWaveNode.cs


using System.Reflection;
namespace UnityEditor.ShaderGraph
{
[Title("Math", "Wave", "Triangle Wave")]
class TriangleWaveNode : CodeFunctionNode
{
public TriangleWaveNode()
{
name = "Triangle Wave";
}
public override string documentationURL
{
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/Triangle-Wave-Node"; }
}
protected override MethodInfo GetFunctionToConvert()
{
return GetType().GetMethod("TriangleWave", BindingFlags.Static | BindingFlags.NonPublic);
}
static string TriangleWave(
[Slot(0, Binding.None)] DynamicDimensionVector In,
[Slot(1, Binding.None)] out DynamicDimensionVector Out)
{
return
@"
{
Out = 2.0 * abs( 2 * (In - floor(0.5 + In)) ) - 1.0;
}
";
}
}
}

11
com.unity.shadergraph/Editor/Data/Nodes/Math/Wave/TriangleWaveNode.cs.meta


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