您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
35 行
1.1 KiB
35 行
1.1 KiB
using System.Reflection;
|
|
using UnityEngine.Graphing;
|
|
|
|
namespace UnityEngine.MaterialGraph
|
|
{
|
|
[Title("Art/Conversion/LineartoRGB")]
|
|
public class LineartoRGBNode : CodeFunctionNode
|
|
{
|
|
public LineartoRGBNode()
|
|
{
|
|
name = "LineartoRGB";
|
|
}
|
|
|
|
protected override MethodInfo GetFunctionToConvert()
|
|
{
|
|
return GetType().GetMethod("Unity_LinearToRGB", BindingFlags.Static | BindingFlags.NonPublic);
|
|
}
|
|
|
|
static string Unity_LinearToRGB(
|
|
[Slot(0, Binding.None)] Vector3 linearColor,
|
|
[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}3 sRGBLo = linearColor * 12.92;
|
|
{precision}3 sRGBHi = (pow(max(abs(linearColor), 1.192092896e-07), {precision}3(1.0 / 2.4, 1.0 / 2.4, 1.0 / 2.4)) * 1.055) - 0.055;
|
|
rgb = {precision}3(linearColor <= 0.0031308) ? sRGBLo : sRGBHi;
|
|
}
|
|
";
|
|
}
|
|
}
|
|
}
|