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

42 行
1.4 KiB

using UnityEngine.Graphing;
namespace UnityEngine.MaterialGraph
{
[Title ("Math/Color/RGBtoLuminance")]
public class RGBtoLuminance : Function1Input, IGeneratesFunction
{
public RGBtoLuminance()
{
name = "RGBtoLuminance";
}
protected override string GetFunctionName ()
{
return "unity_rgbtoluminance_" + precision;
}
protected override MaterialSlot GetInputSlot ()
{
return new MaterialSlot (InputSlotId, GetInputSlotName (), kInputSlotShaderName, SlotType.Input, SlotValueType.Vector3, Vector4.zero);
}
protected override MaterialSlot GetOutputSlot ()
{
return new MaterialSlot (OutputSlotId, GetOutputSlotName (), kOutputSlotShaderName, SlotType.Output, SlotValueType.Vector1, Vector4.zero);
}
// Convert rgb to luminance with rgb in linear space with sRGB primaries and D65 white point (from PostProcessing)
public void GenerateNodeFunction (ShaderGenerator visitor, GenerationMode generationMode)
{
var outputString = new ShaderGenerator ();
outputString.AddShaderChunk (GetFunctionPrototype ("arg1"), false);
outputString.AddShaderChunk ("{", false);
outputString.Indent ();
outputString.AddShaderChunk ("return dot(arg1, "+precision+outputDimension+"(0.2126729, 0.7151522, 0.0721750));", false);
outputString.Deindent ();
outputString.AddShaderChunk ("}", false);
visitor.AddShaderChunk (outputString.GetShaderString (0), true);
}
}
}