您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 

37 行
1011 B

using System.Reflection;
using UnityEngine;
namespace UnityEditor.ShaderGraph
{
[Title("OLD/Line")]
public class LineNode : CodeFunctionNode
{
public LineNode()
{
name = "Line";
}
protected override MethodInfo GetFunctionToConvert()
{
return GetType().GetMethod("Unity_Linenode", BindingFlags.Static | BindingFlags.NonPublic);
}
static string Unity_Linenode(
[Slot(0, Binding.MeshUV0)] Vector2 uv,
[Slot(1, Binding.None)] Vector2 startPoint,
[Slot(2, Binding.None)] Vector2 endPoint,
[Slot(3, Binding.None)] out Vector1 result)
{
return
@"
{
{precision}2 aTob = endPoint - startPoint;
{precision}2 aTop = uv - startPoint;
{precision} t = dot(aTop, aTob) / dot(aTob, aTob);
t = clamp(t, 0.0, 1.0);
{precision} d = 1.0 / length(uv - (startPoint + aTob * t));
result = clamp(d, 0.0, 1.0);
}";
}
}
}