You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
979 B
34 lines
979 B
using System.Reflection;
|
|
using UnityEngine;
|
|
|
|
namespace UnityEditor.ShaderGraph
|
|
{
|
|
[Title("Math", "Vector", "Sphere Mask")]
|
|
class SphereMaskNode : CodeFunctionNode
|
|
{
|
|
public SphereMaskNode()
|
|
{
|
|
name = "Sphere Mask";
|
|
}
|
|
|
|
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 Vector1 Out)
|
|
{
|
|
return
|
|
@"
|
|
{
|
|
Out = 1 - saturate((distance(Coords, Center) - Radius) / (1 - Hardness));
|
|
}
|
|
";
|
|
}
|
|
}
|
|
}
|