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

35 行
1.0 KiB

using System.Reflection;
using UnityEngine.Graphing;
namespace UnityEngine.MaterialGraph
{
[Title("Art/Conversion/HSVtoRGB")]
public class HSVtoRGBNode : CodeFunctionNode
{
public HSVtoRGBNode()
{
name = "HSVtoRGB";
}
protected override MethodInfo GetFunctionToConvert()
{
return GetType().GetMethod("Unity_HSVToRGB", BindingFlags.Static | BindingFlags.NonPublic);
}
static string Unity_HSVToRGB(
[Slot(0, Binding.None)] Vector3 hsv,
[Slot(1, Binding.None)] out Vector3 rgb)
{
rgb = Vector3.zero;
return
@"
{
//Reference code from:https://github.com/Unity-Technologies/PostProcessing/blob/master/PostProcessing/Resources/Shaders/ColorGrading.cginc#L175
{precision}4 K = {precision}4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
{precision}3 P = abs(frac(hsv.xxx + K.xyz) * 6.0 - K.www);
rgb = hsv.z * lerp(K.xxx, saturate(P - K.xxx), hsv.y);
}
";
}
}
}