浏览代码

Merge pull request #1462 from Unity-Technologies/sg/spheremasknode

Added Sphere Mask Node
/main
GitHub 6 年前
当前提交
4138567f
共有 4 个文件被更改,包括 59 次插入0 次删除
  1. 6
      com.unity.shadergraph/CHANGELOG.md
  2. 3
      com.unity.shadergraph/.data/sphereMask.PNG
  3. 39
      com.unity.shadergraph/Editor/Data/Nodes/Math/Vector/SphereMaskNode.cs
  4. 11
      com.unity.shadergraph/Editor/Data/Nodes/Math/Vector/SphereMaskNode.cs.meta

6
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.
### Sphere Mask Node
![](.data/sphereMask.png)
With this node, you can create a sphere mask. Indicate the starting coordinate and center point. The sphere mask uses these with the **Radius** and **Hardness** parameters. Sphere mask functionality works in both 2D and 3D spaces, and is based on the vector coordinates in the **Coords and Center** input.
### Texture3D and Texture2D Array
![](.data/texture_nodes.png)

3
com.unity.shadergraph/.data/sphereMask.PNG


version https://git-lfs.github.com/spec/v1
oid sha256:8df3a610b0b2a3f8d3b6a2b9ddb563c3a74e682055b53bc728ac7f795870d9ad
size 91474

39
com.unity.shadergraph/Editor/Data/Nodes/Math/Vector/SphereMaskNode.cs


using System.Reflection;
using UnityEngine;
namespace UnityEditor.ShaderGraph
{
[Title("Math", "Vector", "Sphere Mask")]
public class SphereMaskNode : CodeFunctionNode
{
public SphereMaskNode()
{
name = "Sphere Mask";
}
public override string documentationURL
{
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/Sphere-Mask-Node"; }
}
protected override MethodInfo GetFunctionToConvert()
{
return GetType().GetMethod("SphereMask", BindingFlags.Static | BindingFlags.NonPublic);
}
static string SphereMask(
[Slot(0, Binding.None)] DynamicDimensionVector Coords,
[Slot(1, Binding.None, 0.5f, 0.5f, 0.5f, 0.5f)] DynamicDimensionVector Center,
[Slot(2, Binding.None, 0.1f, 0.1f, 0.1f, 0.1f)] Vector1 Radius,
[Slot(3, Binding.None, 0.8f, 0.8f, 0.8f, 0.8f)] Vector1 Hardness,
[Slot(4, Binding.None)] out DynamicDimensionVector Out)
{
return
@"
{
Out = 1 - saturate((distance(Coords, Center) - Radius) / (1 - Hardness));
}
";
}
}
}

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


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