您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
47 行
1.2 KiB
47 行
1.2 KiB
using System.Reflection;
|
|
|
|
namespace UnityEngine.MaterialGraph
|
|
{
|
|
[Title("Art/Adjustments/ColorBalance")]
|
|
public class ColorBalanceNode : CodeFunctionNode
|
|
{
|
|
public ColorBalanceNode()
|
|
{
|
|
name = "ColorBalance";
|
|
}
|
|
|
|
protected override MethodInfo GetFunctionToConvert()
|
|
{
|
|
return GetType().GetMethod("Unity_ColorBalance", BindingFlags.Static | BindingFlags.NonPublic);
|
|
}
|
|
|
|
static string Unity_ColorBalance(
|
|
[Slot(0, Binding.None)] Vector4 inputColor,
|
|
[Slot(1, Binding.None)] Vector3 adjustRGB,
|
|
[Slot(2, Binding.None)] out Vector4 outColor)
|
|
{
|
|
outColor = Vector4.zero;
|
|
return
|
|
@"
|
|
{
|
|
float red = 0;
|
|
float green = 0;
|
|
float blue = 0;
|
|
|
|
red = 1.00f / (1-adjustRGB.r) * inputColor.r;
|
|
green = 1.00f / (1-adjustRGB.g) * inputColor.g;
|
|
blue = 1.00f / (1-adjustRGB.b) * inputColor.b;
|
|
|
|
red = clamp(red,0.00f,1.00f);
|
|
green = clamp(green,0.00f,1.00f);
|
|
blue = clamp(blue,0.00f,1.00f);
|
|
|
|
outColor.r = red;
|
|
outColor.g = green;
|
|
outColor.b = blue;
|
|
outColor.a = inputColor.a;
|
|
}
|
|
";
|
|
}
|
|
}
|
|
}
|