您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
51 行
1.6 KiB
51 行
1.6 KiB
using UnityEngine.Graphing;
|
|
using System.Collections.Generic;
|
|
using System.Reflection;
|
|
|
|
namespace UnityEngine.MaterialGraph
|
|
{
|
|
[Title("Art/Adjustments/Levels")]
|
|
public class LevelsNode : CodeFunctionNode
|
|
{
|
|
[SerializeField]
|
|
private float m_InputMin = 0.0f;
|
|
[SerializeField]
|
|
private float m_InputMax = 1.0f;
|
|
[SerializeField]
|
|
private float m_InputGamma = 1.0f;
|
|
[SerializeField]
|
|
private float m_OutputMin = 0.0f;
|
|
[SerializeField]
|
|
private float m_OutputMax = 1.0f;
|
|
|
|
public LevelsNode()
|
|
{
|
|
name = "Levels";
|
|
}
|
|
|
|
|
|
protected override MethodInfo GetFunctionToConvert()
|
|
{
|
|
return GetType().GetMethod("Unity_Levels", BindingFlags.Static | BindingFlags.NonPublic);
|
|
}
|
|
|
|
static string Unity_Levels(
|
|
[Slot(0, Binding.None)] DynamicDimensionVector input,
|
|
[Slot(1, Binding.None)] Vector1 inputMin,
|
|
[Slot(2, Binding.None, 1, 1, 1, 1)] Vector1 inputMax,
|
|
[Slot(3, Binding.None, 1, 1, 1, 1)] Vector1 inputInvGamma,
|
|
[Slot(4, Binding.None)] Vector1 outputMin,
|
|
[Slot(5, Binding.None, 1, 1, 1, 1)] Vector1 outputMax,
|
|
[Slot(6, Binding.None)] out DynamicDimensionVector result)
|
|
{
|
|
return
|
|
@"
|
|
{
|
|
{precision}{slot6dimension} colorMinClamped = max(arg1 - inputMin, 0.0);
|
|
{precision}{slot6dimension} colorMinMaxClamped = min(colorMinClamped / (inputMax - inputMin), 1.0);
|
|
return lerp(outputMin, outputMax, pow(colorMinMaxClamped, inputInvGamma));
|
|
}
|
|
";
|
|
}
|
|
}
|
|
}
|